/* VitaFit components — docs/components.md. FROZEN after phase A.
   Class names follow components.md exactly. Components never set their own outer margin. */

/* =====================================================================
   0. Shared patterns
   ===================================================================== */
.card {
  background: var(--bg-surface);
  border-radius: var(--r-card);
  padding: var(--card-pad);
  display: flex; flex-direction: column; gap: 16px;
  min-width: 0;
}
.card--bordered { border: 1px solid var(--border); }
.panel {
  background: var(--bg-sunken);
  border-radius: var(--r-16);
  padding: 4px;
  display: flex; flex-direction: column; gap: 4px;
}
.panel--neutral { background: var(--bg-neutral); }
.panel__item { background: var(--bg-surface); border-radius: var(--r-12); }
.dot-sep { width: 4px; height: 4px; border-radius: 50%; background: var(--c-gray-soft); flex: none; }
.dot-sep--light { background: var(--c-gray-light); }
.dot-sep--sm { width: 2px; height: 2px; }

.chip {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  border-radius: var(--r-pill); width: 32px; height: 32px; padding: 8px;
}
.chip--lime { background: var(--c-lime-muted); color: var(--c-lime-ink); box-shadow: var(--fx-chip-muted); }
.chip--pale { background: var(--c-lime-pale); color: var(--c-lime-ink); box-shadow: var(--fx-chip-light); }
.chip--dark { background: var(--c-lime-deep); color: #FFFFFF; box-shadow: var(--fx-chip-dark); }
.chip--flat { box-shadow: none; }
.chip--16 { width: 16px; height: 16px; padding: 2px; }
.chip--20 { width: 20px; height: 20px; padding: 4px; }
.chip--22 { width: 22px; height: 22px; padding: 6px; }
.chip--24 { width: 24px; height: 24px; padding: 6px; }
.chip--32 { width: 32px; height: 32px; padding: 8px; }
.chip--40 { width: 40px; height: 40px; padding: 8px; }
.chip--48 { width: 48px; height: 48px; padding: 12px; }

.chip-fire {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  border-radius: var(--r-pill); background: var(--grad-brand); box-shadow: var(--fx-chip-dark); color: #FFFFFF;
  width: 24px; height: 24px; padding: 4px;
}
.chip-fire--deep { background: var(--grad-deep); }
.chip-fire--30 { width: 30px; height: 30px; padding: 6px; }
.chip-fire--24 { width: 24px; height: 24px; padding: 4px; }
.chip-fire--20 { width: 20px; height: 20px; padding: 4px; }
.chip-fire--18 { width: 18px; height: 18px; padding: 4px; }
.chip-fire--16 { width: 16px; height: 16px; padding: 2px; }

.tile-soft {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 48px; height: 48px; border-radius: var(--r-8);
  background: var(--grad-soft); box-shadow: var(--fx-chip-light); color: var(--c-lime-ink);
}
.tile-soft--40 { width: 40px; height: 40px; }
.tile-soft--36 { width: 36px; height: 36px; border-radius: var(--r-4); background: linear-gradient(180deg, #E7E9DF, #F2F2F2); }

.vu { display: inline-flex; align-items: baseline; gap: 2px; white-space: nowrap; }
.vu--4 { gap: 4px; }
.vu__num { color: var(--text); }
.vu__unit { color: var(--text-muted); }

.seg-stats {
  display: flex; align-items: center; gap: 2px; padding: 2px;
  background: var(--bg-neutral); border-radius: var(--r-24);
}
.seg-stats > * { background: var(--bg-surface); border-radius: var(--r-24); }

.level { display: inline-flex; gap: 2px; align-items: center; }
.level > i { display: block; width: 4px; height: 10px; border-radius: var(--r-8); background: var(--c-lime-pale); }
.level > i.is-on { background: var(--c-lime-deep); }

/* Cut-out food photos were flattened to white JPEGs. On tinted backgrounds use multiply
   so the white disappears (decision, see assets/img/INDEX.md). */
.img-cutout { mix-blend-mode: multiply; }
.img-cover { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-round { border-radius: 50%; object-fit: cover; }

/* Skeleton (product-spec §7 Loading) and empty state */
.skel { background: var(--bg-neutral); border-radius: var(--r-8); min-height: 12px; animation: vf-pulse 1.2s ease-in-out infinite; }
@keyframes vf-pulse { 50% { opacity: .55; } }
.empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: var(--fs-body2); line-height: var(--lh-body2); }
.spin { animation: vf-spin .9s linear infinite; }
@keyframes vf-spin { to { transform: rotate(360deg); } }

/* =====================================================================
   1. App shell
   ===================================================================== */
.app {
  display: flex; gap: var(--gap-layout); padding: var(--page-pad);
  min-height: 100vh; align-items: flex-start;
}
.app__main { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: var(--gap-layout); min-height: calc(100vh - 24px); }
.app__content { flex: 1 0 auto; display: flex; flex-direction: column; gap: var(--gap-layout); min-width: 0; }
.app--bare { display: block; padding: 0; }
.app--bare .app__main { min-height: 100vh; gap: 0; }

.sidebar { display: none; }
@media (min-width: 1280px) { .sidebar--desktop { display: flex; } }
@media (min-width: 768px) and (max-width: 1279.98px) { .sidebar--tablet { display: flex; } }
@media (max-width: 767.98px) {
  .app { flex-direction: column; align-items: stretch; }
  .app__main { min-height: calc(100vh - 24px); }
}

/* 1.2 Logo */
.logo { display: inline-flex; align-items: center; gap: 8px; color: var(--text); flex: none; }
.logo__mark { width: 24px; height: 28px; flex: none; }
.logo__word { font-size: 22px; line-height: 1.4; font-weight: 400; white-space: nowrap; }
.logo--symbol .logo__word { display: none; }
.logo--white { color: #FFFFFF; }
.logo--white .logo__leaf-low, .logo--white .logo__leaf-up { fill: #FFFFFF; }
.logo__leaf-low { fill: var(--c-lime-deep); }
.logo__leaf-up { fill: var(--c-lime-muted); }

/* 1.3 Button Nav */
.nav-item {
  display: flex; align-items: center; gap: 16px; width: 100%;
  height: 44px; padding: 12px 16px; border-radius: var(--r-24);
  color: var(--text-muted); transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav-item__content { display: flex; align-items: center; gap: 12px; flex: 1 1 0; min-width: 0; }
.nav-item__content > svg { color: var(--icon-muted); width: 20px; height: 20px; }
.nav-item__label { flex: 1 1 0; min-width: 0; font-size: var(--fs-body1); line-height: var(--lh-body1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: var(--c-gray-pale); color: var(--text); }
.nav-item.is-active { background: var(--primary); color: #FFFFFF; }
.nav-item.is-active .nav-item__content > svg { color: #FFFFFF; }
.nav-item.is-active .nav-item__label { font-weight: 500; }
.nav-item--logout { background: var(--c-gray-pale); flex: none; }
.nav-item--logout:hover { background: var(--c-gray-light); }
.nav-item__badge { margin-left: auto; }

.nav-item--icon { width: 40px; height: 40px; padding: 10px; border-radius: var(--r-pill); justify-content: center; gap: 0; }
.nav-item--icon .nav-item__content { flex: none; }
.nav-item--icon:hover { background: var(--c-gray-light); }
.nav-item--icon.is-active { background: var(--primary); }
.nav-item--icon.nav-item--logout { background: var(--c-gray-pale); }

.nav-group { display: flex; flex-direction: column; gap: 4px; }
.nav-group__sub { display: none; flex-direction: column; }
.nav-group.is-open .nav-group__sub { display: flex; }
.nav-item--sub {
  height: 40px; padding: 0 12px; gap: 4px; align-items: stretch; border-radius: 0; background: none;
}
.nav-item--sub:hover { background: none; }
.nav-item__line { width: 24px; flex: none; position: relative; }
.nav-item__line::before { content: ""; position: absolute; left: 11px; top: 0; bottom: 0; width: 2px; background: var(--c-gray-light); }
.nav-item--sub .nav-item__content {
  height: 36px; margin-top: 4px; padding: 8px 0 8px 16px; border-radius: var(--r-24); align-self: flex-start; width: 100%;
  transition: background var(--dur-fast) var(--ease);
}
.nav-item--sub:hover .nav-item__content { background: var(--c-gray-pale); color: var(--text); }
.nav-item--sub.is-active { background: none; }
.nav-item--sub.is-active .nav-item__line::before { background: var(--primary); }
.nav-item--sub.is-active .nav-item__content { background: var(--primary); color: #FFFFFF; padding: 8px 8px 8px 16px; margin-top: 0; margin-bottom: 4px; align-self: flex-end; }
.nav-item--sub.is-active .nav-item__label { font-weight: 400; }

/* 1.4 Sidebar */
.sidebar--desktop {
  width: var(--sidebar-w); flex: none; flex-direction: column; gap: 28px;
  background: var(--bg-surface); border-radius: var(--r-20); padding: 16px;
  /* F1 (E2-02; supersedes D1's min-height): components.md §1.1 — sticky box exactly calc(100vh - 24px) high, so
     the promo + "Log out" are always on screen. On short viewports the gaps compress (below) and, if still too
     tall (e.g. Meal Plan group open), the NAV scrolls inside the box; promo + Log out never move off-screen. */
  position: sticky; top: 12px; height: calc(100vh - 24px); overflow: visible;
}
.sidebar__logo { height: 40px; padding: 6px 16px; display: flex; align-items: center; flex: none; }
.sidebar__nav { display: flex; flex-direction: column; gap: 16px; flex: 1 0 auto; }
.sidebar--desktop .sidebar__nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: none; padding: 3px; margin: -3px; } /* pad: focus ring not clipped */
.sidebar--desktop .sidebar__nav::-webkit-scrollbar { display: none; }
@media (max-height: 1000px) {
  .sidebar--desktop { gap: 16px; }
  .sidebar--desktop .sidebar__nav { gap: 10px; }
  .sidebar--desktop .sidebar__bottom { gap: 16px; }
}
@media (max-height: 760px) {
  /* very short windows: drop the decorative promo so navigation keeps its room */
  .sidebar--desktop .promo { display: none; }
  .sidebar--desktop .sidebar__bottom { padding-top: 0; }
}
.sidebar__bottom { display: flex; flex-direction: column; gap: 28px; flex: none; padding-top: var(--promo-space); }

.sidebar--tablet {
  width: var(--sidebar-w-tablet); flex: none; flex-direction: column; align-items: center; gap: 24px;
  background: var(--bg-surface); border-radius: 240px; padding: 16px 12px 12px;
  position: sticky; top: 12px; height: calc(100vh - 24px); overflow-y: auto; scrollbar-width: none;
}
.sidebar--tablet .sidebar__logo { width: 40px; height: 36px; padding: 4px 0; justify-content: center; }
.sidebar--tablet .sidebar__nav { align-items: center; }

/* Promo banner */
.promo {
  position: relative; width: 100%; height: 224px; flex: none;
  background: var(--c-lime-muted); border-radius: var(--r-20);
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  padding: 16px 8px 8px; text-align: center;
}
.promo__glass { position: absolute; inset: 0; border-radius: var(--r-20); overflow: hidden; pointer-events: none; }
.promo__glass img { width: 100%; height: 100%; object-fit: cover; opacity: .56; mix-blend-mode: soft-light; }
.promo__art { position: absolute; left: 50%; margin-left: -70px; top: -54px; width: 140px; height: 104px; object-fit: contain; mix-blend-mode: multiply; pointer-events: none; }
.promo__head { position: relative; width: 100%; display: flex; flex-direction: column; gap: 16px; }
.promo__text { display: flex; flex-direction: column; gap: 8px; padding: 0 8px; }
.promo__title { font-size: var(--fs-h4); line-height: var(--lh-h4); font-weight: 500; color: var(--text); }
.promo__desc { font-size: var(--fs-body1); line-height: var(--lh-body1); color: var(--text-muted); }

/* 1.5 Mobile drawer */
.drawer { position: fixed; inset: 0; z-index: 90; visibility: hidden; pointer-events: none; }
.drawer.is-open { visibility: visible; pointer-events: auto; }
.drawer__backdrop { position: absolute; inset: 0; background: var(--backdrop-drawer); opacity: 0; transition: opacity var(--dur-med) var(--ease); }
.drawer.is-open .drawer__backdrop { opacity: 1; }
.drawer__panel {
  position: absolute; left: 0; top: 0; bottom: 0; width: min(300px, 85vw);
  background: var(--bg-surface); border-radius: 0 20px 20px 0; padding: 16px;
  display: flex; flex-direction: column; gap: 28px; overflow-y: auto;
  transform: translateX(-100%); transition: transform var(--dur-med) var(--ease);
}
.drawer.is-open .drawer__panel { transform: none; }
.drawer__head { display: flex; align-items: center; justify-content: space-between; padding-left: 16px; flex: none; }
.drawer__search { flex: none; margin-top: -8px; } /* F1: mobile search lives in the drawer (spec 03 decision) */

/* F1 (E3-07): shared not-found view for unknown hash routes (vf/router) */
.not-found { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; max-width: 560px; }
.not-found code { font-family: inherit; color: var(--text); word-break: break-all; }

/* 1.6 Search input */
.search {
  display: flex; align-items: center; gap: 8px; width: 240px; height: 40px; flex: none;
  padding: 4px 12px 4px 4px; background: var(--bg-sunken); border-radius: var(--r-24);
  border: 1px solid transparent; transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.search__icon { width: 32px; height: 32px; padding: 6px; border-radius: var(--r-24); background: var(--c-lime-muted); color: var(--icon-muted); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.search__icon svg { width: 20px; height: 20px; }
.search__input { flex: 1 1 0; min-width: 0; border: 0; background: transparent; outline: none; font-size: var(--fs-body1); line-height: var(--lh-body1); color: var(--text); padding: 0; }
.search__input::placeholder { color: var(--text-muted); opacity: 1; }
.search__input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search:focus-within { background: var(--bg-surface); border-color: var(--border-lime); box-shadow: var(--focus-ring); }
.search--outline { background: transparent; border-color: var(--border); }
.search--outline .search__icon { color: var(--text-subtle); }
.search--sm { height: 32px; }
.search--sm .search__icon { width: 24px; height: 24px; padding: 4px; }
.search--sm .search__icon svg { width: 16px; height: 16px; }
.search--sm .search__input { font-size: var(--fs-body2); line-height: var(--lh-body2); }
.search--fluid { width: 100%; }

/* 1.7 Header container */
.hdr {
  display: flex; align-items: center; gap: 24px; background: var(--bg-surface); border-radius: 240px;
  height: var(--header-h); padding: 16px; flex: none; min-width: 0;
}
.hdr--default { justify-content: space-between; }
.hdr--title { padding: 16px 16px 16px 24px; }
.hdr__title { flex: 1 1 0; min-width: 0; font-size: var(--fs-h4); line-height: var(--lh-h4); font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* D1: "Header"-variant page title is H5 Regular 16/400 #222 on desktop (screens/07 decision, same for 08/09); tablet keeps H4 Medium. */
@media (min-width: 1280px) { .hdr--title .hdr__title { font-size: var(--fs-h5); line-height: var(--lh-h5); font-weight: 400; } }
.hdr__crumbs { display: flex; align-items: center; gap: 16px; flex: 1 1 0; min-width: 0; }
.hdr__crumbs-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 0; }
.hdr__page { font-size: var(--fs-h5); line-height: var(--lh-h5); font-weight: 400; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hdr__profile { display: flex; align-items: center; gap: 12px; flex: none; position: relative; }
.hdr__who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hdr__name { font-size: var(--fs-body1); line-height: var(--lh-body1); color: var(--text); white-space: nowrap; }
.hdr__role { font-size: var(--fs-body2); line-height: var(--lh-body2); color: var(--text-muted); }
.hdr__avatar-btn { border-radius: 50%; flex: none; }
.hdr-double { display: flex; gap: 12px; flex: none; min-width: 0; }
.hdr-double > .hdr--left { flex: 1 1 0; justify-content: space-between; gap: 16px; }
.hdr-double > .hdr--right { flex: none; width: 323px; justify-content: flex-end; gap: 24px; }
.hdr__actions { display: flex; align-items: center; gap: 12px; flex: none; }
.hdr .btn--icon-only.btn--md { width: 38px; height: 38px; }
@media (max-width: 1279.98px) {
  .hdr { height: var(--header-h-tablet); padding: 12px; }
  .hdr--title { padding: 12px 12px 12px 20px; }
  .hdr .hdr__who, .hdr .hdr__caret { display: none; }
  .hdr-double > .hdr--right { width: 168px; padding: 12px; }
  .hdr-double > .hdr--left { padding: 12px; }
}
@media (max-width: 767.98px) {
  .hdr, .hdr-double { display: none; }
}

/* 1.8 Breadcrumb */
.crumbs { display: flex; align-items: center; gap: 4px; height: 16px; font-size: var(--fs-body2); line-height: var(--lh-body2); min-width: 0; }
.crumbs__link { color: var(--text-subtle); white-space: nowrap; }
.crumbs__link:hover { text-decoration: underline; }
.crumbs__sep { color: var(--text-subtle); display: inline-flex; }
.crumbs__current { color: var(--primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 1.9 Footer */
.footer {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex: none;
  min-height: 48px; padding: 16px; background: var(--bg-surface); border-radius: 240px;
  font-size: var(--fs-body2); line-height: var(--lh-body2); color: var(--text-subtle);
}
.footer__legal { display: flex; align-items: center; gap: 16px; }
.footer__copy { font-weight: 500; color: var(--text-muted); white-space: nowrap; }
.footer__links { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.footer__links a:hover { color: var(--primary); }
.footer__sep { width: 4px; height: 1px; background: var(--c-gray-soft); flex: none; }
@media (max-width: 767.98px) {
  .footer { flex-direction: column; border-radius: var(--r-20); gap: 16px; text-align: center; }
  .footer__legal { flex-direction: column; gap: 8px; }
}

/* 1.10 Navbar mobile */
.navbar-m {
  display: none; align-items: center; gap: 16px; height: var(--navbar-mobile-h); flex: none;
  padding: 10px 16px; background: var(--bg-surface); border-radius: 240px;
}
@media (max-width: 767.98px) { .navbar-m { display: flex; } }
.navbar-m__title { flex: 1 1 0; min-width: 0; text-align: center; font-size: var(--fs-h4); line-height: var(--lh-h4); font-weight: 500; color: var(--c-ink-alt); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.navbar-m .btn--icon-only { margin: -5px 0; }
.navbar-m .logo { width: 38px; justify-content: flex-start; }

/* User menu / dropdown panel */
.menu {
  position: absolute; z-index: 60; min-width: 180px; padding: 4px;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-12);
  box-shadow: 0 8px 24px rgba(34,34,34,.08), var(--fx-hairline);
  display: flex; flex-direction: column; gap: 2px;
}
.menu__item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: var(--r-8); font-size: var(--fs-body2); line-height: var(--lh-body2); color: var(--text);
}
.menu__item:hover, .menu__item:focus-visible { background: var(--c-gray-pale); }
.menu__item.is-selected { color: var(--primary); font-weight: 500; }
.menu__item--danger { color: var(--danger); }
.menu__empty { padding: 12px; font-size: var(--fs-body2); color: var(--text-muted); }

/* =====================================================================
   2. Primitives
   ===================================================================== */
/* 2.1 Button */
.btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  border: 0; border-radius: var(--r-24); white-space: nowrap; cursor: pointer; user-select: none;
  height: 40px; padding: 10px 16px; gap: 0;
  font-size: var(--fs-body1); line-height: var(--lh-body1); font-weight: 400;
  background: var(--bg-neutral); color: var(--text);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn > svg { width: 18px; height: 18px; }
.btn__label { padding: 0 6px; }
.btn:active { transform: scale(.98); }
.btn:disabled, .btn.is-disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn--md { height: 40px; padding: 10px 16px; }
.btn--sm { height: 32px; padding: 8px 10px; gap: 2px; font-size: var(--fs-body2); line-height: var(--lh-body2); }
.btn--sm > svg { width: 16px; height: 16px; }
.btn--sm .btn__label { padding: 0 4px; }
.btn--xs { height: 28px; padding: 6px 8px; font-size: var(--fs-body2); line-height: var(--lh-body2); }
.btn--xs > svg { width: 16px; height: 16px; }
.btn--xs .btn__label { padding: 0 4px; }
.btn--xxs { height: 24px; padding: 4px 8px; font-size: var(--fs-body3); line-height: var(--lh-body3); }
.btn--xxs > svg { width: 12px; height: 12px; }
.btn--xxs .btn__label { padding: 0 4px; }

.btn--primary { background: var(--primary); color: #FFFFFF; font-weight: 500; }
.btn--primary:hover { background: var(--primary-hover); }
.btn--secondary { background: var(--accent); color: var(--text); }
.btn--secondary:hover { background: var(--hover-secondary); }
.btn--tertiary { background: var(--bg-neutral); color: var(--text); }
.btn--tertiary:hover { background: var(--hover-tertiary); }
.btn--ghost { background: transparent; color: var(--text); }
.btn--ghost:hover { background: var(--hover-ghost); }
.btn--white { background: #FFFFFF; color: var(--text); }
.btn--white:hover { background: var(--hover-ghost); }
.btn--destructive { background: var(--danger-bg); color: var(--danger); }
.btn--destructive > svg { color: var(--c-red-icon); }
.btn--destructive:hover { background: var(--hover-destructive); }
.btn--block { width: 100%; display: flex; }
.btn--icon-only { padding: 10px; width: 38px; height: 38px; }
.btn--icon-only.btn--sm { padding: 8px; width: 32px; height: 32px; }
.btn--icon-only .btn__label { display: none; }
.btn--page { width: 32px; padding: 0; }

/* 2.2 Button Icon */
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none;
  border-radius: var(--r-24); border: 0; cursor: pointer;
  width: 40px; height: 40px; padding: 10px; background: var(--bg-neutral); color: var(--text);
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.icon-btn > svg { width: 20px; height: 20px; }
.icon-btn:active { transform: scale(.96); }
.icon-btn:disabled, .icon-btn.is-disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.icon-btn--md { width: 40px; height: 40px; padding: 10px; }
.icon-btn--sm { width: 32px; height: 32px; padding: 8px; }
.icon-btn--sm > svg { width: 16px; height: 16px; }
.icon-btn--xs { width: 28px; height: 28px; padding: 8px; }
.icon-btn--xs > svg { width: 12px; height: 12px; }
.icon-btn--xxs { width: 24px; height: 24px; padding: 6px; }
.icon-btn--xxs > svg { width: 12px; height: 12px; }
.icon-btn--2xs { width: 20px; height: 20px; padding: 6px; }
.icon-btn--2xs > svg { width: 8px; height: 8px; }
.icon-btn--primary { background: var(--primary); color: #FFFFFF; }
.icon-btn--primary:hover { background: var(--primary-hover); }
.icon-btn--secondary { background: var(--accent); color: var(--on-accent); }
.icon-btn--secondary:hover { background: var(--hover-secondary); }
.icon-btn--tertiary { background: var(--bg-neutral); color: var(--text); }
.icon-btn--tertiary:hover { background: var(--hover-tertiary); }
.icon-btn--white { background: #FFFFFF; color: var(--text); }
.icon-btn--white:hover { background: var(--hover-ghost); }
.icon-btn--ghost { background: transparent; color: var(--text); }
.icon-btn--ghost:hover { background: var(--hover-ghost); }
.icon-btn__dot {
  position: absolute; top: 9px; right: 11px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary); box-shadow: 0 0 0 1px #FFFFFF;
}
.icon-btn--sm .icon-btn__dot { width: 6px; height: 6px; top: 7px; right: 9px; }
.icon-btn--xs .icon-btn__dot { width: 6px; height: 6px; top: 7px; right: 8px; }
.icon-btn--xxs .icon-btn__dot { width: 6px; height: 6px; top: 5px; right: 6px; }
.icon-btn--2xs .icon-btn__dot { width: 4px; height: 4px; top: 5px; right: 6px; }
.icon-btn--primary .icon-btn__dot { background: var(--c-lime-highlight); }
.icon-btn--secondary .icon-btn__dot { box-shadow: 0 0 0 1px var(--c-lime-muted); }

/* 2.3 Badge */
.badge-dot { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; flex: none; }
.badge-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.badge-dot--sm::before { width: 6px; height: 6px; }
.badge-dot--xs { width: 16px; height: 16px; }
.badge-dot--xs::before { width: 4px; height: 4px; }
.badge-num {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  min-width: 20px; height: 20px; padding: 2px 4px; border-radius: var(--r-20);
  background: var(--primary); color: #FFFFFF; font-size: var(--fs-label4); line-height: var(--lh-label4); font-weight: 500;
}
.badge-num--sm { min-width: 16px; height: 16px; padding: 0 3px; font-size: var(--fs-label5); line-height: var(--lh-label5); }
.nav-item.is-active .badge-num { background: var(--c-lime-pale); color: var(--primary); }

/* 2.4 Avatar */
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none; overflow: hidden;
  width: 40px; height: 40px; border-radius: 50%; background: var(--primary);
}
.avatar > img { width: 100%; height: 100%; object-fit: cover; }
.avatar--lg { width: 40px; height: 40px; }
.avatar--md { width: 32px; height: 32px; }
.avatar--sm { width: 24px; height: 24px; }
.avatar--xs { width: 16px; height: 16px; }
.avatar--initials { background: var(--c-lime-pale); color: var(--primary); padding: 2px; text-transform: uppercase; font-size: var(--fs-h5); line-height: var(--lh-h5); }
.avatar--initials.avatar--md { font-size: var(--fs-body2); }
.avatar--initials.avatar--sm { font-size: var(--fs-body4); }
.avatar--initials.avatar--xs { font-size: var(--fs-body6); }
.avatar-stack { display: inline-flex; }
.avatar-stack > .avatar { box-shadow: 0 0 0 2px #FFFFFF; }
.avatar-stack > .avatar + .avatar { margin-left: -6px; }

/* 2.5 Checkbox */
.check {
  appearance: none; -webkit-appearance: none; margin: 0; flex: none; cursor: pointer; position: relative;
  width: 12px; height: 12px; border-radius: var(--r-2);
  background: var(--bg-neutral); box-shadow: 0 0 0 1px var(--c-gray-soft);
  background-repeat: no-repeat; background-position: center;
  transition: background-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.check:hover { box-shadow: 0 0 0 1px var(--text-subtle); }
.check:checked {
  background-color: var(--primary); box-shadow: 0 0 0 1px var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 6.2 5 8l4-4.2' fill='none' stroke='%23fff' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 100% 100%;
}
.check:indeterminate {
  background-color: var(--primary); box-shadow: 0 0 0 1px var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 6h6' stroke='%23fff' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-size: 100% 100%;
}
.check:focus-visible { box-shadow: 0 0 0 1px var(--primary), var(--focus-ring); }
.check:disabled { opacity: .45; cursor: not-allowed; }
.check--md { width: 16px; height: 16px; border-radius: var(--r-4); }
.check--lg { width: 22px; height: 22px; border-radius: var(--r-4); box-shadow: 0 0 0 1.5px var(--c-gray-soft); }

/* 2.6 Radio */
.radio {
  appearance: none; -webkit-appearance: none; margin: 0; flex: none; cursor: pointer;
  width: 12px; height: 12px; border-radius: 50%; background: var(--bg-neutral); box-shadow: 0 0 0 1px var(--c-gray-soft);
  transition: background var(--dur-fast) var(--ease);
}
.radio:hover { box-shadow: 0 0 0 1px var(--text-subtle); }
.radio:checked { background: var(--primary); box-shadow: 0 0 0 1px var(--primary), inset 0 0 0 1.5px #FFFFFF; }
.radio:focus-visible { box-shadow: 0 0 0 1px var(--primary), var(--focus-ring); }
.radio--md { width: 16px; height: 16px; }
.radio--lg { width: 22px; height: 22px; }
.radio--lg:checked { box-shadow: 0 0 0 1px var(--primary), inset 0 0 0 1px #FFFFFF; }

/* 2.7 Toggle */
.toggle {
  position: relative; display: inline-flex; flex: none; width: 28px; height: 16px; padding: 2px; border-radius: var(--r-8);
  background: var(--c-gray-soft); cursor: pointer; transition: background var(--dur-fast) var(--ease);
}
.toggle__knob { width: 12px; height: 12px; border-radius: 50%; background: #FFFFFF; transition: transform var(--dur-fast) var(--ease); }
.toggle:hover { background: #CFD1D0; }
.toggle.is-on, .toggle[aria-checked="true"] { background: var(--primary); }
.toggle.is-on:hover, .toggle[aria-checked="true"]:hover { background: var(--primary-hover); }
.toggle.is-on .toggle__knob, .toggle[aria-checked="true"] .toggle__knob { transform: translateX(12px); }

/* 2.8 Input field */
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field__label { font-size: var(--fs-body2); line-height: var(--lh-body2); color: var(--text); }
.field__box {
  display: flex; align-items: center; gap: 12px; height: 44px; padding: 12px 16px;
  background: var(--bg-sunken); border-radius: var(--r-24); border: 1px solid transparent; color: var(--icon-muted);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.field__box > svg { width: 16px; height: 16px; flex: none; }
.field__input {
  flex: 1 1 0; min-width: 0; border: 0; outline: none; background: transparent; padding: 0;
  font-size: var(--fs-body1); line-height: var(--lh-body1); color: var(--text);
}
.field__input::placeholder { color: var(--text-muted); opacity: 1; }
select.field__input { appearance: none; -webkit-appearance: none; cursor: pointer; }
textarea.field__input { resize: vertical; min-height: 60px; }
.field__box--textarea { height: auto; align-items: flex-start; border-radius: var(--r-16); }
.field__unit { font-size: var(--fs-body1); line-height: var(--lh-body1); color: var(--text-muted); flex: none; }
.field__help { font-size: var(--fs-body2); line-height: var(--lh-body2); color: var(--text-muted); }
.field__trail { display: inline-flex; color: var(--icon-muted); flex: none; }
.field__box:focus-within { background: var(--bg-surface); border-color: var(--border-lime); box-shadow: var(--focus-ring); }
.field--qty .field__box { border-radius: var(--r-pill); padding: 6px 6px 6px 16px; }
.field--qty .field__input { text-align: left; }
.field__stepper { display: flex; gap: 4px; flex: none; }
.field.is-disabled .field__label, .field.is-disabled .field__input, .field.is-disabled .field__unit,
.field.is-disabled .field__help, .field.is-disabled .field__box { color: var(--text-subtle); }
.field.is-disabled .field__stepper { opacity: .45; pointer-events: none; }
.field.is-error .field__box { border-color: var(--danger); }
.field.is-error .field__help, .field__error { color: var(--danger); font-size: var(--fs-body2); line-height: var(--lh-body2); }
.form-error { background: var(--danger-bg); color: var(--danger); border-radius: var(--r-12); padding: 8px 12px; font-size: var(--fs-body2); line-height: var(--lh-body2); }

/* 2.9 Segmented button */
.segmented { display: inline-flex; align-items: center; padding: 2px; gap: 0; background: var(--bg-neutral); border-radius: var(--r-24); flex: none; }
.segmented__item {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 28px; padding: 6px 12px;
  border-radius: var(--r-24); font-size: var(--fs-body2); line-height: var(--lh-body2); color: var(--icon-muted);
  white-space: nowrap; transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.segmented__item > svg { width: 16px; height: 16px; }
.segmented__item:hover { color: var(--text); }
.segmented__item.is-active { background: var(--primary); color: #FFFFFF; font-weight: 500; }
.segmented--fluid { display: flex; }
.segmented--fluid .segmented__item { flex: 1 1 0; }

/* Tabs with counts (Calendar categories, Healthy Menu tabs) */
.tabs { display: flex; align-items: center; gap: 4px; padding: 4px; background: var(--bg-neutral); border-radius: var(--r-pill); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs__item {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 6px 12px; border-radius: var(--r-pill);
  font-size: var(--fs-body2); line-height: var(--lh-body2); color: var(--text-muted); white-space: nowrap; flex: none;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.tabs__item:hover { color: var(--text); background: rgba(255,255,255,.6); }
.tabs__item.is-active { background: var(--bg-surface); color: var(--text); font-weight: 500; }
.tabs__count { min-width: 20px; height: 20px; padding: 2px 6px; border-radius: var(--r-pill); background: var(--bg-surface); font-size: var(--fs-label4); font-weight: 500; color: var(--text); display: inline-flex; align-items: center; justify-content: center; }
.tabs__item.is-active .tabs__count { background: var(--primary); color: #FFFFFF; }

/* 2.10 Pagination */
.pager { display: flex; align-items: center; gap: 8px; flex: none; }
.pager__pages { display: flex; align-items: center; gap: 8px; }
.pager__page { width: 32px; height: 32px; padding: 0; justify-content: center; }
.pager__page.is-current { background: var(--primary); color: #FFFFFF; font-weight: 500; }
.pager__gap { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; font-size: var(--fs-body2); color: var(--text); }
.pager-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.pager-bar__info { font-size: var(--fs-body2); line-height: var(--lh-body2); color: var(--text-muted); }
.pager-bar__info b { font-weight: 400; color: var(--text); }

/* 2.11 Section header */
.sec-head { display: flex; align-items: center; gap: 32px; min-height: 32px; min-width: 0; }
.sec-head__titles { display: flex; align-items: baseline; gap: 4px; flex: 1 1 0; min-width: 0; }
.sec-head__title { font-size: var(--fs-h5); line-height: var(--lh-h5); font-weight: 400; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sec-head__count { font-size: var(--fs-body1); line-height: var(--lh-body1); color: var(--text-muted); white-space: nowrap; }
.sec-head__actions { display: flex; align-items: center; gap: 12px; flex: none; }
.sec-head__sort { display: inline-flex; align-items: baseline; gap: 10px; }
.sec-head__sort > span { font-size: var(--fs-body3); line-height: var(--lh-body3); color: var(--text-muted); white-space: nowrap; }
.sec-head .search--sm { width: 172px; }

/* 2.12 Column chart (CSS variant; ui.js columnChart() renders SVG with the same geometry) */
.colchart { position: relative; display: flex; align-items: stretch; gap: 0; width: 100%; }
.colchart__ylabels { display: flex; flex-direction: column; justify-content: space-between; padding: 0 8px 26px 0; font-size: var(--fs-body3); line-height: var(--lh-body3); color: var(--text-muted); text-align: right; }
.colchart__xlabel { font-size: var(--fs-body3); line-height: var(--lh-body3); color: var(--text-muted); text-align: center; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-svg text { font-family: var(--font); }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none; transform: translate(-50%, calc(-100% - 8px));
  background: #FFFFFF; border-radius: var(--r-8); padding: 6px 8px; box-shadow: var(--fx-hairline), 0 4px 12px rgba(34,34,34,.08);
  display: flex; flex-direction: column; gap: 2px; white-space: nowrap;
}
.chart-tip__value { font-size: var(--fs-label3); line-height: var(--lh-label3); font-weight: 500; color: var(--text); }
.chart-tip__label { font-size: var(--fs-body3); line-height: var(--lh-body3); color: var(--text-muted); }
.chart-wrap { position: relative; }

/* Donut / ring */
.donut { position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.donut > svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.donut__label { position: relative; font-size: var(--fs-label3); line-height: var(--lh-label3); font-weight: 500; color: var(--text); }

/* Progress bar */
.progress { position: relative; height: 8px; border-radius: var(--r-pill); background: var(--bg-neutral); overflow: hidden; }
.progress__fill { height: 100%; border-radius: inherit; background: var(--primary); }
.progress__fill--grad { background: var(--grad-deep); }
.progress--16 { height: 16px; padding: 2px; }

/* Dot meter */
.dot-meter { display: inline-flex; gap: 4px; flex: none; }
.dot-meter > i { width: 10px; height: 10px; border-radius: var(--r-pill); background: var(--c-lime-pale); }
.dot-meter > i.is-on { background: var(--primary); }

/* 2.13 Legends */
.legend { display: flex; align-items: center; gap: 6px; min-width: 0; }
.legend__swatch { flex: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.legend__label { font-size: var(--fs-body2); line-height: var(--lh-body2); color: var(--text); }
.legend__value { font-size: var(--fs-body3); line-height: var(--lh-body3); color: var(--text-muted); white-space: nowrap; }
.legend__pct { font-size: var(--fs-label3); line-height: var(--lh-label3); font-weight: 500; color: var(--text); white-space: nowrap; }
.legend--v1 { justify-content: space-between; height: 20px; }
.legend--v1 .legend__swatch { width: 20px; height: 20px; padding: 4px; }
.legend--v1 .legend__pct { background: var(--accent); border-radius: var(--r-24); padding: 2px 8px; }
.legend--v2 { height: 24px; padding: 4px; gap: 8px; border-radius: var(--r-pill); }
.legend--v2 .legend__swatch { width: 12px; height: 12px; }
.legend--v2 .legend__label { flex: 1 1 0; }
.legend--v3 { gap: 4px; height: 16px; }
.legend--v3 .legend__swatch { width: 20px; height: 8px; border-radius: var(--r-8); }
.legend--v3 .legend__label { font-size: var(--fs-body3); line-height: var(--lh-body3); }

/* =====================================================================
   3. Status badges (.tag)
   ===================================================================== */
.tag {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none;
  height: 24px; padding: 4px 8px; border-radius: var(--r-24); white-space: nowrap;
  font-size: var(--fs-body2); line-height: var(--lh-body2); background: var(--bg-neutral); color: var(--text);
}
.tag > svg { flex: none; }
button.tag { cursor: pointer; transition: filter var(--dur-fast) var(--ease); }
button.tag:hover { filter: brightness(.97); }
.tag--status-completed { background: var(--success-bg); color: var(--success); }
.tag--status-progress { background: var(--warning-bg); color: var(--warning); }
.tag--status-notstarted { background: var(--bg-neutral); color: var(--text); }
.tag--status-skipped { background: var(--danger-bg); color: var(--danger); }

.tag--meal { height: 20px; padding: 2px 8px; font-size: var(--fs-label3); line-height: var(--lh-label3); font-weight: 500; color: var(--primary); }
.tag--meal.tag--lg { height: 24px; }
.tag--breakfast { background: var(--meal-breakfast); }
.tag--lunch { background: var(--meal-lunch); }
.tag--snack { background: var(--meal-snack); }
.tag--dinner { background: var(--meal-dinner); }
.tag--onphoto { background: #FFFFFF; }

.tag--grocery { padding: 2px 8px 2px 2px; gap: 4px; background: var(--bg-neutral); }
.tag--grocery .tag__chip { width: 20px; height: 20px; padding: 4px; border-radius: 50%; display: inline-flex; color: #FFFFFF; }
.tag--grocery.tag--bare { height: 16px; padding: 0; background: none; }
.tag--grocery.tag--bare .tag__chip { width: 16px; height: 16px; padding: 2px; }
.tag--protein .tag__chip { background-color: var(--viz-1); }
.tag--veggies .tag__chip { background-color: var(--viz-2); }
.tag--grains .tag__chip { background-color: var(--viz-3); }
.tag--fruits .tag__chip { background-color: var(--viz-4); color: var(--c-lime-ink); }
.tag--dairy .tag__chip { background-color: var(--viz-5); color: var(--c-lime-ink); }
.tag--others .tag__chip { background-color: var(--viz-6); color: var(--c-lime-ink); }
.tag--protein .tag__chip, .tag--veggies .tag__chip, .tag--grains .tag__chip { --hatch: var(--hatch-dark); }
.tag--fruits .tag__chip, .tag--dairy .tag__chip { --hatch: var(--hatch-lime); }
.tag--others .tag__chip { --hatch: var(--hatch-pale); }

.tag--purchased { background: var(--success-bg); color: var(--success); padding: 4px 8px 4px 6px; gap: 4px; }
.tag--purchased > svg { color: var(--c-green-icon); }
.tag--pending { background: var(--warning-bg); color: var(--warning); padding: 4px 8px 4px 6px; gap: 4px; }
.tag--pending > svg { color: var(--c-orange-icon); }

.tag--sugar { min-width: 56px; gap: 2px; align-items: baseline; }
.tag--sugar small { font-size: var(--fs-body3); line-height: var(--lh-body3); }
.tag--sugar-low { background: var(--success-bg); color: var(--success); }
.tag--sugar-moderate { background: var(--warning-bg); color: var(--warning); }
.tag--sugar-high { background: var(--danger-bg); color: var(--danger); }

.tag--thought { gap: 4px; background: var(--bg-neutral); color: var(--text); }
.tag--thought > svg { color: var(--c-lime-ink); }

.tag--pct { height: 20px; padding: 2px 8px; font-size: var(--fs-label3); line-height: var(--lh-label3); font-weight: 500; background: var(--accent); }
.tag--lime { background: var(--accent); color: var(--primary); }
.tag--pale { background: var(--c-lime-pale); color: var(--primary); }

/* =====================================================================
   4. Domain cards (geometry from components.md §4; screens add layout only)
   ===================================================================== */
/* 4.1 KPI */
.kpi { background: var(--bg-surface); border-radius: var(--r-16); padding: 16px; display: flex; align-items: center; gap: 12px; flex: 1 1 0; min-width: 0; }
.kpi__icon { width: 40px; height: 40px; padding: 8px; }
.kpi__body { display: flex; flex-direction: column; gap: 4px; flex: 1 1 0; min-width: 0; }
.kpi__title { font-size: var(--fs-body2); line-height: var(--lh-body2); color: var(--text-muted); }
.kpi__stats { display: flex; align-items: flex-end; gap: 8px; }
.kpi__value { font-size: var(--fs-h3); line-height: var(--lh-h3); font-weight: 500; color: var(--text); flex: 1 1 0; white-space: nowrap; }
.kpi__trend { display: flex; flex-direction: column; align-items: flex-end; padding-bottom: 2px; }
.kpi__trend-row { display: inline-flex; align-items: center; gap: 4px; color: var(--success); font-size: var(--fs-label3); line-height: var(--lh-label3); font-weight: 500; }
.kpi__trend-row > svg { color: var(--c-green-icon); }
.kpi__trend.is-down .kpi__trend-row { color: var(--danger); }
.kpi__trend.is-down .kpi__trend-row > svg { color: var(--c-red-icon); }
.kpi__cmp { font-size: var(--fs-body3); line-height: var(--lh-body3); color: var(--text-muted); white-space: nowrap; }

/* 4.2 Stat pill / trend pill */
.stat-pill { background: var(--bg-surface); border-radius: var(--r-pill); padding: 16px 20px 16px 16px; display: flex; align-items: flex-end; gap: 12px; flex: 1 1 0; min-width: 0; }
.stat-pill__icon { width: 51px; height: 51px; padding: 12px; border-radius: 50%; background: var(--accent); color: var(--c-lime-ink); box-shadow: var(--fx-chip-dark); display: inline-flex; flex: none; }
.trend-pill { display: inline-flex; align-items: center; gap: 2px; padding: 2px; height: 24px; border-radius: var(--r-pill); background: var(--success-bg); flex: none; }
.trend-pill__icon { width: 20px; height: 20px; padding: 4px; border-radius: 50%; background: var(--success); color: #FFFFFF; box-shadow: var(--fx-chip-dark); display: inline-flex; }
.trend-pill__value { background: #FFFFFF; border-radius: var(--r-pill); padding: 2px 6px; font-size: var(--fs-label3); line-height: var(--lh-label3); font-weight: 500; color: var(--success); }
.trend-pill.is-down { background: var(--danger-bg); }
.trend-pill.is-down .trend-pill__icon { background: var(--danger); }
.trend-pill.is-down .trend-pill__value { color: var(--danger); }

/* 4.3 Meal plan tiles + meal entry card */
.mp-week, .mp-day { background: var(--bg-surface); border-radius: var(--r-12); height: 44px; padding: 12px 16px; display: flex; align-items: center; gap: 2px; flex: 1 1 0; min-width: 0; font-size: var(--fs-body1); line-height: var(--lh-body1); }
.mp-day { justify-content: center; padding: 12px 8px; }
.mp-day.is-active { background: var(--primary); color: #FFFFFF; }
.mp-cat, .mp-meal { background: var(--accent); border-radius: var(--r-12); min-height: 176px; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.mp-cat { padding-top: 16px; gap: 16px; }
.mp-meal { padding: 16px 8px 8px; gap: 8px; align-items: center; cursor: pointer; }
.mp-meal--empty { background: var(--bg-sunken); border: 1px dashed var(--c-gray-soft); justify-content: center; }

.meal-card { border-radius: var(--r-16); padding: 12px 4px 4px; display: flex; flex-direction: column; gap: 12px; background: var(--bg-neutral); }
.meal-card--photo { background: var(--bg-sunken); }
.meal-card__row { display: flex; align-items: center; gap: 16px; padding: 0 8px; }
.meal-card__info { display: flex; flex-direction: column; gap: 10px; flex: 1 1 0; min-width: 0; }
.meal-card__cat { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; background: var(--accent); border-radius: var(--r-24); padding: 4px 8px; font-size: var(--fs-label2); line-height: var(--lh-label2); font-weight: 500; color: var(--primary); cursor: pointer; }
.meal-card__img { width: 74px; height: 74px; border-radius: 50%; background: var(--accent); padding: 8px; flex: none; }
.meal-card__img img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.meal-card__macros { background: var(--bg-surface); border-radius: var(--r-12); padding: 6px 8px; display: flex; gap: 12px; }
.meal-card__macro { flex: 1 1 0; display: flex; align-items: center; gap: 6px; min-width: 0; }
.meal-card__macro::before { content: ""; width: 2px; height: 10px; border-radius: var(--r-4); background: var(--c-lime-pale); flex: none; }

/* 4.4 Meal value */
.meal-value { background: var(--bg-surface); border-radius: var(--r-12); padding: 8px; display: flex; align-items: center; gap: 8px; flex: 1 1 0; min-width: 0; }

/* 4.5 Recommended menu */
.rec-menu { background: var(--bg-sunken); border-radius: var(--r-16); padding: 4px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rec-menu__head { background: var(--bg-surface); border-radius: var(--r-12); padding: 12px; display: flex; align-items: center; gap: 16px; }
.rec-menu__macros { background: var(--bg-sunken); border-radius: var(--r-12); padding: 2px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.rec-menu__macros > span { background: var(--bg-surface); border-radius: var(--r-10); height: 20px; padding: 2px 6px; display: flex; align-items: center; gap: 4px; justify-content: space-between; }
.rec-menu__foot { background: var(--bg-surface); border-radius: var(--r-24); padding: 4px; display: flex; align-items: center; gap: 8px; }
.rec-menu--card { cursor: pointer; }
.rec-menu__photo { position: relative; height: 132px; border-radius: var(--r-12); overflow: hidden; padding: 6px; }
.rec-menu__photo > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.rec-menu__photo > .tag { position: relative; }
.rec-menu__body { background: var(--bg-surface); border-radius: var(--r-12); padding: 8px; display: flex; flex-direction: column; gap: 16px; }

/* 4.6 Popular menu */
.pop-menu { background: var(--bg-sunken); border-radius: var(--r-16); padding: 4px; display: flex; flex-direction: column; gap: 4px; justify-content: space-evenly; align-items: stretch; min-height: 184px; flex: 1 1 0; min-width: 0; cursor: pointer; }
.pop-menu__foot { background: var(--bg-surface); border-radius: var(--r-12); padding: 8px; display: flex; gap: 8px; align-items: flex-start; }

/* 4.7 Menu list row */
.menu-row { background: var(--bg-surface); border-radius: var(--r-12); padding: 16px; display: flex; align-items: center; gap: 24px; cursor: pointer; min-width: 0; }
.menu-row--stacked { flex-direction: column; gap: 16px; position: relative; }
.menu-row__img { width: 109px; height: 109px; border-radius: 50%; flex: none; overflow: hidden; }
.menu-row__img--cutout { background: var(--accent); padding: 8px; }
.menu-row__img img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.nutri-group { display: inline-flex; align-items: center; gap: 4px; padding: 4px; background: var(--bg-neutral); border-radius: var(--r-pill); }
.nutri-group > span { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 4px 8px; background: var(--bg-surface); border-radius: var(--r-pill); white-space: nowrap; }

/* 4.8 Recommended exercise */
.rec-ex { background: var(--bg-sunken); border-radius: var(--r-16); padding: 8px 16px 8px 8px; display: flex; gap: 16px; min-width: 0; }
.rec-ex__img { width: 90px; height: 96px; border-radius: var(--r-8); object-fit: cover; flex: none; }
.rec-ex--compact .rec-ex__img { width: 84px; }
.rec-ex__level { background: var(--c-lime-pale); border-radius: var(--r-24); padding: 2px 8px; font-size: var(--fs-label3); line-height: var(--lh-label3); font-weight: 500; color: var(--primary); white-space: nowrap; }

/* 4.9 Workout progress */
.workout { background: var(--bg-surface); border-radius: var(--r-12); padding: 12px; display: flex; align-items: center; gap: 12px; min-width: 0; }

/* 4.10 Macro row */
.macro-row { background: var(--bg-surface); border-radius: var(--r-12); padding: 12px; display: flex; align-items: center; gap: 12px; min-width: 0; }

/* 4.11 Activity */
.activity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.activity__chip { width: 32px; height: 32px; padding: 8px; border-radius: var(--r-24); background: var(--accent); color: var(--c-lime-ink); box-shadow: 0 0 0 1px #FFFFFF; display: inline-flex; flex: none; }

/* 4.12 Cooking direction step */
.step { display: flex; gap: 8px; }
.step__rail { width: 36px; flex: none; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.step__num { width: 36px; height: 36px; padding: 4px; border-radius: var(--r-24); background: #FFFFFF; display: inline-flex; }
.step__num > span { width: 28px; height: 28px; border-radius: 50%; background: #FFFFFF; box-shadow: inset 0 0 0 1px var(--border); display: inline-flex; align-items: center; justify-content: center; font-size: var(--fs-label3); font-weight: 500; }
.step__line { flex: 1 1 auto; width: 1px; background: #FFFFFF; min-height: 8px; }
.step:last-child .step__line { display: none; }
.step__body { flex: 1 1 0; min-width: 0; background: #FFFFFF; border-radius: var(--r-12); padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; justify-content: center; }

/* 4.13 Item pill */
.item-pill { background: var(--bg-surface); border-radius: var(--r-24); padding: 4px 12px 4px 4px; display: flex; align-items: center; gap: 6px; min-height: 30px; flex: 1 1 0; min-width: 0; font-size: var(--fs-body2); line-height: var(--lh-body2); }
.item-pill__lead { width: 22px; height: 22px; padding: 4px; border-radius: var(--r-24); background: var(--accent); color: var(--c-lime-ink); display: inline-flex; align-items: center; justify-content: center; flex: none; font-size: var(--fs-body4); line-height: 1; color: var(--text); }
.item-pill__lead > svg { color: var(--c-lime-ink); }

/* 4.14 Review */
.review { background: var(--bg-surface); border-radius: var(--r-12); padding: 12px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.rating { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-label3); line-height: var(--lh-label3); font-weight: 500; }
.rating > svg { color: var(--c-lime-ink); }

/* 4.15 Trending tag */
.trend-tag { display: flex; gap: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border-subtle); }
.trend-tag:last-child { border-bottom: 0; padding-bottom: 0; }
.trend-tag__idx { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center; flex: none; }

/* 4.16 Top author */
.top-author { background: var(--bg-sunken); border-radius: var(--r-pill); padding: 4px; display: flex; gap: 4px; }
.top-author__photo { width: 64px; height: 64px; padding: 12px; background: #FFFFFF; border-radius: 240px 20px 20px 240px; flex: none; }
.top-author__info { flex: 1 1 0; min-width: 0; background: #FFFFFF; border-radius: 8px 240px 240px 8px; padding: 12px; display: flex; align-items: center; gap: 4px; }
.top-author__rank { width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: #FFFFFF; display: inline-flex; align-items: center; justify-content: center; font-size: var(--fs-label1); font-weight: 500; flex: none; }

/* 4.17–4.20 Articles */
.insight-feature { background: var(--bg-sunken); border-radius: var(--r-16); padding: 4px; display: flex; gap: 4px; cursor: pointer; min-width: 0; }
.insight-feature__img { position: relative; width: 172px; flex: none; border-radius: var(--r-12); overflow: hidden; padding: 8px; }
.insight-feature__img > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.insight-feature__body { flex: 1 1 0; min-width: 0; background: #FFFFFF; border-radius: var(--r-12); padding: 12px; display: flex; flex-direction: column; justify-content: space-between; gap: 24px; }
.pill-cat { position: relative; display: inline-flex; align-items: center; height: 20px; padding: 2px 8px; border-radius: var(--r-24); background: var(--c-lime-pale); color: var(--primary); font-size: var(--fs-body3); line-height: var(--lh-body3); white-space: nowrap; }
.article-tile { position: relative; border-radius: var(--r-12); padding: 4px; min-height: 198px; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; cursor: pointer; }
.article-tile > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.article-tile__glass { position: relative; border-radius: var(--r-12); padding: 12px; background: rgba(91,101,68,.08); backdrop-filter: blur(32px); -webkit-backdrop-filter: blur(32px); color: #FFFFFF; font-size: var(--fs-label1); line-height: var(--lh-label1); font-weight: 500; text-shadow: 0 1px 2px rgba(34,34,34,.25); }
.article-row { display: flex; align-items: center; gap: 16px; cursor: pointer; min-width: 0; }
.article-row__img { width: 100px; height: 96px; border-radius: var(--r-12); object-fit: cover; flex: none; }
.article-card { background: var(--bg-neutral); border-radius: var(--r-16); padding: 4px; display: flex; flex-direction: column; gap: 4px; flex: 1 1 0; min-width: 0; cursor: pointer; }
.article-card__img { width: 100%; height: 164px; border-radius: var(--r-12); object-fit: cover; }
.article-card__body { background: #FFFFFF; border-radius: var(--r-12); padding: 12px; display: flex; flex-direction: column; gap: 20px; flex: 1 1 auto; }
.article-card--h { flex-direction: row; }
.article-card--h .article-card__img { width: 112px; height: auto; min-height: 156px; }

/* 4.21–4.22 Progress */
.progress-photo { background: var(--c-lime-pale); border-radius: var(--r-12); padding: 4px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.progress-photo > img { width: 100%; flex: 1 1 auto; min-height: 0; border-radius: var(--r-8); object-fit: cover; }
.weight-row { background: #FFFFFF; border-radius: var(--r-8); padding: 8px 12px; display: flex; align-items: center; gap: 12px; }

/* 4.23–4.27 Calendar */
.event-card { background: var(--bg-neutral); border-radius: var(--r-12); padding: 4px; display: flex; flex-direction: column; gap: 4px; }
.event-card__main { background: #FFFFFF; border-radius: var(--r-8); padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.event-card__note { background: #FFFFFF; border-radius: var(--r-8); padding: 12px 16px; display: flex; gap: 12px; color: var(--text-muted); font-size: var(--fs-body2); line-height: var(--lh-body2); }
.date-tile { width: 56px; height: 56px; border-radius: var(--r-8); background: var(--accent); display: flex; flex-direction: column; overflow: hidden; flex: none; text-align: center; }
.date-tile__m { height: 20px; padding: 4px 8px 2px; font-size: var(--fs-label4); line-height: var(--lh-label4); font-weight: 500; color: var(--primary); }
.date-tile__d { flex: 1; background: var(--bg-neutral); padding: 8px; font-size: var(--fs-label1); line-height: var(--lh-label1); font-weight: 500; }
.event-chip { display: inline-flex; align-items: center; gap: 2px; padding: 2px; background: var(--bg-neutral); border-radius: var(--r-24); align-self: flex-start; }
.event-chip__icon { width: 24px; height: 20px; padding: 4px 6px; border-radius: var(--r-24); display: inline-flex; }
.event-chip__text { background: #FFFFFF; border-radius: var(--r-24); padding: 2px 8px; font-size: var(--fs-label3); line-height: var(--lh-label3); font-weight: 500; color: var(--primary); white-space: nowrap; }
.event-chip--activity .event-chip__icon { background: var(--c-lime-deep); color: #FFFFFF; }
.event-chip--meal .event-chip__icon { background: var(--c-lime-muted); color: var(--c-lime-ink); }
.event-chip--appointment .event-chip__icon { background: var(--c-lime-pale); color: var(--c-lime-ink); }
.sched-item { background: var(--bg-neutral); border-radius: var(--r-16); padding: 4px; display: flex; flex-direction: column; gap: 4px; flex: 1 1 0; min-width: 0; }
.cal-event { border-radius: var(--r-8); padding: 8px; display: flex; flex-direction: column; gap: 8px; min-width: 0; overflow: hidden; cursor: pointer; }
.cal-event--activity { background: var(--c-lime-deep); color: #FFFFFF; }
.cal-event--activity .cal-event__time { color: var(--c-gray-soft); }
.cal-event--meal { background: var(--c-lime-light); color: var(--text); }
.cal-event--appointment { background: var(--c-lime-pale); color: var(--text); }
.cal-event__time { font-size: var(--fs-body4); line-height: var(--lh-body4); color: var(--text-muted); }
.cal-event__icon { width: 20px; height: 20px; padding: 4px; border-radius: 50%; background: #FFFFFF; color: var(--c-lime-ink); display: inline-flex; }
.cal-event--mini { border-radius: var(--r-4); padding: 4px; }
.mcal { display: grid; grid-template-columns: repeat(7, 1fr); }
.mcal__dow { height: 40px; display: flex; align-items: center; justify-content: center; font-size: var(--fs-body2); color: var(--text-muted); }
.mcal__day { height: 40px; padding: 4px; display: flex; align-items: center; justify-content: center; }
.mcal__day > span { width: 32px; height: 32px; border-radius: 32px; display: inline-flex; align-items: center; justify-content: center; font-size: var(--fs-body2); color: var(--text); transition: background var(--dur-fast) var(--ease); }
button.mcal__day:hover > span { background: var(--bg-sunken); }
.mcal__day--off > span { color: var(--text-subtle); }
.mcal__day--event > span { background: var(--bg-neutral); color: var(--primary); font-weight: 500; }
.mcal__day.is-selected > span { background: var(--accent); color: var(--text); }
.mcal__day--today > span { background: var(--primary); color: #FFFFFF; font-weight: 400; }

/* 4.28–4.30 Tables */
.tbl { display: flex; flex-direction: column; min-width: 0; }
.tbl__head, .tbl__row { display: grid; align-items: center; column-gap: 24px; padding: 0 16px; }
.tbl__head { background: var(--bg-sunken); border-radius: var(--r-24); min-height: 40px; padding: 12px 16px; font-size: var(--fs-body2); line-height: var(--lh-body2); color: var(--text-muted); }
.tbl__row { min-height: 72px; padding: 16px; border-bottom: 1px solid var(--border); font-size: var(--fs-body2); line-height: var(--lh-body2); }
.tbl__row:last-child { border-bottom: 0; }
.tbl__sort { display: inline-flex; align-items: center; gap: 4px; color: inherit; white-space: nowrap; }
.tbl__sort > svg { width: 10px; height: 10px; color: var(--text-subtle); }
.tbl__sort.is-asc > svg, .tbl__sort.is-desc > svg { color: var(--text); } /* D1: specs say #222222 (C3) */
.tbl--diary .tbl__head { border-radius: var(--r-pill); min-height: 56px; padding: 8px 16px; }
.tbl-scroll { overflow-x: auto; scrollbar-width: thin; }
.pill-stats { display: flex; gap: 2px; padding: 2px; background: var(--bg-neutral); border-radius: var(--r-24); }
.pill-stats > span { flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; gap: 2px; height: 24px; padding: 4px 8px; background: #FFFFFF; border-radius: var(--r-24); white-space: nowrap; }
.qty { display: inline-flex; align-items: center; gap: 2px; padding: 2px; background: var(--bg-neutral); border-radius: var(--r-24); }
.qty__stepper { display: inline-flex; align-items: center; gap: 4px; padding: 2px; background: #FFFFFF; border-radius: var(--r-24); }
.qty__value { width: 48px; text-align: center; font-size: var(--fs-body2); }
.qty__unit { height: 24px; padding: 4px 8px; background: #FFFFFF; border-radius: var(--r-24); color: var(--text-muted); font-size: var(--fs-body2); line-height: var(--lh-body2); }

/* =====================================================================
   Overlays: modal + toast
   ===================================================================== */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal__backdrop { position: absolute; inset: 0; background: var(--backdrop); animation: vf-fade var(--dur-med) var(--ease); }
.modal__card {
  position: relative; width: min(480px, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--bg-surface); border-radius: var(--r-20); padding: 24px;
  display: flex; flex-direction: column; gap: 20px; animation: vf-pop var(--dur-med) var(--ease);
}
.modal__card--wide { width: min(640px, 100%); }
.modal__head { display: flex; align-items: center; gap: 16px; }
.modal__title { flex: 1 1 0; font-size: var(--fs-h4); line-height: var(--lh-h4); font-weight: 500; }
.modal__body { display: flex; flex-direction: column; gap: 16px; }
.modal__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 480px) { .modal__grid { grid-template-columns: 1fr; } }
.modal__foot { display: flex; justify-content: flex-end; gap: 12px; }
@keyframes vf-fade { from { opacity: 0; } }
@keyframes vf-pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: var(--c-gray-dark); color: #FFFFFF; border-radius: var(--r-24); padding: 10px 16px;
  font-size: var(--fs-body2); line-height: var(--lh-body2); max-width: min(480px, calc(100vw - 32px)); text-align: center;
  box-shadow: 0 6px 20px rgba(34,34,34,.18); animation: vf-pop var(--dur-med) var(--ease);
  transition: opacity var(--dur-med) var(--ease), transform var(--dur-med) var(--ease);
}
.toast.is-leaving { opacity: 0; transform: translateY(6px); }

/* Auth / bare screens helper: full-page white */
.page-white { background: #FFFFFF; min-height: 100vh; }
