/* ShapeUp — app shell CSS: chrome used by every route (root tokens, sidebar,
 * header, profile menu, .xl-main scroll body, tab bar). Split out of
 * exercise.css so future routes (Body Stats, Calories) can reuse the shell
 * without pulling in Log-tab-specific styles. Load before ui.css/exercise.css. */

/* ShapeUp — Exercise Log SPA styles (first pass: Log tab).
 * Blue ShapeUp theme, mobile-first. iOS Safari: inputs are >=16px to avoid
 * focus zoom; the true scroll container is .xl-main, not window. */

@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/static/fonts/montserrat-variable.woff2') format('woff2-variations');
}

/* Kill Chrome/Android pull-to-refresh on the document-scrolling routes
   (/settings/*, auth pages). .xl-main has its own containment (below); this
   covers everything that isn't inside it. html.sheet-open's stricter
   `overscroll-behavior: none` (ui.css) still wins while a sheet is open. */
html {
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
  /* No text selection and no long-press callout anywhere in the app (user's
     ask). This is also what stops iOS running its selection gesture — and
     firing its own selection haptic — during the reorder long-press: the bare
     `user-select: none` on .xl-card-head was never enough on WebKit, which
     needs the -webkit- prefix AND -webkit-touch-callout. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
/* Typing surfaces opt back in — without this the caret and in-field selection
   break in Safari. Do not remove. */
input,
textarea,
[contenteditable] {
  -webkit-user-select: text;
  user-select: text;
}

:root {
  --blue: #2563C9;
  --blue-dark: #1e4fa3;
  --blue-deep: #0d47a1;
  --blue-fill: #2563C9;
  --blue-fill-hover: #1e4fa3;
  --blue-light: #e6f1fb;
  --error: #dc2626;
  --error-light: #fef2f2;
  --ok: #16a34a;
  --green-light: #e8f5e9;
  --green-dark: #2e7d32;
  --ink: #0f172a;
  --slate: #475569;
  --muted: #94a3b8;
  --border: #D5D9E0;
  --bg: #f4f6f8;
  --canvas: #FAFAF9;    /* app screen background — warm near-white so white cards separate */
  --white: #ffffff;
  --tab-pill: #ffffff;   /* active tab-bar pill fill (own token so it can differ from --white) */
  --tab-track: #EFF0F3;  /* tab-bar track base — glass translucency applied on top */
  --split-selected: var(--blue);

  /* type scale — base-anchored t-shirt sizes; see docs/type-tokens-plan.md */
  --fs-3xs: 9px;
  --fs-2xs: 10px;
  --fs-xs: 11px;
  --fs-base: 12px;
  --fs-md: 13px;
  --fs-lg: 14px;
  --fs-xl: 16px;
  --fs-2xl: 18px;
  --fs-3xl: 22px;
  --fs-4xl: 26px;
  --fs-display: 32px;

  /* standard control height — buttons (.sa-btn-primary), form inputs/selects */
  --control-h: 34px;

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --fw-extrabold: 800;

  --radius: 6px;
  --font: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* motion — panel reveal (new-features/panel-reveal-animation/): a short lift
     + fade + cross-blur on an expo-out curve, so a travel much shorter than the
     panel's height still reads as a full open. Enter is slower than exit (the
     user is watching the entrance; the exit should get out of the way). */
  --panel-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --panel-open-dur: 400ms;
  --panel-close-dur: 350ms;
  --panel-travel: 48px;
  --panel-blur: 2px;
  --on-accent: #ffffff;

  --amber-light: #fdf3df;
  --amber-dark: #ba7517;
  --split-pull: #7b3fbf;
  --split-push: #c0392b;
  --split-upper: #1e6091;
  --split-leg: #2e7d32;
  --split-full-body: #37474f;
  --split-cardio: #00897b;
  --split-default: var(--blue);
  --line-0: #2563C9;
  --line-1: #c0392b;
  --line-2: #2e7d32;
  --line-3: #7b3fbf;
  --line-4: #8A6D0E;
  --line-5: #1e6091;

  --gauge-lean: #a9c9f0;
  --gauge-muscle: #5a8fda;
  --gauge-fat: var(--blue);

  --scrim: rgba(15, 23, 42, 0.58);

  --shadow-l1:      0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-l2:      0 1px 2px rgba(15, 23, 42, 0.04),
                    0 4px 10px rgba(15, 23, 42, 0.05),
                    0 12px 28px rgba(15, 23, 42, 0.07);
  --shadow-l3:      0 6px 20px rgba(15, 23, 42, 0.18);
  --shadow-l3-pill: 0 8px 18px -8px rgba(15, 23, 42, 0.25);
  --shadow-l4:      0 8px 24px rgba(15, 23, 42, 0.12);
  --shadow-l4-menu: 0 16px 40px -8px rgba(20, 24, 40, 0.28),
                    0 2px 8px rgba(20, 24, 40, 0.08);
  --shadow-l5:      0 24px 60px rgba(15, 23, 42, 0.28);
  --shadow-l5-deep: 0 12px 40px rgba(15, 23, 42, 0.28);
}

