/* ============================================================
   OptimalFit — style.css (P2-2 design system)

   Tokens: spacing 4/8/12/16/24/32 · type 12/14/16/20/24/32
   (system-ui) · radius sm/md/lg/full · layered elevation ·
   semantic colors. Dark theme is the hero (deep blue-gray,
   violet→cyan gradient accent); light theme via
   prefers-color-scheme. Mobile-first at 375px: top app bar +
   5-tab bottom nav (Log opens an action sheet); desktop gets a
   left sidebar with all destinations. Zero external assets.
   ============================================================ */

/* ---------- 1. Design tokens ---------- */
:root {
  /* spacing scale */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  /* type scale */
  --fs-1: 12px; --fs-2: 14px; --fs-3: 16px; --fs-4: 20px; --fs-5: 24px; --fs-6: 32px;
  /* radius */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-full: 999px;
  --radius: var(--r-md); /* legacy alias */

  /* dark theme (hero) */
  --bg: #0a0e17;
  --bg-2: #10182a;
  --card: #131c30;
  --card-2: #182339;
  --card-edge: rgba(148, 163, 184, 0.14);
  --text: #e9eef8;
  --text-dim: #8d9bb2;
  --g1: #8b5cf6;              /* gradient start: violet */
  --g2: #22d3ee;              /* gradient end: cyan */
  --grad: linear-gradient(135deg, var(--g1) 0%, var(--g2) 100%);
  --accent: #8f9dff;          /* interactive tint on dark */
  --accent-soft: rgba(139, 118, 255, 0.14);
  --accent-2: #34d399;        /* success */
  --accent-2-soft: rgba(52, 211, 153, 0.13);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.13);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.13);
  --ring-track: rgba(148, 163, 184, 0.16);
  /* layered soft elevation */
  --e1: 0 1px 2px rgba(2, 6, 16, 0.5), 0 2px 8px rgba(2, 6, 16, 0.35);
  --e2: 0 2px 4px rgba(2, 6, 16, 0.5), 0 8px 24px rgba(2, 6, 16, 0.45);
  --e3: 0 4px 8px rgba(2, 6, 16, 0.55), 0 16px 48px rgba(2, 6, 16, 0.6);
  --shadow: var(--e1); /* legacy alias */

  --nav-w: 236px;
  --header-h: 56px;
  --dur: 0.18s;
  --ease: cubic-bezier(0.3, 0.7, 0.4, 1);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f5fa;
    --bg-2: #e9edf5;
    --card: #ffffff;
    --card-2: #f7f9fd;
    --card-edge: #dde3ef;
    --text: #1a2334;
    --text-dim: #5d6b83;
    --g1: #7c3aed;
    --g2: #0891b2;
    --accent: #5851d8;
    --accent-soft: rgba(88, 81, 216, 0.10);
    --accent-2: #059669;
    --accent-2-soft: rgba(5, 150, 105, 0.10);
    --warn: #b45309;
    --warn-soft: rgba(180, 83, 9, 0.10);
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.09);
    --ring-track: rgba(90, 105, 130, 0.16);
    --e1: 0 1px 2px rgba(28, 40, 64, 0.06), 0 2px 8px rgba(28, 40, 64, 0.06);
    --e2: 0 2px 4px rgba(28, 40, 64, 0.07), 0 8px 24px rgba(28, 40, 64, 0.09);
    --e3: 0 4px 8px rgba(28, 40, 64, 0.08), 0 16px 48px rgba(28, 40, 64, 0.14);
  }
}

/* ---------- 2. Base ---------- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: var(--fs-3);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  /* iOS: stop the rubber-band bounce from dragging the fixed bars along
     (the bottom tab bar "popped up" on overscroll, showing content under it) */
  overscroll-behavior-y: none;
}
body.ob-open { overflow: hidden; }

h1 { font-size: var(--fs-5); font-weight: 750; letter-spacing: -0.02em; margin: var(--sp-2) 0 var(--sp-4); }
h2 { font-size: var(--fs-3); font-weight: 700; letter-spacing: -0.01em; margin: 0 0 var(--sp-3); }
.muted { color: var(--text-dim); }
.small { font-size: 0.82rem; }
.hidden { display: none !important; }
.plain-list { margin: 6px 0; padding-left: 20px; }
.grad-text {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--accent-soft); }

/* inline SVG icons (icons.js) */
.ico { width: 22px; height: 22px; display: inline-block; vertical-align: middle; flex-shrink: 0; }
.ico-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}
.ico-badge .ico { width: 20px; height: 20px; }

/* ---------- 3. App shell: header + nav + content ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) var(--sp-4) 0;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--card-edge);
}
@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .app-header { background: var(--bg); }
}
/* Opaque slab painted ABOVE the header: if an overscroll bounce ever shifts
   the bar (iOS 15 lacks overscroll-behavior), solid background shows through
   the gap instead of page content. */
.app-header::before {
  content: "";
  position: absolute;
  left: 0; right: 0;
  bottom: 100%;
  height: 200px;
  background: var(--bg);
  pointer-events: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
}
.brand svg { display: block; }
.brand-word { color: var(--text); }
/* gradient the "Fit" <em> exactly (was a positional 47/53% stop that bled into
   "Optimal" since that word is ~70% of the lockup width) */
.brand-word em {
  font-style: normal;
  background: linear-gradient(90deg, var(--g1), var(--g2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  border: none;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.header-btn:hover { background: var(--card); color: var(--text); }
.header-btn:active { transform: scale(0.94); }
.header-btn.active { color: var(--accent); background: var(--accent-soft); }

.app-shell { display: flex; min-height: calc(100vh - var(--header-h)); }

.content {
  flex: 1;
  padding: var(--sp-4) clamp(14px, 3vw, 40px) 96px;
  max-width: 1060px;
  margin: 0 auto;
  width: 100%;
  min-width: 0;
}

/* tab entrance */
.tab { animation: tab-in var(--dur) var(--ease); }
@keyframes tab-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 4. Navigation ---------- */
.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: var(--nav-w);
  padding: var(--sp-4) var(--sp-3);
  border-right: 1px solid var(--card-edge);
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  flex-shrink: 0;
  overflow-y: auto;
}

.nav-sec {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  padding: var(--sp-4) var(--sp-3) var(--sp-1);
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 10px var(--sp-3);
  border: none;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.95rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.nav-btn:hover { background: var(--card); color: var(--text); }
.nav-btn:active { transform: scale(0.97); }
.nav-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.nav-ico { display: inline-flex; width: 24px; justify-content: center; }
.nav-ico .ico { width: 22px; height: 22px; }

/* the Log button + its label only exist on mobile */
.nav-log { display: none; }

/* ---------- 5. Cards & forms ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--r-lg);
  padding: var(--sp-4) 18px;
  margin-bottom: var(--sp-4);
  box-shadow: var(--e1);
}

.placeholder-card { border-style: dashed; box-shadow: none; background: transparent; }
.danger-card { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .danger-card { border-color: var(--danger); }
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.form-row label {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  flex: 1 1 130px;
  min-width: 120px;
}
/* keep the caption (e.g. "Weight (lb)") on one line so it can't break into
   "Weight (" / "lb" / ")" and shove the input out of alignment on iOS */
.form-row label { white-space: nowrap; }
.form-row label > input, .form-row label > select, .form-row label > textarea { white-space: normal; }
.form-row label.grow { flex: 3 1 220px; }

input, select, textarea {
  background: var(--bg-2);
  border: 1px solid var(--card-edge);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  /* 16px stops iOS Safari/WKWebView from auto-zooming the page on focus */
  font-size: 16px;
  font-weight: 500;
  font-family: inherit;
  width: 100%;
  min-height: 44px;
  line-height: 1.25;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
/* iOS/WebKit renders date/number/time/select with native chrome that keeps a
   wide intrinsic width and won't shrink into its flex cell — so the fields
   OVERLAP and space unevenly on iPhone (fine on Blink/Chrome/Android).
   Stripping the native appearance makes every input honor the box model.
   Checkboxes/radios keep native rendering on purpose. */
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}
/* appearance:none removes the native select arrow — add a custom caret */
select {
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238f9dff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
@media (prefers-color-scheme: light) {
  select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235851d8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  }
}
/* strip number spinners for a consistent field */
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
/* date/time: left-align the value so it fills the field like a text input
   instead of iOS's wide, centred native control */
input[type="date"]::-webkit-date-and-time-value,
input[type="time"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
input[type="date"], input[type="time"] { text-align: left; }
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator { opacity: 0.55; margin-left: 4px; }
input::placeholder, textarea::placeholder { color: var(--text-dim); opacity: 0.7; font-weight: 400; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--card-edge)); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--card);
}
input[type="checkbox"], input[type="radio"] { -webkit-appearance: auto; appearance: auto; width: auto; min-height: 0; transition: none; }

.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: var(--sp-2); }
.form-hint { color: var(--text-dim); font-size: 0.85rem; margin: 4px 0; min-height: 1em; }
.form-error { color: var(--danger); font-size: 0.88rem; margin: 4px 0; font-weight: 600; }

