/* ---------- base ---------- */
:root {
  --bg: #f8f6fc;                 /* pastel lavender-tinted ivory */
  --panel: #ffffff;
  --ink: #2c2640;
  --muted: #7c7396;
  --accent: #9b8ad6;             /* pastel lavender */
  --accent-dark: #6f5fb0;
  --accent-deep: #4f4384;
  --accent-soft: #efeafa;
  --gold: #c9975e;               /* premium warm accent */
  --gold-soft: #faf1e2;
  --border: #e6e1f2;
  --warn-bg: #fdf6e8;
  --warn-border: #e0bf76;
  --info-bg: #f1eef9;
  --info-border: #c3b6e3;
  --success-bg: #efeafa;
  --success-border: #a897d9;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(20, 32, 26, 0.05), 0 4px 14px rgba(20, 32, 26, 0.05);
  --shadow-md: 0 2px 4px rgba(20, 32, 26, 0.06), 0 10px 30px rgba(20, 32, 26, 0.09);
  --font-display: "Montserrat", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-body: "Montserrat", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must always win over component display rules. The
   browser's UA stylesheet sets `[hidden] { display: none }`, but any author
   rule with equal specificity that sets `display` (e.g. `.field { display:
   flex }`) overrides it per normal cascade order, silently defeating
   `el.hidden = true`. Force it here so JS-toggled visibility always works. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em; }

.app-header {
  background: linear-gradient(120deg, var(--accent-deep) 0%, var(--accent) 70%, #c3b3ea 100%);
  color: #fff;
  padding: 0.65rem 2rem;
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.header-brand { flex: 1; min-width: 0; }
.app-header h1 { margin: 0; font-size: 1.3rem; font-weight: 600; display: flex; align-items: center; gap: 0.4rem; }
.header-logo { display: block; flex-shrink: 0; }
.tagline { margin: 0.05rem 0 0; opacity: 0.82; font-size: 0.85rem; letter-spacing: 0.02em; }
@media (max-width: 600px) {
  .tagline { display: none; }
  .app-header { padding: 0.65rem 1rem; }
}

.app-footer {
  padding: 1.25rem 2rem 1.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}
.app-footer .privacy-note {
  color: var(--accent-dark);
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ---------- login screen (two-panel: marketing + sign-in) ---------- */
.login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  overflow-y: auto;
}
.login-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  width: 100%;
  max-width: 1020px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  margin: auto;
}

/* left: marketing panel */
.marketing-panel {
  background: linear-gradient(150deg, var(--accent-deep) 0%, var(--accent) 65%, #c3b3ea 100%);
  color: #fff;
  padding: 1.75rem 2.25rem 1.25rem;
  display: flex;
  flex-direction: column;
}
.marketing-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.1rem;
}
.marketing-logo { display: block; width: 28px; height: 28px; flex-shrink: 0; }
.marketing-name { font-weight: 700; font-size: 1.1rem; letter-spacing: 0.01em; }
.marketing-panel h1 {
  margin: 0 0 0.5rem;
  font-size: 1.55rem;
  line-height: 1.25;
  font-weight: 700;
}
.marketing-sub {
  margin: 0 0 1.1rem;
  font-size: 0.9rem;
  line-height: 1.55;
  opacity: 0.88;
  max-width: 36ch;
}

/* dynamic infographic: auto-rotating feature spotlight */
.feature-carousel {
  position: relative;
  min-height: 108px;
  margin-bottom: 0.75rem;
}
.feature-slide {
  position: absolute;
  inset: 0 0 auto;
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  opacity: 0;
  animation: feature-cycle 25s infinite;
  animation-delay: calc(var(--slide) * 5s);
}
.feature-icon { font-size: 1.6rem; line-height: 1; margin-top: 0.15rem; }
.feature-slide h3 { margin: 0 0 0.2rem; font-size: 0.95rem; font-weight: 600; }
.feature-slide p { margin: 0; font-size: 0.82rem; line-height: 1.5; opacity: 0.85; }
@keyframes feature-cycle {
  0%        { opacity: 0; transform: translateY(10px); }
  2%, 18%   { opacity: 1; transform: translateY(0); }
  20%, 100% { opacity: 0; transform: translateY(-8px); }
}
.carousel-dots {
  position: absolute;
  bottom: -0.9rem;
  left: 1rem;
  display: flex;
  gap: 0.4rem;
}
.carousel-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  animation: dot-cycle 25s infinite;
  animation-delay: calc(var(--slide) * 5s);
}
@keyframes dot-cycle {
  0%        { background: rgba(255, 255, 255, 0.3); }
  2%, 18%   { background: #fff; }
  20%, 100% { background: rgba(255, 255, 255, 0.3); }
}
@media (prefers-reduced-motion: reduce) {
  .feature-slide { animation: none; opacity: 1; position: static; }
  .feature-slide + .feature-slide { margin-top: 0.5rem; }
  .feature-carousel { min-height: 0; }
  .carousel-dots { display: none; }
}

.marketing-stats {
  list-style: none;
  display: flex;
  gap: 0.6rem;
  padding: 0;
  margin: 1.3rem 0 0;
  flex-wrap: wrap;
}
.marketing-stats li {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  font-size: 0.78rem;
  white-space: nowrap;
}
.marketing-stats strong { font-size: 0.9rem; margin-right: 0.25rem; color: #f3d9a4; }

.marketing-legal {
  margin: auto 0 0;
  padding-top: 0.9rem;
  font-size: 0.75rem;
  opacity: 0.75;
  display: flex;
  flex-wrap: wrap;
  row-gap: 0.2rem;
  gap: 0.5rem;
}
.marketing-legal a { color: #fff; text-decoration: underline; }
.marketing-legal a:hover { opacity: 0.85; }

/* right: login panel */
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0;
  padding: 1.25rem 2rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0;
}
.login-brand {
  text-align: center;
  margin-bottom: 1rem;
}
.login-logo { width: 48px; height: 48px; display: block; margin: 0 auto 0.15rem; }
.login-brand h1 {
  margin: 0 0 0.1rem;
  font-size: 1.4rem;
  color: var(--accent-dark);
}
.login-brand p { margin: 0; color: var(--muted); font-size: 0.82rem; }

.login-error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.85rem;
  font-size: 0.85rem;
  color: #b91c1c;
  margin-bottom: 0.6rem;
}
.login-error.login-info {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--accent-dark);
}