:root[data-theme="dark"] {
  --canvas: #1c1b19;
  --white: #2a2825;
  --bg: #35322e;
  --tab-track: #232220;
  --tab-pill: #3a3833;
  --ink: #f5f3ee;
  --slate: #a8a399;
  --muted: #8f8a80;
  --border: #45423c;
  --blue: #5b8ee8;
  --blue-dark: #7ba9ee;
  --blue-deep: #9cc0f5;
  --blue-fill: #3b73d4;
  --blue-fill-hover: #2f6fd6;
  --blue-light: #37332c;
  --error: #EF4444;
  --error-light: #3e2a27;
  --ok: #22C55E;
  --green-light: #293b2c;
  --green-dark: #6EE7A0;
  --on-accent: #ffffff;

  --shadow-l1:      0 1px 3px rgba(0,0,0,.40);
  --shadow-l2:      0 1px 2px rgba(0,0,0,.35), 0 4px 10px rgba(0,0,0,.40), 0 12px 28px rgba(0,0,0,.45);
  --shadow-l3:      0 6px 20px rgba(0,0,0,.55);
  --shadow-l3-pill: 0 8px 18px -8px rgba(0,0,0,.60);
  --shadow-l4:      0 8px 24px rgba(0,0,0,.50);
  --shadow-l4-menu: 0 16px 40px -8px rgba(0,0,0,.65), 0 2px 8px rgba(0,0,0,.40);
  --shadow-l5:      0 24px 60px rgba(0,0,0,.65);
  --shadow-l5-deep: 0 12px 40px rgba(0,0,0,.65);

  --amber-light: #3a2e1c;
  --amber-dark: #F5B041;
  --split-pull: #a871e6;
  --split-push: #ef4444;
  --split-upper: #5097cd;
  --split-leg: #6ee7a0;
  --split-full-body: #8ca3b3;
  --split-cardio: #26c6da;
  --split-default: var(--blue);
  --line-0: #3b82f6;
  --line-1: #ef4444;
  --line-2: #6ee7a0;
  --line-3: #a871e6;
  --line-4: #f5b041;
  --line-5: #5097cd;

  --gauge-lean: #3a4a6b;
  --gauge-muscle: #5b8ee8;
  --gauge-fat: var(--blue-dark);

  --scrim: rgba(10, 9, 8, 0.66);
}

:root[data-theme="dark"] body {
  background: var(--canvas);
}