/* segmented 1-5 rating pills (ui.js swaps in for <select data-seg>) */
.seg-native { display: none !important; }
/* the 5-pill row needs ~230px — give rating labels their own row on
   narrow screens so nothing overflows at 375px */
@media (max-width: 719px) {
  .form-row label.seg-label { flex: 1 1 100%; }
}
.seg {
  display: flex;
  gap: 6px;
}
.seg-btn {
  flex: 1;
  min-width: 40px;
  min-height: 44px;
  border: 1px solid var(--card-edge);
  border-radius: var(--r-sm);
  background: var(--bg-2);
  color: var(--text-dim);
  font-size: 0.95rem;
  font-weight: 650;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease),
    border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.seg-btn:hover { border-color: var(--accent); color: var(--text); }
.seg-btn:active { transform: scale(0.94); }
.seg-btn.active {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--e1);
}

/* ---------- 6. Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--card-edge);
  background: var(--bg-2);
  color: var(--text);
  padding: 10px 18px;
  min-height: 44px;
  border-radius: var(--r-md);
  font-size: 0.92rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
    color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:hover { background: var(--card-2); border-color: color-mix(in srgb, var(--accent) 40%, var(--card-edge)); }
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--e1);
}
.btn.primary:hover { filter: brightness(1.08); box-shadow: var(--e2); }
.btn.danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn.danger:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn.ghost:hover { color: var(--text); background: var(--bg-2); }
.btn.mini { padding: 6px 12px; min-height: 36px; font-size: 0.8rem; border-radius: var(--r-sm); }
.btn.big { padding: 13px 24px; font-size: 1rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn .ico { width: 18px; height: 18px; }

/* ---------- 7. Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(8px);
  max-width: min(92vw, 480px);
  padding: 11px 18px;
  border-radius: var(--r-md);
  background: var(--card-2);
  border: 1px solid var(--danger);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--e3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
  z-index: 500;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-warn { border-color: var(--warn); }

/* ---------- 8. History lists ---------- */
.list-heading { margin: var(--sp-5) 0 var(--sp-3); font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); }

.history-list { display: flex; flex-direction: column; gap: var(--sp-2); }

.entry {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--r-md);
  padding: 10px 14px;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.entry:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--card-edge)); background: var(--card-2); }

.entry-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}
.entry-ico .ico { width: 18px; height: 18px; }

.entry-main { flex: 1; min-width: 0; }
.entry-title { font-weight: 650; font-size: 0.95rem; }
.entry-sub {
  color: var(--text-dim);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.entry-badge {
  background: var(--bg-2);
  border: 1px solid var(--card-edge);
  color: var(--text-dim);
  border-radius: var(--r-full);
  padding: 3px 11px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.entry-actions { display: flex; gap: 6px; flex-shrink: 0; }

.empty-msg {
  color: var(--text-dim);
  padding: var(--sp-4);
  text-align: center;
}

/* upgraded empty state (icon + one-liner + optional CTA) */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  color: var(--text-dim);
  padding: var(--sp-5) var(--sp-4);
}
.empty-state .ico-badge { width: 48px; height: 48px; border-radius: var(--r-lg); }
.empty-state .ico-badge .ico { width: 24px; height: 24px; }
.empty-state p { margin: 0; font-size: 0.92rem; max-width: 420px; }

/* today's summary strip on tracker tabs */
.today-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--r-md);
  padding: 10px 14px;
  margin-bottom: var(--sp-4);
  font-size: 0.88rem;
  color: var(--text-dim);
  box-shadow: var(--e1);
}
.today-strip:empty { display: none; }
.today-strip strong { color: var(--text); font-weight: 700; }
.today-strip .entry-ico { width: 30px; height: 30px; }
.today-strip .entry-ico .ico { width: 16px; height: 16px; }

/* ---------- 9. Dashboard: hero + stat cards ---------- */
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  margin: var(--sp-2) 0 var(--sp-5);
}
.hero-greet {
  font-size: clamp(1.35rem, 5vw, var(--fs-6));
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 0;
  line-height: 1.15;
}
.hero-date { color: var(--text-dim); font-size: 0.9rem; margin: 4px 0 0; font-weight: 500; }
.hero-ring { display: flex; flex-direction: column; align-items: center; gap: 2px; flex-shrink: 0; }
.hero-ring-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-dim);
}

/* progress ring (util.js progressRing) */
.ring { display: block; }
.ring-bg { fill: none; stroke: var(--ring-track); }
.ring-fg {
  fill: none;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset 0.5s var(--ease);
}
.ring-val { fill: var(--text); font-weight: 750; font-family: inherit; }
.ring-sub { fill: var(--text-dim); font-weight: 600; font-family: inherit; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.stat-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  box-shadow: var(--e1);
  overflow: hidden;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.stat-card:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--card-edge)); transform: translateY(-1px); box-shadow: var(--e2); }
.stat-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat-label { color: var(--text-dim); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.stat-value { font-size: 1.55rem; font-weight: 750; letter-spacing: -0.02em; margin-top: 4px; }
.stat-sub { color: var(--text-dim); font-size: 0.79rem; margin-top: 2px; }
.stat-value .unit { font-size: 0.9rem; color: var(--text-dim); font-weight: 550; }
.stat-spark { margin-top: 8px; }
.stat-spark svg { display: block; width: 100%; height: 30px; }

/* delta chips (+/- vs last week) */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border-radius: var(--r-full);
  padding: 2px 9px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}
.chip-up { background: var(--accent-2-soft); color: var(--accent-2); }
.chip-down { background: var(--danger-soft); color: var(--danger); }
.chip-flat { background: var(--bg-2); color: var(--text-dim); }

/* ---------- 10. Charts ---------- */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--sp-4);
}

.chart-card h2 { margin-bottom: var(--sp-3); }

.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }

.chart-grid { stroke: var(--card-edge); stroke-width: 1; stroke-dasharray: 2 4; }
.chart-txt { fill: var(--text-dim); font-size: 10px; font-weight: 500; font-family: inherit; }
.chart-txt-strong { fill: var(--text); font-size: 10px; font-weight: 650; font-family: inherit; }