.login-form { display: flex; flex-direction: column; gap: 0; }
.login-form .field { margin-bottom: 0.6rem; }

.login-forgot { text-align: right; margin: -0.35rem 0 0.5rem; }
.login-forgot .btn-link { font-size: 0.78rem; font-weight: 500; }

.login-form .btn { margin-top: 0.25rem; width: 100%; border-radius: var(--radius-sm); }

/* Visually hidden but present for screen readers (used for the feature
   carousel's static text equivalent, since the animated version is
   aria-hidden). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.login-toggle {
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.6rem 0 0;
}
.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  font-size: inherit;
  padding: 0;
  text-decoration: underline;
  font-family: inherit;
}
.btn-link:hover { color: var(--accent-dark); }

.login-privacy {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0.4rem 0 0;
}

.login-legal {
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0.5rem 0 0;
}
.login-legal a { color: var(--accent); }
.login-legal a:hover { color: var(--accent-dark); }

.footer-links a { color: var(--accent); }
.footer-links a:hover { color: var(--accent-dark); }
.footer-links span { margin: 0 0.35rem; }

/* ---------- legal pages (terms.html / privacy.html) ---------- */
.legal-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}
.legal-page h1 { font-size: 1.6rem; color: var(--accent-dark); margin: 0 0 0.25rem; }
.legal-updated { color: var(--muted); font-size: 0.8rem; margin: 0 0 1.5rem; }
.legal-page h2 { font-size: 1.05rem; margin: 1.5rem 0 0.4rem; color: var(--accent-dark); }
.legal-page p, .legal-page li { font-size: 0.92rem; line-height: 1.65; }
.legal-page a { color: var(--accent); }
.legal-page a:hover { color: var(--accent-dark); }
.legal-back {
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.8rem;
  text-decoration: none;
  font-size: 0.82rem;
  white-space: nowrap;
}
.legal-back:hover { background: rgba(255, 255, 255, 0.12); }

/* compact mode: short laptop viewports (e.g. 13" 1080p at 125% scaling) —
   squeeze both panels so the full layout, incl. legal links, fits one screen */
@media (min-width: 761px) and (max-height: 850px) {
  .login-screen { padding: 0.75rem; }
  .marketing-panel { padding: 1.25rem 2rem 1rem; }
  .marketing-brand { margin-bottom: 0.75rem; }
  .marketing-panel h1 { font-size: 1.35rem; }
  .marketing-sub { margin-bottom: 0.85rem; font-size: 0.85rem; }
  .feature-carousel { min-height: 96px; }
  .feature-slide { padding: 0.7rem 0.9rem; }
  .feature-slide p { font-size: 0.78rem; }
  .marketing-stats { margin-top: 1rem; }
  .marketing-stats li { padding: 0.25rem 0.75rem; font-size: 0.74rem; }
  .marketing-legal { padding-top: 0.7rem; }

  .login-card { padding: 1rem 1.75rem; }
  .login-brand { margin-bottom: 0.5rem; }
  .login-logo { width: 36px; height: 36px; margin-bottom: 0; }
  .login-brand h1 { font-size: 1.2rem; }
  .login-brand p { font-size: 0.78rem; }
  .login-form .field { margin-bottom: 0.45rem; }
  .login-card .field label { margin-bottom: 0.2rem; font-size: 0.84rem; }
  .login-card .field input { padding: 0.48rem 0.7rem; font-size: 0.9rem; }
  .login-card .btn.large { padding: 0.52rem 2rem; font-size: 0.92rem; }
  .login-divider { margin: 0.45rem 0 0.4rem; }
  .login-toggle { margin: 0.45rem 0 0; font-size: 0.8rem; }
  .login-privacy { margin: 0.3rem 0 0; font-size: 0.72rem; }
  .login-legal { margin: 0.35rem 0 0; font-size: 0.7rem; }
}