:root[data-theme="midnight"] {
  --canvas: #0B1220;
  --white: #161F30;
  --bg: #202B40;
  --tab-track: #161F31;
  --tab-pill: #28334A;
  --ink: #E6EDF7;
  --slate: #A9B6C9;
  --muted: #8494AB;
  --border: #2A3651;
  --blue: #3B82F6;
  --blue-dark: #60A5FA;
  --blue-deep: #93C5FD;
  --blue-fill: #3B82F6;
  --blue-fill-hover: #60A5FA;
  --blue-light: #16233B;
  --error: #EF4444;
  --error-light: #2A1518;
  --ok: #22C55E;
  --green-light: #122A1E;
  --green-dark: #6EE7A0;
  --on-accent: #ffffff;

  --shadow-l1:      0 1px 3px rgba(0,0,0,.40);
  --shadow-l2:      0 1px 2px rgba(0,0,0,.35), 0 4px 10px rgba(0,0,0,.40), 0 12px 28px rgba(0,0,0,.45);
  --shadow-l3:      0 6px 20px rgba(0,0,0,.55);
  --shadow-l3-pill: 0 8px 18px -8px rgba(0,0,0,.60);
  --shadow-l4:      0 8px 24px rgba(0,0,0,.50);
  --shadow-l4-menu: 0 16px 40px -8px rgba(0,0,0,.65), 0 2px 8px rgba(0,0,0,.40);
  --shadow-l5:      0 24px 60px rgba(0,0,0,.65);
  --shadow-l5-deep: 0 12px 40px rgba(0,0,0,.65);

  /* amber/split/line/gauge: same derivation approach as Charcoal's block —
     copy Charcoal's values verbatim as a starting point (both are dark
     surfaces, categorical colors are temperature-independent per
     palette-swap-plan.md Step 1's own note), adjust only if the Phase-0
     preview shows a clash against the cooler canvas. */
  --amber-light: #3a2e1c;
  --amber-dark: #F5B041;
  --split-pull: #a871e6;
  --split-push: #ef4444;
  --split-upper: #5097cd;
  --split-leg: #6ee7a0;
  --split-full-body: #8ca3b3;
  --split-cardio: #26c6da;
  --split-default: var(--blue);
  --line-0: #3b82f6;
  --line-1: #ef4444;
  --line-2: #6ee7a0;
  --line-3: #a871e6;
  --line-4: #f5b041;
  --line-5: #5097cd;

  --gauge-lean: #a9c9f0;
  --gauge-muscle: #5a8fda;
  --gauge-fat: var(--blue-dark);

  --scrim: rgba(4, 8, 16, 0.66);
}

:root[data-theme="midnight"] body {
  background: var(--canvas);
}

/* SearchInput uses a transparent border so its light/charcoal track stays
   soft. Midnight's cooler track needs a quiet outline to remain visible
   against the near-black canvas; focus-within still promotes it to blue. */
:root[data-theme="midnight"] .search-input-shell {
  border-color: var(--border);
}

:root[data-theme="midnight"] .search-input-shell:focus-within {
  border-color: var(--blue);
}

/* The bare-element reset (* box-sizing/margin/padding, html/body height,
   body font/color/bg) now lives in frontend/react/src/index.css's
   @layer base — moved there in the Tailwind migration's Phase 0 so it can't
   defeat margin/padding utilities (unlayered CSS always beats @layer-ed CSS). */

/* ───────── swapping label (TextSwap.tsx) ─────────
 * Crossfade + blur + scale between two labels, e.g. Select All / Clear All.
 * Source: new-features/text-swap-animation/. Both labels share one grid cell,
 * so the control's width is the LONGER label's and nothing reflows mid-swap.
 * Scale is 0.92, not the reference's 0.25 — a word shrinking to a quarter
 * reads as a glitch, where an icon reads as a pop. */
.sa-swap { display: inline-grid; }
.sa-swap-item {
  grid-area: 1 / 1;
  transition: opacity 0.25s ease-in-out, filter 0.25s ease-in-out, transform 0.25s ease-in-out;
}
.sa-swap[data-state="a"] [data-swap="a"],
.sa-swap[data-state="b"] [data-swap="b"] {
  opacity: 1;
  filter: blur(0);
  transform: scale(1);
}
.sa-swap[data-state="a"] [data-swap="b"],
.sa-swap[data-state="b"] [data-swap="a"] {
  opacity: 0;
  filter: blur(2px);
  transform: scale(0.92);
}
/* Reduced motion: keep the crossfade (it explains the label changed), drop
   the movement and the blur. */