.chart-mini-label {
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: var(--sp-3) 0 var(--sp-1);
}
.chart-mini-label:first-child { margin-top: 0; }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: var(--sp-2);
  font-size: 0.78rem;
  color: var(--text-dim);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.chart-empty {
  color: var(--text-dim);
  font-size: 0.88rem;
  padding: 18px 10px;
  text-align: center;
  border: 1px dashed var(--card-edge);
  border-radius: var(--r-sm);
  margin: 4px 0;
}

/* ---------- 11. Insight cards ---------- */
.insight-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: var(--sp-2);
}
.insight-head h2 { margin: 0; }
.ih-l { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.ih-l .ico-badge { width: 34px; height: 34px; }
.ih-l .ico-badge .ico { width: 18px; height: 18px; }

.conf {
  border-radius: var(--r-full);
  padding: 3px 11px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid transparent;
}
.conf-high { color: var(--accent-2); background: var(--accent-2-soft); }
.conf-medium { color: var(--warn); background: var(--warn-soft); }
.conf-low { color: var(--text-dim); background: var(--bg-2); }
.conf-need { color: var(--text-dim); border-color: var(--card-edge); border-style: dashed; }

.insight-headline { margin: 4px 0 var(--sp-2); font-size: 0.98rem; line-height: 1.55; }

/* Weekly plan: gradient edge + tinted wash */
.plan-card {
  position: relative;
  border: 1px solid transparent;
  background:
    linear-gradient(var(--card), var(--card)) padding-box,
    var(--grad) border-box;
  box-shadow: var(--e2);
}
.plan-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.09), rgba(34, 211, 238, 0.05));
  pointer-events: none;
}
.plan-card > * { position: relative; }
.plan-card .insight-headline { font-size: 1.05rem; font-weight: 650; }

.insight-sub { font-size: 0.82rem; display: flex; flex-wrap: wrap; gap: 6px 10px; }
.mini-stat {
  background: var(--bg-2);
  border: 1px solid var(--card-edge);
  border-radius: var(--r-sm);
  padding: 3px 9px;
  white-space: nowrap;
  font-weight: 550;
}

.factor-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.85rem;
}
.f-good { color: var(--accent-2); font-weight: 800; }
.f-bad { color: var(--danger); font-weight: 800; }
.f-neutral { color: var(--text-dim); font-weight: 800; }

/* ---------- 12. AI Coach ---------- */
.coach-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }

.coach-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: var(--sp-4);
  overflow-y: auto;
  min-height: 260px;
  max-height: 58vh;
}

.coach-empty { margin: 4px 0 var(--sp-2); font-size: 0.9rem; }

.coach-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.coach-chip {
  background: var(--bg-2);
  border: 1px solid var(--card-edge);
  color: var(--text);
  border-radius: var(--r-full);
  padding: 9px 15px;
  min-height: 40px;
  font-size: 0.85rem;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease),
    background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.coach-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.coach-chip:active { transform: scale(0.97); }

.msg-row { display: flex; align-items: flex-end; gap: 8px; max-width: 92%; }
.msg-row .bubble { max-width: 100%; }

.coach-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--r-full);
  background: var(--grad);
  color: #fff;
  flex-shrink: 0;
  box-shadow: var(--e1);
}
.coach-avatar .ico { width: 15px; height: 15px; }

.bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--r-lg);
  font-size: 0.93rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  animation: bubble-in var(--dur) var(--ease);
}
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
.bubble-user {
  align-self: flex-end;
  background: var(--grad);
  color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow: var(--e1);
}
.bubble-coach {
  background: var(--bg-2);
  border: 1px solid var(--card-edge);
  border-bottom-left-radius: 5px;
}
.bubble-error {
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-bottom-left-radius: 5px;
}
.bubble-thinking { color: var(--text-dim); }

/* typing indicator: three bouncing dots */
.dots { display: inline-flex; gap: 3px; margin-left: 2px; }
.dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  font-size: 0; /* hide the &bull; glyphs — the dot IS the element */
  animation: of-bounce 1.15s var(--ease) infinite;
}
.dots span:nth-child(2) { animation-delay: 0.18s; }
.dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes of-bounce {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.coach-input-row {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--card-edge);
  background: var(--card);
}
.coach-input-row input { flex: 1; min-width: 0; border-radius: var(--r-full); padding-left: 16px; }
.coach-input-row .btn { border-radius: var(--r-full); }
.coach-input-row input:disabled,
.coach-input-row .btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- 13. Pairing / phone info / health import ---------- */
.pair-input {
  max-width: 150px;
  font-size: 1.2rem;
  letter-spacing: 0.3em;
  text-align: center;
  font-weight: 700;
}
.phone-url {
  display: inline-block;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  padding: 6px 12px;
  margin: 4px 6px 4px 0;
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--accent);
  user-select: all;
}

.hi-preview-list { list-style: none; margin: var(--sp-2) 0; padding: 0; }
.hi-preview-list li { margin: 6px 0; font-size: 0.9rem; }
.hi-preview-list label { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.hi-preview-list input[type="checkbox"] {
  width: auto; min-height: 0; margin-top: 3px; accent-color: var(--accent);
}
.hi-range { color: var(--text-dim); font-size: 0.82rem; }

/* ---------- 14. Progress bars & rings ---------- */
.progress {
  height: 8px;
  background: var(--bg-2);
  border: none;
  border-radius: var(--r-full);
  overflow: hidden;
  margin: 6px 0 12px;
}
.progress-fill {
  height: 100%;
  border-radius: var(--r-full);
  transition: width 0.4s var(--ease);
  min-width: 0;
}

/* ---------- 15. Daily tab (water + steps) ---------- */
.daily-progress-line { margin: 2px 0 4px; font-size: 0.95rem; }

.quick-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 12px; }
.quick-row .btn { flex: 1 1 auto; }

.water-custom-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.water-custom-row input { max-width: 160px; }

.water-entries { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.water-entry {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-2);
  border: 1px solid var(--card-edge);
  border-radius: var(--r-full);
  padding: 5px 6px 5px 13px;
  font-size: 0.85rem;
  font-weight: 550;
}
.water-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--r-full);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.water-del:hover { color: var(--danger); background: var(--danger-soft); }

/* ---------- 16. Today-vs-targets strip (dashboard) ---------- */
.target-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--sp-3);
}
.target-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}
.target-cell-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-dim); }
.target-cell-val { font-size: 0.78rem; color: var(--text-dim); }
.target-row-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.85rem;
  margin-bottom: 2px;
}

/* ---------- 17. Goal card (Insights) ---------- */
.goal-card {
  border: 1px solid transparent;
  background:
    linear-gradient(var(--card), var(--card)) padding-box,
    linear-gradient(135deg, var(--accent-2), var(--g2)) border-box;
}
.goal-progress-flex { display: flex; align-items: center; gap: var(--sp-4); margin: var(--sp-2) 0; }
.goal-progress-flex .ring { flex-shrink: 0; }
.goal-progress-line { margin: 4px 0 2px; font-size: 0.92rem; }
.goal-note { margin: 6px 0 2px; font-size: 0.88rem; }
.goal-note.good { color: var(--accent-2); font-weight: 650; }
.goal-reality {
  border: 1px solid var(--warn);
  border-radius: var(--r-sm);
  background: var(--warn-soft);
  padding: 10px 12px;
  font-size: 0.86rem;
  margin: 10px 0;
}
.adj-log {
  list-style: none;
  margin: 4px 0 6px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.adj-log strong { color: var(--text); font-weight: 650; }

/* ---------- 18. Log action sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 300; }
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 16, 0.6);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: fade-in var(--dur) var(--ease);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.sheet-panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  margin: 0 auto;
  max-width: 520px;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-bottom: none;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: var(--sp-2) var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--e3);
  animation: sheet-up 0.22s var(--ease);
}
@keyframes sheet-up {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.sheet-grab {
  width: 40px; height: 4px;
  border-radius: var(--r-full);
  background: var(--card-edge);
  margin: 4px auto 14px;
}
.sheet-panel h2 { text-align: center; margin-bottom: var(--sp-4); }
.sheet-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
/* an odd last item (e.g. "Water & steps") spans both columns so it doesn't
   sit alone half-width and wrap awkwardly */
.sheet-grid .sheet-item:last-child:nth-child(odd) { grid-column: 1 / -1; }
.sheet-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--bg-2);
  border: 1px solid var(--card-edge);
  color: var(--text);
  font-weight: 650;
  font-size: 0.95rem;
  text-decoration: none;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.sheet-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.sheet-item:active { transform: scale(0.97); }