/* stacked layout on small screens: sign-in first, marketing below */
@media (max-width: 760px) {
  .login-layout {
    grid-template-columns: minmax(0, 1fr);
    max-width: 480px;
  }
  .login-card { order: -1; border-left: 1px solid var(--border); }
  .marketing-panel { padding: 1.75rem 1.5rem 1.25rem; }
  .marketing-panel h1 { font-size: 1.4rem; }
  .marketing-panel h1 br { display: none; }
  .marketing-legal { padding-top: 1rem; }
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.6rem 0 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
}
.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.google-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: #fff;
  color: #3c4043;
  border: 1px solid #dadce0;
  font-weight: 500;
  transition: box-shadow 0.15s, background 0.15s;
}
.google-btn:hover {
  background: #f8f9fa;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.google-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ── header user chip ── */
.header-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.header-username {
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
}
.header-logout {
  font-size: 0.75rem;
  padding: 0.32rem 0.75rem;
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.9);
}
.header-logout:hover { background: rgba(255,255,255,0.25); border-color: rgba(255,255,255,0.5); color: #fff; }
@media (max-width: 640px) { .header-user { display: none; } }

/* sign-out in mobile dropdown */
.nav-drop-divider {
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin: 0.2rem 0;
}
.nav-drop-logout { color: rgba(255,255,255,0.6); font-size: 0.9rem; }
.nav-drop-logout:hover { color: #fff; background: rgba(255,0,0,0.15); }

/* ---------- tab navigation (in header) ---------- */
.tab-nav {
  display: flex;
  gap: 0.2rem;
  padding: 0.2rem;
  background: rgba(255,255,255,0.15);
  border-radius: 999px;
  flex-shrink: 0;
}

.tab-btn {
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.8);
  padding: 0.4rem 1.1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}
.tab-btn.active {
  background: rgba(255,255,255,0.95);
  color: var(--accent-dark);
}
.tab-btn:hover:not(.active) { color: #fff; background: rgba(255,255,255,0.2); }
@media (max-width: 640px) {
  .tab-nav { display: none; }
}

/* ---------- hamburger button (mobile only) ---------- */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0.45rem 0.55rem;
  flex-shrink: 0;
  transition: background 0.15s;
}
.nav-hamburger:hover { background: rgba(255,255,255,0.25); }
.nav-hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform 0.22s ease, opacity 0.22s ease;
}
.nav-hamburger[aria-expanded="true"] span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.nav-hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-hamburger[aria-expanded="true"] span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }
@media (max-width: 640px) { .nav-hamburger { display: flex; } }

/* ---------- mobile nav dropdown ---------- */
.nav-dropdown {
  position: fixed;
  top: var(--header-height, 60px);
  left: 0;
  right: 0;
  z-index: 195;
  background: var(--accent-deep);
  display: none;
  flex-direction: column;
  box-shadow: 0 6px 24px rgba(0,0,0,0.3);
  border-top: 1px solid rgba(255,255,255,0.1);
}
.nav-dropdown.open { display: flex; }
@media (min-width: 641px) { .nav-dropdown { display: none !important; } }

.nav-drop-btn {
  background: none;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.8);
  padding: 1rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-body);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  letter-spacing: 0.01em;
}
.nav-drop-btn:last-child { border-bottom: none; }
.nav-drop-btn.active {
  color: #fff;
  background: rgba(255,255,255,0.12);
  border-left: 3px solid rgba(255,255,255,0.7);
  padding-left: calc(1.5rem - 3px);
}
.nav-drop-btn:hover:not(.active) { background: rgba(255,255,255,0.1); color: #fff; }

/* dropdown overlay backdrop (closes dropdown on outside tap) */
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 194;
  background: transparent;
}
.nav-backdrop.open { display: block; }

.tab-panel[hidden] { display: none; }