@media (prefers-reduced-motion: reduce) {
  .sa-swap-item { transition-property: opacity; }
}

/* ───────── shared selectable chip/pill ─────────
 * App-wide component (used across Exercise/Progress/Body Stats/Food, hence
 * "sa-" not "xl-" — same convention as .sa-search/.sa-toast). One canonical
 * recipe: 999px pill, fs-2xs/semibold, light-tint selected state (blue-light
 * bg + blue border/text). Feature files keep their own class name alongside
 * this one for JS/TSX hooks (e.g. class="sa-chip xlp-pill") and layer only
 * genuine per-instance differences (flex/scroll behavior) on top — never
 * radius/padding/font-size/selected-color, which all belong here. */
.sa-chip {
  --accent: var(--blue);
  font-family: var(--font);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--white);
  color: var(--slate);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.sa-chip:focus { outline: none; }
@media (hover: hover) {
  .sa-chip:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
}
.sa-chip:disabled { opacity: .35; cursor: not-allowed; }
.sa-chip.selected,
.sa-chip.active,
.sa-chip.on {
  background: var(--blue-light);
  border-color: var(--accent);
  color: var(--accent);
}
.sa-chip.empty { opacity: 0.45; }

/* Dark themes: a selected chip/toggle reads white-on-tint, not blue-on-tint —
   the dark --blue (#5b8ee8 / #3B82F6) doesn't carry enough contrast against
   the tinted --blue-light fill. Fill is unchanged; only ink + border. */
:root[data-theme="dark"] .sa-chip,
:root[data-theme="midnight"] .sa-chip { --accent: var(--ink); }

/* Once selected went white-on-tint above, the default --slate unselected
   text (a mid-gray, same token used app-wide for body copy) sat too close
   in brightness to that white — barely distinguishable at a glance. Dim the
   UNSELECTED chip text further, scoped to chips only, so the two states
   read clearly apart on dark. Selected/hover (--accent) untouched. */