.sheet-cancel { width: 100%; }

/* ---------- 19. Onboarding overlay ---------- */
#onboarding { position: fixed; inset: 0; z-index: 400; }
.ob-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 16, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fade-in 0.25s var(--ease);
}
.ob-panel {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(94vw, 460px);
  max-height: min(88vh, 700px);
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--r-lg);
  padding: var(--sp-6) var(--sp-5) var(--sp-5);
  box-shadow: var(--e3);
  animation: ob-in 0.25s var(--ease);
}
@keyframes ob-in {
  from { opacity: 0; transform: translate(-50%, -48%) scale(0.97); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.ob-close {
  position: absolute;
  top: 10px; right: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  border: none;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.ob-close:hover { background: var(--bg-2); color: var(--text); }
.ob-logo { display: flex; justify-content: center; margin-bottom: var(--sp-4); }
.ob-title { font-size: var(--fs-5); font-weight: 800; letter-spacing: -0.02em; text-align: center; margin: 0 0 var(--sp-2); }
.ob-lead { color: var(--text-dim); text-align: center; font-size: 0.94rem; margin: 0 0 var(--sp-4); }
.ob-list { list-style: none; margin: 0 0 var(--sp-4); padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.ob-list li { display: flex; gap: 12px; align-items: flex-start; font-size: 0.9rem; color: var(--text-dim); }
.ob-list li strong { color: var(--text); }
.ob-goals { display: flex; flex-direction: column; gap: 8px; margin-bottom: var(--sp-4); }
.ob-goal {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--card-edge);
  border-radius: var(--r-md);
  background: var(--bg-2);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
/* hover:hover gate stops iOS keeping the :hover accent border "stuck" on a
   tapped-but-unselected goal (it looked half-selected next to the real pick) */
@media (hover: hover) { .ob-goal:hover { border-color: var(--accent); } }
.ob-goal.active { border-color: var(--accent); background: var(--accent-soft); }
.ob-goal-check { display: inline-flex; width: 20px; color: var(--accent); opacity: 0; transition: opacity var(--dur) var(--ease); }
.ob-goal-check .ico { width: 18px; height: 18px; }
.ob-goal.active .ob-goal-check { opacity: 1; }
.ob-dots { display: flex; justify-content: center; gap: 6px; margin: var(--sp-2) 0 var(--sp-4); }
.ob-dot {
  width: 7px; height: 7px;
  border-radius: var(--r-full);
  background: var(--card-edge);
  transition: background var(--dur) var(--ease), width var(--dur) var(--ease);
}
.ob-dot.active { background: var(--accent); width: 20px; }
.ob-actions { display: flex; flex-direction: column; gap: 8px; }
.ob-actions .btn { width: 100%; }
.ob-demo-note { text-align: center; margin: 2px 0 0; }

/* ---------- 19b. Food photo estimate (food-photo.js) ---------- */
.photo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: var(--sp-3);
}
.photo-btn,
.photo-file-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.photo-btn .ico,
.photo-file-btn .ico { width: 18px; height: 18px; }
.photo-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.photo-hint { font-size: 0.8rem; }

.photo-panel { max-height: 86vh; overflow-y: auto; }
.photo-pick-row { display: flex; justify-content: center; margin-bottom: var(--sp-3); }
.photo-preview { margin-bottom: var(--sp-3); }
.photo-preview:empty { margin-bottom: 0; }
.photo-preview img {
  display: block;
  max-width: 100%;
  max-height: 220px;
  margin: 0 auto;
  border-radius: var(--r-md);
  border: 1px solid var(--card-edge);
}
.photo-desc-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  font-weight: 550;
  margin-bottom: var(--sp-2);
}
.photo-desc-label textarea {
  background: var(--bg-2);
  border: 1px solid var(--card-edge);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
  margin-top: 4px;
  resize: vertical;
  min-height: 58px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.photo-desc-label textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--card);
}
.photo-thinking { margin-bottom: var(--sp-3); }
.photo-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.photo-food-name { font-size: 1.05rem; }
.photo-portion { margin: 0 0 var(--sp-2); }
.photo-macros {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-2) var(--sp-3);
  margin: var(--sp-3) 0;
}
.photo-macros label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 550;
}
.photo-notes { margin: 0 0 var(--sp-2); }