/* ---------- preferences section (Row 1) ---------- */
.preferences-section {
  margin: 1rem 2rem 0;
}
@media (max-width: 860px) { .preferences-section { margin: 0.75rem 1rem 0; } }

.preferences-section h2 { margin: 0 0 0.85rem; font-size: 1.1rem; }

.prefs-fields {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.65rem 1rem;
  align-items: start;
}
.prefs-fields .field { margin-bottom: 0; }
@media (max-width: 1060px) { .prefs-fields { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px)  { .prefs-fields { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 440px)  { .prefs-fields { grid-template-columns: 1fr; } }

/* calorie calculator full-width below the fields grid */
.preferences-section .calorie-calc { margin-top: 0.85rem; }

/* ---------- generate-row (Row 3) ---------- */
.generate-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  padding: 1.1rem 2rem;
  flex-wrap: wrap;
}
.btn.large { font-size: 0.98rem; padding: 0.7rem 2rem; }
@media (max-width: 860px) { .generate-row { padding: 0.9rem 1rem; } }
@media (max-width: 480px) {
  .generate-row { flex-direction: column; gap: 0.5rem; }
  .generate-row .btn { width: 100%; justify-content: center; }
}

/* ---------- menu section (Row 4) ---------- */
.menu-section {
  padding: 0 2rem 1.25rem;
}
@media (max-width: 860px) { .menu-section { padding: 0 1rem 1rem; } }

.menu-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.menu-header h2 { margin: 0; }

.panel {
  background: var(--panel);
  border: 1px solid rgba(231, 227, 216, 0.6);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow-sm);
}
.panel h2 { margin-top: 0; font-size: 1.2rem; }

/* ---------- form ---------- */
.field { margin-bottom: 1.05rem; display: flex; flex-direction: column; }
.field label { font-weight: 600; font-size: 0.88rem; margin-bottom: 0.3rem; }
.field small { color: var(--muted); margin-top: 0.25rem; font-size: 0.78rem; }

.field input,
.field select {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 107, 79, 0.15);
}

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.btn {
  padding: 0.6rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s, background 0.15s;
}
.btn:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 3px 10px rgba(30, 107, 79, 0.3);
}
.btn.primary:hover { box-shadow: 0 5px 16px rgba(30, 107, 79, 0.4); }
.btn.small { font-size: 0.8rem; padding: 0.42rem 0.85rem; }
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
  transform: none;
}

.notify-row { margin-top: 1rem; }

/* ---------- calorie calculator ---------- */
.calorie-calc {
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: #fcfbf8;
}
.calorie-calc summary {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--accent-dark);
  user-select: none;
  list-style: none;
}
.calorie-calc summary::-webkit-details-marker { display: none; }
.calorie-calc summary::before {
  content: '▶ ';
  font-size: 0.7rem;
  transition: transform 0.15s;
  display: inline-block;
}
.calorie-calc[open] summary::before { transform: rotate(90deg); }

.calc-body {
  padding: 0.6rem 0.75rem 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.calc-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.calc-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.calc-field label { font-weight: 600; color: var(--muted); font-size: 0.78rem; }
.calc-field input,
.calc-field select {
  padding: 0.42rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 0.85rem;
  background: #fff;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.calc-field input:focus,
.calc-field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 107, 79, 0.15);
}

.input-unit-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.3rem;
}
.input-unit-row select { width: auto; }

.calc-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.2rem;
  flex-wrap: wrap;
}
.calc-result {
  font-size: 0.82rem;
  color: var(--accent-dark);
  font-weight: 600;
}

.meta { margin-top: 1rem; font-size: 0.85rem; color: var(--muted); }
.meta p { margin: 0.25rem 0; }
.rule-note { color: var(--accent-dark); }

/* ---------- alerts ---------- */
.alert-area { padding: 0 2rem; }
@media (max-width: 860px) { .alert-area { padding: 0 1rem; } }

.alert {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
}
.alert-info { background: var(--info-bg); border-color: var(--info-border); }
.alert-warning { background: var(--warn-bg); border-color: var(--warn-border); }
.alert-success { background: var(--success-bg); border-color: var(--success-border); }

.alert-close {
  border: none;
  background: none;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  color: inherit;
}