:root[data-theme="dark"] .sa-chip:not(.selected):not(.active):not(.on) { color: #6b665c; }
:root[data-theme="midnight"] .sa-chip:not(.selected):not(.active):not(.on) { color: #5c6b85; }

:root[data-theme="dark"] .sa-btn-toggle.active,
:root[data-theme="midnight"] .sa-btn-toggle.active { color: var(--ink); }

/* Selected fill: in dark themes the selected state kept --blue-light, a
   near-match of the unselected --white fill (warm-on-warm). Use the
   disabled-input fill (--bg) instead — a clear step up from --white — while
   the ink border/text from the rules above carries the state. Light themes
   untouched. */
:root[data-theme="dark"] .sa-chip.selected,
:root[data-theme="dark"] .sa-chip.active,
:root[data-theme="dark"] .sa-chip.on,
:root[data-theme="dark"] .sa-btn-toggle.active,
:root[data-theme="midnight"] .sa-chip.selected,
:root[data-theme="midnight"] .sa-chip.active,
:root[data-theme="midnight"] .sa-chip.on,
:root[data-theme="midnight"] .sa-btn-toggle.active {
  background: var(--bg);
}

/* ───────── shared Button component (components/Button.tsx) ─────────
 * docs/shareable-button-component-plan.md. One class family for every button
 * style in the app — each sa-btn-* variant is a verbatim port of a CSS recipe
 * that used to be copy-pasted per call site (exercise.css/ui.css). Variant
 * numbers below match the plan's 8-variant survey. */
/* Shared control-height recipe for text/number/date/select fields — same
 * --control-h (34px) as .sa-btn-primary, so buttons and inputs/selects
 * align. Apply alongside each field's own visual classes (.xl-form input,
 * .cp-input, .xl-select, etc.) rather than replacing them. */
.xl-field-h {
  height: var(--control-h);
  box-sizing: border-box;
  padding-top: 0;
  padding-bottom: 0;
}

.sa-btn {
  font-family: var(--font);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  border: none;
  text-decoration: none; /* .sa-btn also renders as <a> (e.g. Link) — anchors default to underline */
}
.sa-btn:disabled { cursor: not-allowed; }
.sa-btn-full { width: 100%; }
.sa-btn-flex1 { flex: 1; } /* fills remaining space in a flex row (e.g. Save beside a fixed-width icon button) */

/* Variant 1 — primary filled pill, large/CTA (.xl-hero-finish/.xl-manual-start/.xl-sheet-save) */
.sa-btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  height: 34px;
  padding: 0 15px;
  border-radius: 999px;
  font-size: var(--fs-md);
  background: var(--blue-fill); color: var(--on-accent);
  transition: background 0.15s;
}
.sa-btn-primary:hover:not(:disabled) { background: var(--blue-fill-hover); }
.sa-btn-primary:disabled { background: var(--border); color: var(--on-accent); }
/* Large/CTA sizing (.xl-manual-start/.xl-sheet-save): full-width, taller, shadowed */
.sa-btn-primary.sa-btn-lg {
  height: 46px;
  font-size: var(--fs-lg); font-weight: var(--fw-bold);
  box-shadow: var(--shadow-l3);
}
.sa-btn-primary.sa-btn-lg:disabled { background: var(--border); box-shadow: none; }

/* Variant 3 — secondary/outline pill: blue border, transparent fill, blue text (.xl-nosession-secondary) */
.sa-btn-secondary {
  display: inline-flex; align-items: center; justify-content: center;
  height: 34px;
  padding: 0 15px;
  border: 1px solid var(--blue);
  border-radius: 999px;
  font-size: var(--fs-md);
  background: transparent; color: var(--blue);
  transition: all 0.15s;
}
.sa-btn-secondary:hover:not(:disabled) { background: var(--blue-light); }
.sa-btn-secondary:disabled { border-color: var(--border); background: var(--border); color: var(--muted); }

/* Variant 2 — primary/ghost paired buttons in a 2-col .xl-form-actions grid (.xl-btn) */
.sa-btn-primary-pair,
.sa-btn-ghost-pair {
  font-size: var(--fs-base);
  padding: 12px 8px;
  border-radius: 999px;
  transition: all 0.2s ease;
}
.sa-btn-primary-pair { background: var(--blue-fill); color: #fff; }
.sa-btn-primary-pair:hover:not(:disabled) { background: var(--blue-fill-hover); }
.sa-btn-primary-pair:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; opacity: 0.6; }
.sa-btn-ghost-pair { background: var(--blue-light); color: var(--blue); }
.sa-btn-ghost-pair:hover:not(:disabled) { background: var(--blue-light); filter: brightness(0.97); }

/* Variant 4 — ghost/text-link (.xl-program-meta-add/.xl-manual-back/.plan-change) */
.sa-btn-ghost {
  display: inline-flex; align-items: center; gap: 4px;
  background: none;
  padding: 0;
  font-size: var(--fs-md);
  color: var(--blue);
}
.sa-btn-ghost:hover:not(:disabled) { color: var(--blue-dark); }
.sa-btn-ghost svg { width: 15px; height: 15px; }
.sa-btn-ghost.sa-btn-full { justify-content: center; }

/* Variant 5 — secondary block/full-width outline (.cp-btn-secondary) */
.sa-btn-secondary-block {
  display: block;
  width: 100%;
  height: 38px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: var(--fs-base);
  color: var(--slate);
}
.sa-btn-secondary-block:active { background: var(--bg); }
.sa-btn-secondary-block:disabled { opacity: 0.5; cursor: not-allowed; }

/* Variant 6 — icon-only square (.xl-setup-collapse/.cp-ex-del/.cp-mini-btn/.xl-sheet-clear) */
.sa-btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  background: none;
  border-radius: 999px;
  color: var(--muted);
}
.sa-btn-icon svg { width: 16px; height: 16px; }
.sa-btn-icon:active { background: rgba(15,23,42,0.06); }
/* Boxed sizing (.cp-ex-del/.xl-sheet-clear): bordered square/circle, larger glyph */
.sa-btn-icon.sa-btn-lg {
  width: 46px; height: 46px;
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: 999px;
  color: var(--slate);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.sa-btn-icon.sa-btn-lg svg { width: 21px; height: 21px; stroke: currentColor; }
.sa-btn-icon.sa-btn-lg:active { background: var(--bg); }
.sa-btn-icon.sa-btn-lg:hover:not(:disabled) { color: var(--blue); border-color: var(--blue); }
.sa-btn-icon.sa-btn-lg:disabled { opacity: 0.4; cursor: not-allowed; }
.sa-btn-icon.sa-btn-lg:disabled:hover { color: var(--slate); border-color: var(--border); }

/* Variant 7 — segmented/pill toggle group member (.xl-ref-btn) */
.sa-btn-toggle {
  padding: 6px 11px;
  border-radius: 12px;
  background: transparent; color: var(--slate);
  font-size: var(--fs-2xs);
  transition: all 0.15s;
}
.sa-btn-toggle.active { background: var(--blue-light); color: var(--blue); }
.sa-btn-toggle:disabled { color: var(--muted); opacity: 0.45; cursor: not-allowed; }
.sa-btn-toggle:disabled.active { background: transparent; color: var(--muted); }

/* Variant 8 — modal action pair (.sa-btn-modal-primary/.sa-btn-modal-ghost) */
.sa-btn-modal-primary,
.sa-btn-modal-ghost {
  flex: 1;
  font-size: var(--fs-base);
  padding: 12px 14px;
  border-radius: 999px;
}
.sa-btn-modal-primary { background: var(--blue-fill); color: #fff; }
.sa-btn-modal-primary:hover:not(:disabled) { background: var(--blue-fill-hover); }
.sa-btn-modal-primary:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; }
.sa-btn-modal-ghost { background: var(--bg); color: var(--slate); }
.sa-btn-modal-ghost:hover:not(:disabled) { background: var(--border); }

.xl-app {
  --tabbar-h: 44px;   /* .xl-tabbtn 34px + .xl-tabbar padding 5px ×2 */
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  background: var(--canvas);
  box-shadow: 0 0 40px rgba(15, 23, 42, 0.05);
}

/* ───────── burger + sidebar ───────── */

.xl-sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
}