/* ---------- 19c. Physique photo analysis (physique.js / insights) ---------- */
.phys-privacy {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0 0 var(--sp-3);
  line-height: 1.4;
}
.phys-privacy .ico { width: 15px; height: 15px; flex: 0 0 auto; margin-top: 2px; color: var(--accent-2); }
.phys-musc { font-size: 1rem; }
.phys-bf { margin: 0 0 var(--sp-2); font-weight: 600; }
.phys-regions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px var(--sp-3);
  margin: var(--sp-2) 0 var(--sp-3);
}
.phys-region {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-2);
  border: 1px solid var(--card-edge);
  border-radius: var(--r-sm);
  font-size: 0.85rem;
}
.phys-region-name { color: var(--text-dim); font-weight: 600; }
.phys-region-note { text-align: right; }
.phys-chip-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 0 var(--sp-2);
}
.phys-chip-label { font-size: 0.78rem; color: var(--text-dim); font-weight: 600; margin-right: 2px; }
.phys-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 0.8rem;
  font-weight: 550;
  border: 1px solid var(--card-edge);
}
.phys-chip.good { color: var(--accent-2); border-color: color-mix(in srgb, var(--accent-2) 40%, transparent); background: color-mix(in srgb, var(--accent-2) 12%, transparent); }
.phys-chip.focus { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.phys-assessment { margin: var(--sp-2) 0; line-height: 1.5; }
.phys-notes, .phys-disclaimer { margin: 0 0 var(--sp-2); line-height: 1.4; }
.physique-card .phys-regions { margin-top: var(--sp-3); }

/* ---------- 20. Mobile (<720px): bottom tab bar ---------- */
@media (max-width: 719px) {
  .app-shell { flex-direction: column-reverse; min-height: auto; }

  .nav {
    flex-direction: row;
    width: 100%;
    height: auto;
    position: fixed;
    top: auto;   /* cancel the desktop sticky top, else the bar stretches full height */
    bottom: 0;
    left: 0;
    z-index: 50;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    border-right: none;
    border-top: 1px solid var(--card-edge);
    justify-content: space-around;
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    overflow: visible;
  }
  @supports not (background: color-mix(in srgb, red 50%, blue)) {
    .nav { background: var(--bg); }
  }
  /* Opaque slab painted BELOW the fixed tab bar: during an iOS rubber-band
     bounce the bar lifts with the page — this makes the revealed strip solid
     background instead of page content peeking under the bar. */
  .nav::after {
    content: "";
    position: absolute;
    left: 0; right: 0;
    top: 100%;
    height: 200px;
    background: var(--bg);
    pointer-events: none;
  }

  /* mobile shows exactly 5 destinations: sections + tracker/settings
     buttons live in the Log sheet / header gear instead */
  /* Mobile bar = 4 destinations (Dashboard, Insights, Coach, Community) split
     2-2 around a truly-centered raised Log FAB. Daily (water/steps) moves into
     the Log sheet as a log action, so nothing is lost. */
  .nav-sec, .nav-sub { display: none; }
  .nav-btn[data-tab="daily"] { display: none; }
  .nav-log { display: flex; }
  .nav-btn[data-tab="dashboard"] { order: 1; }
  .nav-btn[data-tab="insights"]  { order: 2; }
  .nav-log                       { order: 3; }
  .nav-btn[data-tab="coach"]     { order: 4; }
  .nav-btn[data-tab="community"] { order: 5; }

  .nav-btn {
    flex-direction: column;
    gap: 3px;
    padding: 6px 2px;
    flex: 1;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    min-width: 0;
    min-height: 52px;
    border-radius: var(--r-md);
  }
  .nav-btn.active { background: transparent; }
  .nav-lbl { font-size: 0.62rem; font-weight: 650; letter-spacing: 0.01em; }
  .nav-ico { width: auto; }

  /* Log = the centered raised circular FAB (the focal "do" action). Lift the
     whole BUTTON (not just the icon) so the protruding top of the circle stays
     inside the tappable box; label-less (aria-label keeps a11y). */
  .nav-log {
    flex: 1;
    overflow: visible;
    transform: translateY(-14px);
  }
  .nav-log .nav-lbl { display: none; }
  .nav-log .nav-ico {
    width: 52px; height: 52px;
    border-radius: var(--r-full);
    background: var(--grad);
    color: #fff;
    align-items: center;
    /* plain fallbacks first — the color-mix versions live in @supports below,
       else iOS 15-16.1 drops the WHOLE declaration (no ring, no elevation) */
    border: 2px solid rgba(10, 14, 23, 0.7);
    box-shadow: var(--e2);
    transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
  }
  @supports (background: color-mix(in srgb, red 50%, blue)) {
    .nav-log .nav-ico {
      border: 2px solid color-mix(in srgb, var(--bg) 70%, transparent);
      box-shadow: var(--e2), 0 6px 18px color-mix(in srgb, var(--g1) 45%, transparent);
    }
    .nav-log:active .nav-ico { box-shadow: var(--e1), 0 3px 10px color-mix(in srgb, var(--g1) 40%, transparent); }
  }
  .nav-log .nav-ico .ico { width: 24px; height: 24px; }
  .nav-log:active { transform: translateY(-14px) scale(0.94); }
  .nav-log.active .nav-ico { box-shadow: var(--e2), 0 0 0 3px var(--accent-soft); }

  /* clear the bottom nav + the iOS home indicator (safe area) */
  .content { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }

  .entry { flex-wrap: wrap; }
  .entry-actions { margin-left: auto; }

  .hero { margin-top: 0; }
}

/* very narrow phones: tighten paddings a touch */
@media (max-width: 380px) {
  .card { padding: 14px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- 21. Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ---------- 22. Exercise sets builder (P2-11) ---------- */
.ex-builder {
  border: 1px solid var(--card-edge);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  margin-bottom: var(--sp-3);
  background: var(--bg-2);
}
.ex-builder-head {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  margin-bottom: var(--sp-2);
}
.ex-builder-hint { font-weight: 400; opacity: 0.8; }
.ex-item {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  margin-bottom: var(--sp-2);
}
.ex-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: 8px;
}
.ex-item-name { font-weight: 650; font-size: 0.95rem; overflow-wrap: anywhere; }
.set-row {
  display: grid;
  grid-template-columns: 20px minmax(90px, 1fr) auto minmax(70px, 1fr) 44px;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}
.set-num { color: var(--text-dim); font-size: 0.78rem; font-weight: 600; text-align: right; }
.set-x { color: var(--text-dim); font-size: 0.82rem; white-space: nowrap; }
.set-del {
  min-height: 44px;
  min-width: 44px;
  padding: 0 10px;
  line-height: 1;
}
.set-add { min-height: 44px; }
.ex-add-row {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  align-items: center;
}
.ex-add-row input { flex: 1 1 180px; }
.ex-add-row .btn { min-height: 44px; }

/* Feature B: "prefilled from your last session" hint */
.ex-prefill-hint {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--accent-2);
  margin: -2px 0 8px;
}

/* history: per-exercise set-summary lines */
.entry-sets { margin-top: 4px; }
.set-line { font-size: 0.8rem; color: var(--text); }
.set-line-detail { color: var(--text-dim); }

/* ---------- 23. Rest timer (Exercise tab, Feature A) ---------- */
#exercise-timer { margin-bottom: var(--sp-4); }
.rt-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-3);
}
.rt-title { margin: 0; font-size: var(--fs-3); }
.rt-seg {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  background: var(--bg-2);
  border: 1px solid var(--card-edge);
  border-radius: var(--r-md);
}
.rt-seg-btn {
  min-height: 44px;
  padding: 0 14px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 650;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.rt-seg-btn:hover { color: var(--text); }
.rt-seg-btn.active { background: var(--card); color: var(--text); box-shadow: var(--e1); }
.rt-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4) var(--sp-3);
  margin-bottom: var(--sp-3);
  border: 1px solid var(--card-edge);
  border-radius: var(--r-md);
  background: var(--bg-2);
}
.rt-time {
  font-size: clamp(2.6rem, 14vw, 3.6rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.rt-status {
  min-height: 1.2em;
  margin-top: 6px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-dim);
}
.rt-presets { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.rt-preset { flex: 1 1 auto; min-width: 64px; min-height: 44px; }
.rt-preset.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.rt-controls { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.rt-start { flex: 1 1 130px; min-height: 48px; font-size: 1rem; }
.rt-reset { min-height: 48px; }
.rt-adjust { display: flex; gap: var(--sp-2); margin-left: auto; }
.rt-adj { min-height: 44px; min-width: 56px; }
/* Finish cue: a STEADY color change is the baseline (reduced-motion safe);
   a gentle pulse layers on top only when motion is allowed. */
.rt-finished .rt-display { border-color: var(--accent-2); background: var(--accent-2-soft); }
.rt-finished .rt-time, .rt-finished .rt-status { color: var(--accent-2); }
@media (prefers-reduced-motion: no-preference) {
  .rt-finished .rt-display { animation: rt-pulse 0.9s ease-in-out 3; }
}
@keyframes rt-pulse {
  0%, 100% { background: var(--accent-2-soft); }
  50% { background: color-mix(in srgb, var(--accent-2) 28%, transparent); }
}

/* ---------- 24. Community (social.js / social-profile.js / social-compose.js) ---------- */
.soc-center { text-align: center; padding: var(--sp-4); }
#social-sheet2 { z-index: 320; } /* stacks above #social-sheet (300) */
.soc-panel { max-height: 88vh; overflow-y: auto; }

.soc-link {
  background: none; border: none; padding: 0;
  color: var(--accent); font: inherit; font-weight: 650;
  text-decoration: underline; cursor: pointer;
}
.soc-check {
  display: flex; align-items: center; gap: 10px;
  margin: 10px 0; font-size: 0.92rem; color: var(--text); cursor: pointer;
}
.soc-check input[type="checkbox"], .soc-check input[type="radio"] {
  width: 20px; height: 20px; min-height: 0; flex-shrink: 0; accent-color: var(--accent);
}

/* opt-in pitch */
.soc-pitch { max-width: 560px; }
.soc-pitch-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; border-radius: var(--r-lg);
  background: var(--grad); color: #fff; box-shadow: var(--e1); margin-bottom: var(--sp-3);
}
.soc-pitch-list { margin: 0 0 var(--sp-3); padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 0.9rem; }
.soc-pitch-list li strong { color: var(--text); }
.soc-auth-note { margin-top: -6px; }
.soc-auth-switch { margin-top: var(--sp-3); }
.soc-terms p { font-size: 0.9rem; }

/* avatars */
.soc-ava {
  width: 40px; height: 40px; border-radius: var(--r-full);
  object-fit: cover; flex-shrink: 0;
  background: var(--bg-2); border: 1px solid var(--card-edge);
}
.soc-ava-txt {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--grad); border-color: transparent; color: #fff;
  font-weight: 800; font-size: 1rem;
}
.soc-ava-xs { width: 24px; height: 24px; font-size: 0.7rem; }
.soc-ava-sm { width: 30px; height: 30px; font-size: 0.8rem; }
.soc-ava-lg { width: 72px; height: 72px; font-size: 1.8rem; }

/* signed-in header row + quick actions */
.soc-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.soc-me {
  display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 44px;
  background: none; border: none; padding: 2px; cursor: pointer;
  color: var(--text); text-align: left; font-family: inherit; border-radius: var(--r-md);
}
.soc-me:hover { background: var(--card); }
.soc-me-names { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.soc-me-names strong { font-size: 0.98rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.soc-quick { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: var(--sp-3); }
.soc-quick-btn {
  flex: 1 1 104px; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 46px; padding: 8px 10px;
  border: 1px solid var(--card-edge); border-radius: var(--r-md);
  background: var(--card); color: var(--text); font-size: 0.85rem; font-weight: 650;
  font-family: inherit; cursor: pointer; box-shadow: var(--e1); min-width: 0;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.soc-quick-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.soc-quick-btn .ico { width: 18px; height: 18px; }
.soc-quick-btn:hover { border-color: var(--accent); }
.soc-quick-btn:active { transform: scale(0.97); }
.soc-quick-btn.done { color: var(--accent-2); border-color: var(--accent-2); background: var(--accent-2-soft); }
.soc-quick-btn:disabled { opacity: 0.6; cursor: default; }

/* Home / Discover segmented bar (also reused for compose kinds & board scopes) */
.soc-feed-bar {
  display: flex; gap: 4px; padding: 4px;
  background: var(--bg-2); border: 1px solid var(--card-edge); border-radius: var(--r-full);
  margin-bottom: var(--sp-4); overflow-x: auto;
}
.soc-feed-tab {
  flex: 1; min-height: 40px; padding: 6px 16px;
  border: none; border-radius: var(--r-full); background: transparent;
  color: var(--text-dim); font-size: 0.9rem; font-weight: 650; font-family: inherit;
  cursor: pointer; white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.soc-feed-tab.active { background: var(--grad); color: #fff; box-shadow: var(--e1); }

/* post cards */
.soc-post { padding: 14px 16px; }
.soc-post-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.soc-user {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; min-height: 44px;
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--text); text-align: left; font-family: inherit;
}
.soc-user-names { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.soc-user-name { font-weight: 700; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.soc-user-handle { font-size: 0.75rem; }
.soc-time { font-size: 0.75rem; white-space: nowrap; }
.soc-menu-btn {
  width: 44px; height: 44px; margin: -6px -10px -6px 0; flex-shrink: 0;
  background: none; border: none; border-radius: var(--r-md);
  color: var(--text-dim); font-size: 1.25rem; line-height: 1; cursor: pointer;
}
.soc-menu-btn:hover { background: var(--bg-2); color: var(--text); }

.soc-img-wrap {
  border-radius: var(--r-md); overflow: hidden;
  border: 1px solid var(--card-edge); margin: 6px 0; background: var(--bg-2);
}
.soc-img { display: block; width: 100%; max-height: 440px; object-fit: cover; }
.soc-caption { margin: 8px 0 2px; font-size: 0.95rem; white-space: pre-wrap; overflow-wrap: break-word; }
.soc-hidden-note { margin: 6px 0 0; font-style: italic; }

.soc-post-actions { display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.soc-act {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 6px 10px;
  background: none; border: none; border-radius: var(--r-md);
  color: var(--text-dim); font-size: 0.88rem; font-weight: 650; font-family: inherit; cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.soc-act:hover { background: var(--bg-2); color: var(--text); }
.soc-act:active { transform: scale(0.94); }
.soc-act .ico { width: 19px; height: 19px; }
.soc-act.liked { color: var(--danger); }
.soc-act.liked .ico { fill: var(--danger); stroke: var(--danger); }
.soc-kind {
  margin-left: auto;
  background: var(--bg-2); border: 1px solid var(--card-edge); color: var(--text-dim);
  border-radius: var(--r-full); padding: 3px 11px; font-size: 0.72rem; font-weight: 700;
}

/* receipt posts: gradient-edged stat block */
.soc-receipt {
  border: 1px solid transparent; border-radius: var(--r-md);
  background:
    linear-gradient(var(--card-2), var(--card-2)) padding-box,
    var(--grad) border-box;
  padding: 12px 14px; margin: 6px 0;
}
.soc-receipt-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.soc-verified {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--accent-2); font-size: 0.72rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.soc-verified .ico { width: 14px; height: 14px; }
.soc-receipt-tag {
  color: var(--text-dim); background: var(--bg-2); border-radius: var(--r-full);
  padding: 2px 10px; font-size: 0.72rem; font-weight: 700;
}
.soc-receipt-type { color: var(--text-dim); font-size: 0.8rem; font-weight: 650; }
.soc-receipt-metric { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.01em; }

/* receipt card bodies (P3-6): sparkline / 7-day grid / stat row */
.rc-spark { display: block; width: 100%; max-width: 260px; height: 56px; margin: 6px 0 2px; }
.rc-days { display: flex; gap: 5px; margin: 8px 0 4px; }
.rc-day {
  width: 24px; height: 24px; border-radius: 7px;
  background: var(--bg-2); border: 1px solid var(--card-edge);
}
.rc-day.on { background: var(--grad); border-color: transparent; }
.rc-stats { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }

/* Receipts-Day banner (Community tab) + drop section headers */
.soc-receipts-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border: 1px solid transparent; border-radius: var(--r-md);
  background:
    linear-gradient(var(--card-2), var(--card-2)) padding-box,
    var(--grad) border-box;
  padding: 10px 14px; margin-bottom: 12px; font-size: 0.88rem;
}
.soc-receipts-banner .ico, .soc-receipts-banner-ico svg { width: 18px; height: 18px; flex-shrink: 0; }
.soc-receipts-banner-ico { display: inline-flex; color: var(--g2); }
.soc-receipts-banner-txt { flex: 1; min-width: 180px; }
.soc-receipts-banner .btn { flex-shrink: 0; }
.soc-drop-head {
  display: flex; align-items: center; gap: 8px;
  margin: 14px 2px 10px; font-size: 0.82rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.07em;
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.soc-drop-head .ico { width: 16px; height: 16px; color: var(--g2); -webkit-text-fill-color: initial; }
.soc-drop-head.soc-drop-rest {
  background: none; -webkit-text-fill-color: initial;
  color: var(--text-dim);
}

/* composer receipt picker */
.rc-pick { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 12px; }
.rc-pick-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  text-align: left; padding: 10px 14px; cursor: pointer;
  background: var(--card-2); color: var(--text);
  border: 1px solid var(--card-edge); border-radius: var(--r-md);
  font: inherit; font-size: 0.9rem;
}
.rc-pick-item.active {
  border-color: transparent;
  background:
    linear-gradient(var(--card-2), var(--card-2)) padding-box,
    var(--grad) border-box;
}
.rc-pick-item strong { font-weight: 750; }

/* dashboard Receipts-Day nudge */
.receipts-nudge {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; font-size: 0.88rem;
}
.receipts-nudge-txt { flex: 1; min-width: 180px; display: inline-flex; align-items: center; gap: 8px; }
.receipts-nudge-txt .ico { width: 16px; height: 16px; color: var(--g2); flex-shrink: 0; }
#dash-receipts:empty { display: none; }

/* insights: community benchmark line + PR-share nudge */
.lift-bench { margin-top: 3px; font-size: 0.76rem; }
.lift-pr-share {
  margin-top: 4px; padding: 0; font-size: 0.8rem; font-weight: 700;
  background: none; border: none; cursor: pointer;
}

/* comments */
.soc-cmts { border-top: 1px solid var(--card-edge); margin-top: 8px; padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.soc-cmts:empty { display: none; }
.soc-cmt { display: flex; align-items: flex-start; gap: 8px; font-size: 0.88rem; }
.soc-cmt-body { flex: 1; min-width: 0; overflow-wrap: break-word; }
.soc-cmt-name { font-weight: 700; }
.soc-cmt-time { font-size: 0.72rem; margin-left: 6px; white-space: nowrap; }
.soc-cmt-btns { display: inline-flex; flex-shrink: 0; }
.soc-cmt-act {
  width: 44px; height: 44px; background: none; border: none; border-radius: var(--r-full);
  color: var(--text-dim); font-size: 1rem; font-weight: 700; line-height: 1; cursor: pointer;
}
.soc-cmt-act:hover { background: var(--danger-soft); color: var(--danger); }
.soc-cmts-more {
  background: none; border: none; padding: 4px 0; text-align: left;
  color: var(--text-dim); font-size: 0.85rem; font-weight: 650; font-family: inherit; cursor: pointer;
}
.soc-cmts-more:hover { color: var(--accent); }
.soc-cmt-form { display: flex; gap: 8px; }
.soc-cmt-form input { flex: 1; min-width: 0; min-height: 40px; border-radius: var(--r-full); padding-left: 14px; }

.soc-more { display: flex; justify-content: center; margin: var(--sp-2) 0 var(--sp-5); }

/* post-menu sheet */
.soc-menu-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: var(--sp-2); }
.soc-menu-item {
  display: flex; align-items: center; min-height: 50px; padding: 10px 14px;
  border: 1px solid var(--card-edge); border-radius: var(--r-md);
  background: var(--bg-2); color: var(--text); font-size: 0.95rem; font-weight: 600;
  font-family: inherit; cursor: pointer; text-align: left;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.soc-menu-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.soc-menu-item.danger { color: var(--danger); }
.soc-menu-item.danger:hover { border-color: var(--danger); background: var(--danger-soft); }
.soc-report-reasons { margin: var(--sp-2) 0; }
.soc-report-reasons .soc-check { margin: 6px 0; }

/* gyms + blocked list */
.soc-gym-list { max-height: 40vh; overflow-y: auto; margin: 2px 0 var(--sp-2); }
.soc-gym-mine { margin-bottom: var(--sp-3); }
.soc-gym-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: 9px 2px; border-bottom: 1px solid var(--card-edge);
}
.soc-gym-row:last-child { border-bottom: none; }
.soc-gym-name { font-weight: 600; font-size: 0.92rem; overflow-wrap: anywhere; }
.soc-gym-none { padding: var(--sp-2) 0; }

/* leaderboards */
.soc-lb-scopes { margin-bottom: var(--sp-2); }
.soc-lb-metrics { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: var(--sp-3); }
.soc-chip-on { border-color: var(--accent) !important; color: var(--accent) !important; background: var(--accent-soft) !important; }
.soc-lb-rows { margin-bottom: var(--sp-3); }
.soc-lb-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px; border-bottom: 1px solid var(--card-edge);
}
.soc-lb-row:last-child { border-bottom: none; }
.soc-lb-row.me { background: var(--accent-soft); border-radius: var(--r-md); border-bottom-color: transparent; }
.soc-lb-rank { width: 26px; text-align: right; font-weight: 800; color: var(--text-dim); flex-shrink: 0; }
.soc-lb-name { flex: 1; min-width: 0; text-align: left; text-decoration: none; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.soc-lb-val { font-weight: 800; white-space: nowrap; }

/* profiles */
.soc-prof-head { display: flex; align-items: center; gap: var(--sp-4); margin-bottom: var(--sp-2); }
.soc-prof-names h2 { margin: 0 0 2px; font-size: var(--fs-4); }
.soc-prof-names p { margin: 0; }
.soc-prof-bio { margin: 6px 0; font-size: 0.92rem; white-space: pre-wrap; overflow-wrap: break-word; }
.soc-prof-stats {
  display: flex; align-items: center; gap: 6px; margin: 6px 0;
  color: var(--accent); font-size: 0.88rem; font-weight: 650;
}
.soc-prof-stats .ico { width: 16px; height: 16px; }
.soc-prof-counts { display: flex; gap: var(--sp-4); margin: var(--sp-2) 0; font-size: 0.9rem; color: var(--text-dim); }
.soc-prof-counts strong { color: var(--text); }
.soc-prof-actions { margin-bottom: var(--sp-2); }
.soc-prof-posts { margin-top: var(--sp-3); }
.soc-edit-ava-row { display: flex; align-items: center; gap: var(--sp-4); margin-bottom: var(--sp-2); }
.soc-stats-share { margin: var(--sp-2) 0; }

/* composer */
.soc-kind-bar { margin-bottom: var(--sp-3); }
.soc-attach { margin-bottom: var(--sp-2); }
.soc-attach-item {
  display: block; width: 100%; margin: 6px 0; padding: 10px 12px; min-height: 44px;
  border: 1px dashed var(--card-edge); border-radius: var(--r-md);
  background: var(--bg-2); color: var(--text); font-size: 0.84rem; font-family: inherit;
  cursor: pointer; text-align: left; overflow-wrap: anywhere;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.soc-attach-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.soc-attach-none { margin: 0 0 var(--sp-2); }
.soc-comp-count { text-align: right; margin: 2px 0 var(--sp-2); }

/* narrow phones: check-in gets its own row so no label truncates */
@media (max-width: 430px) {
  .soc-quick-btn { font-size: 0.8rem; padding: 8px 8px; gap: 6px; }
  .soc-quick-btn .ico { width: 16px; height: 16px; }
  .soc-quick-btn:first-child { flex-basis: 100%; }
}

/* ---------- 23. Strength & lifting insight cards (P2-11) ---------- */
.lift-rows { margin-top: 4px; }
.lift-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 8px 0;
  border-top: 1px solid var(--card-edge);
}
.lift-row:first-child { border-top: none; }
.lift-main { flex: 1; min-width: 0; }
.lift-name { font-weight: 650; font-size: 0.92rem; color: var(--text); }
.lift-sub { font-size: 0.78rem; color: var(--text-dim); overflow-wrap: anywhere; }
.spark { flex-shrink: 0; }
.pr-badge {
  display: inline-block;
  background: linear-gradient(120deg, var(--g1), var(--g2));
  color: #fff;
  border-radius: var(--r-full);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  vertical-align: 2px;
}
.conf-bad { color: var(--danger); background: var(--danger-soft); }
.lift-pending { font-size: 0.8rem; margin: 8px 0 0; }
@media (max-width: 480px) {
  .lift-row { flex-wrap: wrap; }
  .lift-row .spark { order: 3; }
  /* long verdict chips wrap below the name instead of squeezing it */
  .lift-main { min-width: 70%; }
}

/* Bottom-nav labels are ~10px; text-dim (#5d6b83) is sub-AA on the light bg.
   Darken nav labels in light mode for WCAG AA (icons already carry meaning). */
@media (prefers-color-scheme: light) {
  .nav-btn { color: #46526a; }
  .nav-btn.active { color: #4a30c0; }
}

/* ============================================================
   26. Pre-ship visual polish (design-audit high-impact set)
   Additive refinements over existing selectors — tokens only,
   dark+light safe, >=44px targets preserved, degrade gracefully.
   ============================================================ */

/* [dashboard] Tabular numerals + crisper value block across all dashboard numbers */
.stat-value,
.stat-value .unit,
.ring-val, .ring-sub,
.chip,
.target-cell-val {
  font-variant-numeric: tabular-nums;
}
.stat-value {
  line-height: 1.1;   /* was default 1.5 — tightens the value into a solid block */
}

/* [dashboard] Lit-from-above depth on stat cards (gradient + inset highlight) */
.stat-card {
  background: linear-gradient(180deg, var(--card-2), var(--card));
  box-shadow: var(--e1), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.stat-card:hover {
  box-shadow: var(--e2), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

/* [dashboard] Soft focal glow behind the readiness ring */
.hero-ring { position: relative; isolation: isolate; }
.hero-ring::before {
  content: "";
  position: absolute;
  top: -6px; left: 50%;
  width: 88px; height: 88px;   /* ring is 76px; halo sits just outside it */
  transform: translateX(-50%);
  border-radius: var(--r-full);
  background: radial-gradient(circle, var(--accent-soft) 0%, transparent 68%);
  z-index: -1;
  pointer-events: none;
}
.hero-ring .ring-fg {
  filter: drop-shadow(0 1px 4px rgba(2, 6, 16, 0.5));
}

/* [dashboard] Crisper delta chips with a hairline edge */
.chip {
  padding: 3px 10px;              /* was 2px 9px */
  border: 1px solid transparent;
}
.chip-up { border-color: color-mix(in srgb, var(--accent-2) 24%, transparent); }
.chip-down { border-color: color-mix(in srgb, var(--danger) 24%, transparent); }
.chip-flat { border-color: var(--card-edge); }

/* [insights] Give the goal card the plan card's premium treatment (wash + elevation) */
.goal-card {
  position: relative;
  box-shadow: var(--e2);
}
.goal-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.08), rgba(34, 211, 238, 0.05));
  pointer-events: none;
}
.goal-card > * { position: relative; }

/* [insights] Define the confidence & verdict pills with tinted borders */
.conf { letter-spacing: 0.01em; }
.conf-high   { border-color: color-mix(in srgb, var(--accent-2) 34%, transparent); }
.conf-medium { border-color: color-mix(in srgb, var(--warn)    34%, transparent); }
.conf-bad    { border-color: color-mix(in srgb, var(--danger)  34%, transparent); }
.conf-low    { border-color: var(--card-edge); }
/* optional: same treatment for the +/- delta chips */
.chip-up   { border: 1px solid color-mix(in srgb, var(--accent-2) 30%, transparent); }
.chip-down { border: 1px solid color-mix(in srgb, var(--danger)  30%, transparent); }

/* [forms] Enclose the 1-5 rating pills in a real segmented-control track */
.seg {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--bg-2);
  border: 1px solid var(--card-edge);
  border-radius: var(--r-md);
}
.seg-btn {
  border: none;
  background: transparent;
  border-radius: var(--r-sm);
}
/* hover only on real pointers (iOS sticky-hover would repaint the SELECTED
   pill flat after tapping it — same gate as .ob-goal); never mask .active */
@media (hover: hover) {
  .seg-btn:not(.active):hover {
    background: var(--card);
    border-color: transparent;
    color: var(--text);
  }
}

/* [forms] Make the rest-timer a gradient hero readout instead of a flat box */
.rt-display {
  padding: var(--sp-5) var(--sp-3);
  background: linear-gradient(180deg, var(--card-2), var(--bg-2));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
@media (prefers-color-scheme: dark) {
  .rt-time {
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
  }
  .rt-finished .rt-time {
    -webkit-text-fill-color: var(--accent-2);
  }
}

/* [community] Flagship: make the "Verified by data" receipt a premium, trustworthy artifact */
/* app/css/style.css — override the existing .soc-receipt / .soc-verified / .soc-receipt-metric rules (~L1633-1652) */
.soc-receipt {
  padding: var(--sp-3) var(--sp-4);
  box-shadow: var(--e1), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
/* color-mix() needs WebKit 16.2+; on iOS 15-16.1 the var()-laden shorthand
   would compute to `unset` (transparent card) — keep the base background there */
@supports (background: color-mix(in srgb, red 50%, blue)) {
  .soc-receipt {
    background:
      linear-gradient(180deg,
        color-mix(in srgb, var(--g1) 7%, var(--card-2)),
        var(--card-2) 62%) padding-box,
      var(--grad) border-box;
  }
  /* verified-only: extra brand glow so it clearly outranks a plain "Receipt" block */
  .soc-receipt:has(.soc-verified) {
    box-shadow:
      var(--e2),
      0 0 0 1px color-mix(in srgb, var(--g2) 22%, transparent),
      inset 0 1px 0 rgba(255, 255, 255, 0.06);
  }
}
/* the checkmark becomes a real, recognizable verified pill */
.soc-verified {
  padding: 3px 9px 3px 7px;
  border-radius: var(--r-full);
  background: var(--accent-2-soft);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-2) 32%, transparent);
}
/* the hero number earns more presence */
.soc-receipt-metric { font-size: 1.5rem; line-height: 1.15; margin: 2px 0; }

/* [community] Avatar "coin" treatment — glossy monogram + soft lift, everywhere at once */
/* app/css/style.css — augment the existing avatar rules (~L1530-1542) */
.soc-ava { box-shadow: var(--e1); }
.soc-ava-txt {
  box-shadow:
    var(--e1),
    inset 0 1px 1px rgba(255, 255, 255, 0.22),
    inset 0 -2px 3px rgba(2, 6, 16, 0.18);
}
.soc-ava-lg { box-shadow: var(--e2); }

/* [community] Make receipt data-viz emit brand light (7-day streak cells + sparkline glow) */
/* app/css/style.css — augment .rc-day / .rc-spark (~L1655-1662) */
.rc-day { box-shadow: inset 0 1px 2px rgba(2, 6, 16, 0.22); }
.rc-day.on {
  box-shadow:
    0 1px 6px color-mix(in srgb, var(--g2) 40%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.rc-spark {
  filter: drop-shadow(0 1px 4px color-mix(in srgb, var(--accent-2) 45%, transparent));
}

/* ---------- Premium paywall (AI features) ---------- */
.ent-paywall { text-align: left; }
.ent-badge {
  display: inline-flex; align-items: center; gap: 5px;
  align-self: flex-start;
  padding: 4px 11px; margin-bottom: var(--sp-2);
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase;
  color: #fff; border-radius: var(--r-full);
  background: var(--grad);
  box-shadow: var(--e1), 0 4px 12px color-mix(in srgb, var(--g1) 40%, transparent);
}
.ent-paywall h2 { margin: 0 0 6px; }
.ent-paywall .form-actions { margin-top: var(--sp-3); }