/* ---------- calorie progress bar ---------- */
.calorie-bar {
  height: 6px;
  background: #eeebe2;
  border-radius: 999px;
  overflow: hidden;
  margin: 0.25rem 0 0.45rem;
}
.calorie-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}
.bar-good { background: linear-gradient(90deg, #2a8c63, #4caf82); }
.bar-warn { background: linear-gradient(90deg, #cf9713, #e6b23c); }
.bar-over { background: linear-gradient(90deg, #b03a2e, #cd5c50); }

/* ---------- day macros ---------- */
.day-macros {
  margin: 0 0 0.55rem;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* ---------- swap button ---------- */
.swap-btn {
  border: none;
  background: none;
  cursor: pointer;
  color: #b6c2ba;
  font-size: 1rem;
  line-height: 1;
  padding: 0.25rem 0.35rem;
  border-radius: 50%;
  flex-shrink: 0;
  min-width: 32px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s, transform 0.2s;
}
.swap-btn:hover, .swap-btn:focus-visible {
  color: var(--accent);
  background: var(--accent-soft);
  outline: none;
  transform: rotate(90deg);
}

/* ---------- shopping section (hidden — code kept for future use) ---------- */
.shopping-section {
  /* Visibility is controlled entirely by the `hidden` attribute (see the
     global `[hidden]` rule above) — this used to force `display: none
     !important` unconditionally here, which meant the section could never
     be shown even after JS cleared `hidden`. */
  padding: 0;
  margin: 0 2rem;
}
@media (max-width: 860px) { .shopping-section { margin: 0 1rem; } }

.shopping-inner {
  background: var(--panel);
  border: 1px solid rgba(231, 227, 216, 0.6);
  border-radius: var(--radius);
  padding: 0.8rem 1.4rem;
  box-shadow: var(--shadow-sm);
}

#shopping-accordion > summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  cursor: pointer;
  list-style: none;
  padding: 0.25rem 0;
}
#shopping-accordion > summary::-webkit-details-marker { display: none; }
#shopping-accordion > summary::before {
  content: '▶';
  font-size: 0.7rem;
  color: var(--muted);
  display: inline-block;
  transition: transform 0.15s;
}
#shopping-accordion[open] > summary::before { transform: rotate(90deg); }
#shopping-accordion > summary h2 {
  margin: 0;
  font-size: 1.1rem;
}
.shopping-count {
  font-size: 0.8rem;
  color: var(--gold);
  font-weight: 600;
  background: var(--gold-soft);
  border-radius: 999px;
  padding: 0.1rem 0.65rem;
}

/* ---------- shopping list ---------- */
.shopping-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.shopping-checklist {
  margin: 0 0 0.75rem;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.15rem 1rem;
}
.shopping-checklist li {
  display: flex;
  align-items: center;
}
.shopping-checklist label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  font-size: 0.87rem;
  padding: 0.22rem 0;
  border-radius: 6px;
  transition: color 0.15s;
}
.shopping-checklist label:hover { color: var(--accent-dark); }
.shopping-checklist input[type=checkbox] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}
.shopping-checklist li.checked label {
  text-decoration: line-through;
  color: var(--muted);
}

.staples-details {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.staples-details summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 0.35rem;
  list-style: none;
}
.staples-details summary::-webkit-details-marker { display: none; }
.staples-details summary::before { content: '▶ '; font-size: 0.65rem; }
.staples-details[open] summary::before { content: '▼ '; }

.staples-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.staples-list li {
  background: #f4f1e9;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.12rem 0.65rem;
  font-size: 0.78rem;
  color: var(--muted);
}

/* ---------- cuisine guide ---------- */
.shopping-guide-note {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0 0 0.65rem;
  font-style: italic;
}
.shopping-guide-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.shopping-guide-list li {
  background: var(--accent-light);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.18rem 0.75rem;
  font-size: 0.82rem;
  color: var(--accent-dark);
  font-weight: 500;
}

/* ---------- modal macros ---------- */
.modal-macros {
  font-size: 0.82rem;
  color: var(--accent-dark);
  font-weight: 600;
  margin: 0.1rem 0 0.8rem;
}

/* ---------- history section ---------- */
.history-section {
  padding: 0 2rem 1.5rem;
}
@media (max-width: 860px) { .history-section { padding: 0 1rem 1.25rem; } }

.history-inner {
  background: var(--panel);
  border: 1px solid rgba(231, 227, 216, 0.6);
  border-radius: var(--radius);
  padding: 0.8rem 1.4rem;
  box-shadow: var(--shadow-sm);
}

#history-accordion > summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  list-style: none;
  padding: 0.25rem 0;
}
#history-accordion > summary::-webkit-details-marker { display: none; }
#history-accordion > summary::before {
  content: '▶';
  font-size: 0.7rem;
  color: var(--muted);
  display: inline-block;
  transition: transform 0.15s;
}
#history-accordion[open] > summary::before { transform: rotate(90deg); }
#history-accordion > summary h2 {
  margin: 0;
  font-size: 1.1rem;
}
.history-count {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: normal;
}
.history-note {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0.25rem 0 0.75rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.history-empty {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}

.history-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  background: #fcfbf8;
}