.xl-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 220px;
  background: var(--white);
  box-shadow: 4px 0 24px rgba(15,23,42,.12);
  z-index: 210;
  transform: translateX(-100%);
  transition: transform .22s ease;
  display: flex;
  flex-direction: column;
  padding: 16px 8px;
}
.xl-sidebar.open { transform: translateX(0); }

.xl-sidebar-logo {
  padding: 8px 12px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.xl-sidebar-logo img {
  width: 120px;
  height: auto;
  display: block;
}

.xl-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.xl-sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--slate);
  text-decoration: none;
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  transition: background .12s, color .12s;
}
.xl-sidebar-item:hover {
  background: var(--bg);
  color: var(--ink);
}
.xl-sidebar-item.active {
  background: var(--blue-light);
  color: var(--blue);
}
.xl-sidebar-item.disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
.xl-sidebar-item.disabled:hover {
  background: none;
  color: var(--slate);
}

.xl-sidebar-icon {
  width: 20px;
  height: 20px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.xl-sidebar-icon svg { width: 18px; height: 18px; display: block; }
.xl-sidebar-svg-icon {
  width: 20px;
  height: 20px;
  display: block;
  object-fit: contain;
  /* pre-colored slate/blue/ink SVG files are picked by active state in Sidebar.tsx */
}
/* Inactive items stack base(slate) + hover(ink) and crossfade opacity on hover */
.xl-sidebar-svg-icon-base,
.xl-sidebar-svg-icon-hover {
  position: absolute;
  inset: 0;
  transition: opacity 0.12s ease;
}
.xl-sidebar-svg-icon-hover { opacity: 0; }
.xl-sidebar-item:hover .xl-sidebar-svg-icon-base { opacity: 0; }
.xl-sidebar-item:hover .xl-sidebar-svg-icon-hover { opacity: 1; }

/* ───────── header (white bar, centered logo — per mockup) ───────── */

.xl-header {
  position: relative;            /* anchor for the absolutely-centered brand */
  z-index: 4;                    /* paint above .xl-tabbar (z-index:3) so the auto-hiding bar tucks under it */
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  color: var(--ink);
}

/* Left cluster: burger. */
.xl-header-left {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Right cluster: per-page action (e.g. help icon) + profile. */
.xl-header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Hamburger — plain dark icon button (was the white wordmark). */
.xl-burger {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s;
}
.xl-burger:hover { background: var(--bg); }
.xl-burger-icon {
  width: 22px;
  height: 22px;
  display: block;
}

/* Centered brand — absolutely positioned so the logo stays dead-center
   regardless of what sits in the left/right clusters. */
.xl-brand {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  text-decoration: none;
}
.xl-header .xl-logo { height: 22px; width: auto; display: block; }

/* Logo-only header (AccessExpiredPage) — no burger/avatar, so the row's only
   content is the 22px logo instead of the 42px burger/profile circles. Pin the
   CONTENT height to 42px (matching .xl-burger/.xl-profile-avatar) so the bar's
   total height matches the normal header exactly. min-height alone is
   border-box here, so it measured 42px total vs the real header's 67px —
   ::before is a zero-width 42px strut instead. */
.xl-header-logo-only::before {
  content: '';
  display: block;
  width: 0;
  height: 42px;
}

/* ───────── top-level nav ───────── */

.xl-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
.xl-nav-item {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  color: var(--slate);
  text-decoration: none;
  transition: background .12s, color .12s;
}
.xl-nav-item:hover { background: var(--bg); color: var(--ink); }
.xl-nav-item.active { background: var(--blue-light); color: var(--blue); }

/* ───────── profile menu ───────── */

/* text-decoration: it's a <Link> (an <a>) now, not the old <button> — without
   this the browser underlines the avatar initial. */
.xl-profile { position: relative; text-decoration: none; }

.xl-profile-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 999px;
  font-family: inherit;
}
.xl-profile-name {
  color: var(--slate);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
}
.xl-profile-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--blue-light);
  color: var(--blue);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