.history-card-hdr {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}
.history-card-hdr strong { font-size: 0.9rem; }
.history-profile { color: var(--muted); }
.history-avg { color: var(--accent-dark); font-weight: 600; }
.history-warn-badge {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  font-size: 0.75rem;
  cursor: default;
}

.history-meals > summary {
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--accent-dark);
  font-weight: 600;
  list-style: none;
}
.history-meals > summary::-webkit-details-marker { display: none; }

.history-meal-grid {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  overflow-x: auto;
}
.history-day-row {
  display: grid;
  grid-template-columns: 36px repeat(4, 1fr);
  gap: 0.3rem;
  font-size: 0.75rem;
  align-items: start;
}
.history-day-name {
  font-weight: 700;
  color: var(--muted);
  padding-top: 0.1rem;
}
.history-meal-cell {
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 600px) {
  .history-day-row {
    grid-template-columns: 36px 1fr 1fr;
    grid-template-rows: auto auto;
  }
  .history-day-name { grid-row: 1 / 3; }
  .history-meal-cell:nth-child(3) { grid-column: 2; }
  .history-meal-cell:nth-child(4) { grid-column: 3; }
  .history-meal-cell:nth-child(5) { grid-column: 2; }
  .history-meal-cell:nth-child(6) { grid-column: 3; }
}

/* ---------- weekly plan grid (day rows) ---------- */
.week-label { color: var(--muted); font-size: 0.88rem; font-style: italic; }