/* ───────── scroll body ───────── */

.xl-main {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain; /* don't chain to the document / no PTR */
  /* Top spacing comes from the .has-tabbar overlay rule below. */
  padding: 0 18px 32px;
}
/* Overlay mode: the pill bar floats over the scroller. Pull the scrollport up
   underneath the bar (its flow footprint = 6px margin-top + --tabbar-h) and
   re-add the same amount as padding-top plus a 12px resting gap. The padding
   scrolls away with content — content slides UNDER the glass pill. Gated on
   .has-tabbar because some routes (e.g. Calories) render no bar. */
.xl-app.has-tabbar .xl-main {
  margin-top: calc(-1 * (var(--tabbar-h) + 6px));
  padding-top: calc(var(--tabbar-h) + 6px + 12px);
}
/* Reserve room for the fixed bottom rest-timer pill — ONLY while a rest is
   actually running (.xl-app.rest-on, toggled by RestTimerBar.tsx), since the
   pill no longer has an idle/collapsed state to always reserve space for.
   Mirrors the pill's own footprint (~50px tall + 16px bottom gap + slack). */
.xl-app.rest-on .xl-main {
  padding-bottom: calc(82px + env(safe-area-inset-bottom, 0px));
}

/* ───────── tab bar (grey pill track, text labels — per redesign) ───────── */

/* A rounded grey track holding content-width, text-label tabs. The active tab
   is a white pill (soft shadow, ink text); inactive tabs are plain muted text.
   Tabs hug their label width and center within the track. */
.xl-tabbar {
  position: relative;
  z-index: 3;                    /* above in-tab sticky headers (z-index 2) */
  flex: 0 0 auto;
  align-self: center;            /* shrink to content width, don't stretch full-width */
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 2px;
  max-width: calc(100% - 32px);  /* never overflow the frame; keep the old 16px side gap as breathing room */
  /* Glass: translucent track + backdrop blur — content blurs through as it
     scrolls underneath. Safe to have the blur back HERE because the side-panel
     pseudos below are plain gradients (no backdrop-filter of their own to
     isolate). Base color from the --tab-track token; solid fallback first for
     browsers without rgb(from). */
  background: var(--tab-track);
  background: rgb(from var(--tab-track) r g b / 0.72);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  backdrop-filter: blur(14px) saturate(1.15);
  border-radius: 999px;
  padding: 5px;
  margin: 6px 0 0;
  height: var(--tabbar-h);       /* keep in sync with the .xl-app token */
  box-sizing: border-box;
  transition:
    transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.2s ease;
}

/* Invisible full-width hit shield across the bar's airspace: taps in the
   transparent zones beside/above the pill land here (i.e. nowhere) instead of
   on content sliding under the bar. z:-1 keeps it under the pill's buttons.
   Purely hit-testing — the airspace is deliberately left VISUALLY transparent
   (user's call 2026-07-18: every scrim/band/panel treatment read as a fill or
   cropped the pill; content showing raw beside the rounded glass pill is the
   accepted design). ⚠️ If a visual treatment is ever revisited, mind the two
   gotchas in docs/tabbar-scroll-guidelines.md §6: bar pseudos can't hide
   behind the track's fill (stacking-context paint order) and can't carry
   backdrop-filter (the bar's own backdrop-filter isolates them). */
.xl-tabbar::after {
  content: '';
  position: absolute;
  z-index: -1;
  top: -6px;
  bottom: 0;
  left: 50%;
  width: min(100vw, 640px);
  transform: translateX(-50%);
}

/* Auto-hide (headroom): pure transform/fade — the bar occupies no exclusive
   layout space in overlay mode, so hiding it must not (and does not) reflow
   .xl-main. Driven by useHideOnScroll via AppShell. */
.xl-tabbar.hidden {
  transform: translateY(calc(-100% - 6px));  /* clear the 6px margin-top too */
  opacity: 0;
  pointer-events: none;
}

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

.xl-tabbtn {
  position: relative;
  height: 34px;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--slate);
  cursor: pointer;
  font-family: var(--font);
  /* Only transform/opacity/background/color transition — no `all`. */
  transition: background-color 0.2s ease, color 0.2s ease,
              box-shadow 0.2s ease, transform 0.16s cubic-bezier(0.23, 1, 0.32, 1);
  -webkit-appearance: none;
  appearance: none;
}
.xl-tabbtn:focus { outline: none; }
/* Press feedback — subtle scale, snaps back fast (design-eng principle). */
.xl-tabbtn:active { transform: scale(0.97); }

/* Active tab → white pill, blue text (matches Body Stats' active tab). */
.xl-tabbtn.active {
  background: var(--tab-pill);
  color: var(--blue);
  box-shadow: var(--shadow-l1);
}

/* Text labels are the tab content now — icons hidden (kept in markup for the
   `src` swap logic; not shown). */
.xl-tabbtn img { display: none; }
.xl-tabbtn-label {
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  line-height: 1;

  white-space: nowrap;
}
.xl-tabbtn.active .xl-tabbtn-label { font-weight: var(--fw-semibold); }

.xl-panel { display: none; }
.xl-panel.active { display: block; }