.plan-grid {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 3rem 1rem;
  font-size: 0.95rem;
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* Each day is a horizontal row: [day info] [breakfast] [lunch] [dinner] [snack] */
.day-row {
  display: grid;
  grid-template-columns: 155px 1fr;
  border: 1px solid rgba(231, 227, 216, 0.8);
  border-radius: var(--radius);
  background: #fdfcf9;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.day-row:hover { box-shadow: var(--shadow-md); }
.day-row.today {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent), var(--shadow-sm);
  background: #fff;
}

/* Left column: day name, calorie bar, totals */
.day-info {
  padding: 0.85rem 1rem;
  border-right: 1px solid var(--border);
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.2rem;
}
.day-row.today .day-info { background: var(--accent-soft); }

.day-info h3 {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.today-chip {
  background: linear-gradient(135deg, var(--gold) 0%, #d4a94a 100%);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 0.08rem 0.52rem;
  box-shadow: 0 2px 6px rgba(185, 139, 47, 0.35);
  flex-shrink: 0;
}

.day-total {
  font-size: 0.76rem;
  color: var(--accent-dark);
  font-weight: 700;
  margin: 0;
}
.day-macros {
  font-size: 0.66rem;
  color: var(--muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin: 0;
}

/* Right side: 4 meal columns */
.day-meals-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.meal-col {
  padding: 0.7rem 0.85rem;
  border-left: 1px solid var(--border);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-height: 88px;
}
.meal-col-filled {
  cursor: pointer;
  transition: background 0.15s;
}
.meal-col-filled:hover,
.meal-col-filled:focus-visible {
  background: var(--accent-soft);
  outline: none;
}
.meal-col-header {
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.15rem;
}
.meal-name {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink);
  flex: 1;
  line-height: 1.3;
  padding-right: 1.6rem; /* space for swap btn */
}
.meal-kcal {
  font-size: 0.73rem;
  color: var(--accent-dark);
  font-weight: 600;
}
.meal-col .swap-btn {
  position: absolute;
  top: 0.4rem;
  right: 0.3rem;
  min-width: 26px;
  min-height: 26px;
  font-size: 0.82rem;
}
.meal-col-empty {
  font-size: 0.8rem;
  color: #b3473e;
  font-style: italic;
  margin-top: 0.2rem;
}

/* Responsive: tablet — stack to 2×2 meal columns */
@media (max-width: 860px) {
  .day-row { grid-template-columns: 110px 1fr; }
  .day-meals-grid { grid-template-columns: repeat(2, 1fr); }
  .meal-col:nth-child(1),
  .meal-col:nth-child(2) { border-bottom: 1px solid var(--border); }
  .meal-col:nth-child(3) { border-left: none; }
  .meal-col-header { font-size: 0.6rem; }
  .meal-name { font-size: 0.8rem; }
}

/* Responsive: mobile — day info on top, meals 2×2 */
@media (max-width: 600px) {
  .day-row { grid-template-columns: 1fr; }
  .day-info {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0.6rem 0.9rem;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
  }
  .day-info h3 { margin: 0; }
  .day-info .calorie-bar { flex: 1; min-width: 80px; margin: 0; }
  .day-meals-grid { grid-template-columns: repeat(2, 1fr); }
  .meal-col:nth-child(1) { border-left: none; }
  .meal-col:nth-child(3) { border-left: none; border-top: 1px solid var(--border); }
  .meal-col:nth-child(4) { border-top: 1px solid var(--border); }
  .meal-col:nth-child(1),
  .meal-col:nth-child(2) { border-bottom: none; }
}

/* ---------- shopping list (container inside accordion) ---------- */
.shopping-list { margin-top: 0.6rem; }

/* ---------- recipe detail modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 26, 20, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1rem;
  padding-top: calc(var(--header-height, 72px) + 0.75rem);
  overflow-y: auto;
  z-index: 500;
}
.modal-overlay[hidden] { display: none; }

.modal {
  position: relative;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1.6rem;
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.modal h2 { margin: 0 0.5rem 0.25rem 0; font-size: 1.3rem; }
.modal-meta { color: var(--muted); font-size: 0.85rem; margin: 0 0 1rem; }

.modal-section { margin-top: 1rem; }
.modal-section h3 { margin: 0 0 0.4rem; font-size: 0.98rem; }

.modal-ingredients,
.modal-steps {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.9rem;
}
.modal-ingredients li,
.modal-steps li { margin-bottom: 0.3rem; }
.modal-ingredients .staple-ingredient { color: var(--muted); }

.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  border: none;
  background: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0.2rem 0.5rem;
  border-radius: 50%;
  transition: color 0.15s, background 0.15s;
}
.modal-close:hover { color: var(--ink); background: var(--accent-soft); }

/* ---------- daily tracker ---------- */
.tracker-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  padding: 1.25rem 2rem;
  align-items: start;
}
@media (max-width: 860px) {
  .tracker-layout { grid-template-columns: 1fr; padding: 1rem; }
}

.tracker-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}
.tracker-top h2 { margin: 0 0 0.15rem; font-size: 1.2rem; }
.tracker-date-label { margin: 0; color: var(--muted); font-size: 0.85rem; font-style: italic; }

.tracker-meals {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.tracker-meal-row {
  display: grid;
  grid-template-columns: 90px 1fr 80px;
  gap: 0.5rem;
  align-items: center;
}
@media (max-width: 480px) {
  .tracker-meal-row {
    grid-template-columns: 1fr;
    gap: 0.3rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed var(--border);
  }
}
.tracker-meal-label {
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.tracker-name-input,
.tracker-cal-input {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: #fff;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.tracker-cal-input { text-align: right; }
@media (max-width: 480px) { .tracker-cal-input { text-align: left; } }
.tracker-name-input:focus,
.tracker-cal-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 107, 79, 0.15);
}

.tracker-summary { margin-bottom: 1rem; }
.tracker-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.3rem;
}
.tracker-total-text { font-weight: 700; font-size: 1.1rem; font-family: var(--font-display); }
.tracker-status { font-size: 0.85rem; font-weight: 600; }
.tracker-status.status-good  { color: #6f5fb0; }
.tracker-status.status-under { color: #a1770f; }
.tracker-status.status-over  { color: #b03a2e; }
.tracker-bar { height: 9px; }

.tracker-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.tracker-week-note {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0 0 0.75rem;
}
.tracker-week {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.tracker-week-row {
  display: grid;
  grid-template-columns: 70px 1fr auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: #fdfcf9;
  transition: box-shadow 0.15s;
}
.tracker-week-row:hover { box-shadow: var(--shadow-sm); }
.tracker-today-row {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.tracker-week-date {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.tracker-week-date span { color: var(--muted); font-size: 0.72rem; }
.tracker-week-total { font-weight: 600; }
.tracker-week-status { font-size: 0.78rem; font-weight: 600; text-align: right; }
.tracker-week-status.status-good  { color: #6f5fb0; }
.tracker-week-status.status-under { color: #a1770f; }
.tracker-week-status.status-over  { color: #b03a2e; }
@media (max-width: 480px) {
  .tracker-week-row { grid-template-columns: 60px 1fr auto; font-size: 0.78rem; }
}
.tracker-no-target {
  margin-top: 0.6rem;
  font-size: 0.78rem;
  color: var(--muted);
}

/* ---------- analytics tab ---------- */
.an-layout {
  padding: 1rem 2rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
@media (max-width: 860px) { .an-layout { padding: 0.75rem 1rem 1.5rem; } }

.an-section { /* panel class handles card look */ }

.an-heading {
  margin: 0 0 0.1rem;
  font-size: 1rem;
  color: var(--accent-dark);
}
.an-section-note {
  margin: 0 0 0.8rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.an-empty {
  color: var(--muted);
  font-size: 0.87rem;
  text-align: center;
  padding: 1.2rem 0 0.4rem;
}

/* KPI cards */
.an-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
  margin-top: 0.75rem;
}
@media (max-width: 860px) { .an-summary { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 440px) { .an-summary { grid-template-columns: 1fr 1fr; } }

.an-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-left: 4px solid var(--border);
  padding: 0.8rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}
.an-card-good    { border-left-color: var(--accent); }
.an-card-warn    { border-left-color: #f59e0b; }
.an-card-over    { border-left-color: #e57373; }
.an-card-neutral { border-left-color: #b0b8b4; }
.an-card-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.an-card-value { font-size: 1.45rem; font-weight: 700; color: var(--ink); line-height: 1.1; }
.an-card-sub   { font-size: 0.75rem; color: var(--muted); }

/* Two-column below chart */
.an-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.1rem;
}
@media (max-width: 680px) { .an-two-col { grid-template-columns: 1fr; } }

/* Calorie bar chart */
.an-chart-inner {
  display: flex;
  gap: 0.4rem;
  height: 190px;
  margin-top: 0.5rem;
}
.an-y-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 34px;
  font-size: 0.67rem;
  color: var(--muted);
  text-align: right;
  flex-shrink: 0;
  padding-bottom: 1.6rem; /* aligns with bar base */
}
.an-bars-area {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
}
.an-target-line {
  position: absolute;
  left: 0; right: 0;
  border-top: 2px dashed var(--accent);
  opacity: 0.65;
  pointer-events: none;
  z-index: 2;
}
.an-bars-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  height: 100%;
  gap: 0.2rem;
  border-bottom: 1px solid var(--border);
  flex: 1;
}
.an-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  height: 100%;
  justify-content: flex-end;
  gap: 0.25rem;
  min-width: 0;
}
.an-bars-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  width: 100%;
  height: 100%;
}
.an-bar {
  border-radius: 4px 4px 0 0;
  width: 13px;
  transition: height 0.35s ease;
  flex-shrink: 0;
}
.an-bar-planned            { background: #cde5d8; }
.an-bar-logged.bar-good    { background: var(--accent); }
.an-bar-logged.bar-warn    { background: #f59e0b; }
.an-bar-logged.bar-over    { background: #e57373; }
.an-bar-label {
  font-size: 0.65rem;
  text-align: center;
  color: var(--muted);
  line-height: 1.25;
  white-space: nowrap;
}
.an-bar-label strong { display: block; color: var(--ink); font-weight: 600; font-size: 0.7rem; }
.an-bar-label span   { display: block; }
.an-chart-legend {
  display: flex;
  gap: 1.1rem;
  align-items: center;
  font-size: 0.73rem;
  color: var(--muted);
  margin-top: 0.55rem;
  justify-content: center;
}
.an-leg-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 3px;
}
.an-leg-dot.planned { background: #cde5d8; }
.an-leg-dot.logged  { background: var(--accent); }
.an-leg-dash {
  display: inline-block;
  width: 16px; height: 2px;
  border-top: 2px dashed var(--accent);
  vertical-align: middle;
  margin-right: 3px;
  opacity: 0.75;
}

/* Macro donut */
.an-macro-chart {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-top: 0.5rem;
}
@media (max-width: 440px) { .an-macro-chart { flex-direction: column; gap: 0.75rem; } }
.an-donut { width: 110px; height: 110px; flex-shrink: 0; }
.an-macro-legend { display: flex; flex-direction: column; gap: 0.55rem; flex: 1; }
.an-macro-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.82rem; }
.an-macro-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.an-macro-name { flex: 1; color: var(--ink); font-weight: 500; }
.an-macro-val  { color: var(--muted); font-size: 0.76rem; }

/* Meal completion */
.an-meal-completion { display: flex; flex-direction: column; gap: 0.65rem; margin-top: 0.5rem; }
.an-completion-row  { display: flex; align-items: center; gap: 0.65rem; font-size: 0.82rem; }
.an-completion-label { width: 128px; flex-shrink: 0; color: var(--ink); }
.an-completion-bar-wrap {
  flex: 1; height: 7px;
  background: #e8e4d9;
  border-radius: 999px;
  overflow: hidden;
}
.an-completion-bar {
  height: 100%; background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.an-completion-pct { width: 36px; text-align: right; color: var(--muted); font-size: 0.76rem; flex-shrink: 0; }

/* Week glance grid */
.an-glance-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-top: 0.5rem;
}
@media (max-width: 680px) { .an-glance-grid { grid-template-columns: repeat(2, 1fr); } }
.an-glance-stat { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.2rem; }
.an-glance-num  { font-size: 1.9rem; font-weight: 700; color: var(--accent-dark); text-transform: capitalize; line-height: 1; }
.an-glance-lbl  { font-size: 0.75rem; color: var(--muted); }
