/* ==========================================================================
   MACRITION - Modern Professional Design System.0
   Brighter palette, glassmorphism cards, frosted modals, clean typography
   ========================================================================== */

/* (S108) Global hidden-attribute guard. The HTML spec: elements with the
   hidden attribute are not rendered. But ANY author display rule (class or
   id) overrides the UA stylesheet's [hidden]{display:none} - which is how
   the food-detail diary dialog (.fd-dialog-backdrop{display:flex}) shipped
   VISIBLE on page load and could never be closed by Cancel/OK: the JS sets
   hidden=true, the CSS keeps display:flex. This guard restores the spec
   semantics corpus-wide. Show/hide via hidden + removeAttribute('hidden')
   (e.g. footer-social) is fully compatible: once the attribute is gone the
   rule no longer matches. */
[hidden] { display: none !important; }

/* ==========================================================================
   ENHANCEMENT Polish, accessibility, micro-interactions
   ========================================================================== */

/* ==========================================================================
   THEME PRESETS Sepia, High-Contrast, Colorblind-friendly
   Switch via: document.documentElement.setAttribute('data-theme', 'sepia')
   ========================================================================== */

/* ==========================================================================
.0 PROFESSIONAL NUTRITION DISPLAY ENHANCEMENTS
   ========================================================================== */

/* ==========================================================================
.1 FRONTEND POLISH - Alignment, Spacing, Readability Fixes
   ========================================================================== */

/* ==========================================================================
.0 UNIVERSAL PROFESSIONAL UPGRADE
   Inspired by: Cronometer, Healthline, Examine.com, NIH ODS, Mayo Clinic
   Focus: Trust signals, data clarity, visual hierarchy, accessibility
   ========================================================================== */

/* ==========================================================================
.1 PROFESSIONAL APP STYLING
   ========================================================================== */

/* ==========================================================================
    SMOOTH TRANSITIONS & POLISH
   ========================================================================== */

/* ==========================================================================
.0 PROFESSIONAL NAVIGATION SYSTEM
   ========================================================================== */

/* ==========================================================================
.1 PROFESSIONAL NAVIGATION - Compact, Polished, Responsive
   ========================================================================== */

:root {
  /* === MACRITION BRAND PALETTE.0 === */
  /* Balanced tri-color from logo: green (nature) + blue (science) + orange (energy) */
  /* Primary = blue (trust, science, professional) - the anchoring color */
  /* Accent = green (health, growth, nutrition) - the secondary brand color */
  /* Tertiary = orange (energy, vitality) - used sparingly for CTAs/warnings */
  --macrition-green: #22C55E;
  --macrition-deep-green: #16A34A;
  --macrition-orange: #F97316;
  --macrition-gold: #FFC107;
  --macrition-blue: #2563EB;
  --macrition-navy: #0F172A;

  --bg: #F8FAFC;
  --bg-soft: #F1F5F9;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --surface-3: #F1F5F9;
  --primary: #2563EB;
  --primary-text: #2563EB; /* (D-039) the text-role companion: curated per theme; dark steps to blue-400 */
  --primary-d: #1D4ED8;
  --primary-l: #60A5FA;
  --primary-50: #EFF6FF;
  --primary-100: #DBEAFE;
  --accent: #22C55E;
  --accent-d: #16A34A;
  --accent-l: #4ADE80;
  --accent-50: #F0FDF4;
  --accent-100: #DCFCE7;
  --amber: #F59E0B;
  --amber-l: #FCD34D;
  --amber-50: #FFFBEB;
  --amber-100: #FEF3C7;
  --info: #2563EB;
  --info-l: #60A5FA;
  --info-50: #EFF6FF;
  --info-100: #DBEAFE;
  --rose: #F43F5E;
  --rose-l: #FB7185;
  --rose-50: #FFF1F2;
  --text: #0F172A;
  --text-2: #1E293B;
  --text-3: #334155;
  --text-muted: #64748B;
  --border: #E2E8F0;
  --border-control: #64748B; /* (D-040) form-control boundary: 4.76:1 on surface */
  --border-control-hover: #475569; /* (D-040) 7.58:1 */
  --border-2: #CBD5E1;
  --border-light: #F1F5F9;
  --shadow-xs: 0 1px 2px rgba(17,24,39,.04);
  --shadow-sm: 0 2px 4px rgba(17,24,39,.04),0 1px 2px rgba(17,24,39,.06);
  --shadow-md: 0 4px 8px rgba(17,24,39,.04),0 2px 4px rgba(17,24,39,.06);
  --shadow-lg: 0 12px 24px rgba(17,24,39,.06),0 4px 8px rgba(17,24,39,.04);
  --shadow-xl: 0 24px 48px rgba(17,24,39,.08),0 8px 16px rgba(17,24,39,.06);
  --shadow-2xl: 0 32px 64px rgba(17,24,39,.12);
  --glass-bg: rgba(255,255,255,.72);
  --glass-border: rgba(255,255,255,.5);
  --glass-blur: 16px;
  --r-xs: 4px;
  --r-sm: 8px;
  --r: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 24px;
  --r-2xl: 32px;
  --r-pill: 999px;
  --container: 1200px;
  --container-narrow: 800px;
  --font-sans: "Inter",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
  --font-serif: "Fraunces",Georgia,"Times New Roman",serif;
  --font-mono: "JetBrains Mono",ui-monospace,monospace;
}

[data-theme="dark"] {
  --bg: #0F172A;
  --bg-soft: #1E293B;
  --surface: #1E293B;
  --surface-2: #334155;
  --surface-3: #475569;
  --primary-50: #172554;
  --primary-100: #1E3A8A;
  --primary-text: #60A5FA; /* (D-039) dark text companion: 7.02:1 on --bg / 5.75:1 on --surface */
  --accent-50: #052E16;
  --accent-100: #064E3B;
  --amber-50: #451A03;
  --rose-50: #4C0519;
  --text: #F8FAFC;
  --text-2: #E2E8F0;
  --text-3: #CBD5E1;
  --text-muted: #94A3B8;
  --border: #334155;
  --border-2: #475569;
  --border-light: #1E293B;
  --border-control: #94A3B8; /* (D-040) dark boundary: 5.71:1 */
  --border-control-hover: #A3B2C7; /* 6.79:1 */
  --glass-bg: rgba(30,41,59,.78);
  --glass-border: rgba(168,179,204,.22);
  --shadow-xs: 0 1px 2px rgba(0,0,0,.28);
  --shadow-sm: 0 2px 4px rgba(0,0,0,.30),0 1px 2px rgba(0,0,0,.32);
  --shadow-md: 0 4px 8px rgba(0,0,0,.32),0 2px 4px rgba(0,0,0,.30);
  --shadow-lg: 0 12px 24px rgba(0,0,0,.38),0 4px 8px rgba(0,0,0,.30);
  --shadow-xl: 0 24px 48px rgba(0,0,0,.44),0 8px 16px rgba(0,0,0,.36);
  --shadow-2xl: 0 32px 64px rgba(0,0,0,.52);
}

/* ==========================================================================
   SMOOTH THEME TRANSITION 
   Adds a 0.3s ease transition on background-color, color, and border-color
   to ALL elements so switching themes (light <-> dark) animates smoothly.

   This `*` rule has specificity (0,0,0) so ANY selector that sets its own
   `transition` shorthand (e.g. `button`, `.btn`, `.tool-card:hover`,
   `a { transition: color.15s }` - all of which already exist in this file)
   fully overrides it. Therefore hover/click transitions are NOT affected -
   only elements without an explicit transition get the smooth theme fade.

   `prefers-reduced-motion` users get no transition (see line ~5658).
   ========================================================================== */
/* Theme transition: only applied to specific elements, not ALL elements.
   The universal `*` selector caused text-color disappearing glitches
   when CSS variables changed during dynamic updates. */
body, .site-header, .admin-topbar, .admin-sidebar, .card, .tool-card,
.glass-surface, .stat-card, .admin-card, .ai-bubble, .ai-sidebar,
.wizard-card, .btn, .admin-btn, input, select, textarea, .badge,
.pricing-card, .blog-card, .faq-item, .goal-card {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, fill 0.3s ease;
}

/* Extra emphasis layer - toggled by JS for ~350ms during theme switches.
   Scoped to major container elements to avoid the universal-selector
   performance hit and text-disappearing glitch. */
html.theme-transitioning body,
html.theme-transitioning .site-header,
html.theme-transitioning .admin-topbar,
html.theme-transitioning .admin-sidebar,
html.theme-transitioning .card,
html.theme-transitioning .tool-card,
html.theme-transitioning .glass-surface,
html.theme-transitioning .stat-card,
html.theme-transitioning .admin-card,
html.theme-transitioning .ai-bubble,
html.theme-transitioning .ai-sidebar,
html.theme-transitioning .wizard-card,
html.theme-transitioning .btn,
html.theme-transitioning .admin-btn,
html.theme-transitioning input,
html.theme-transitioning select,
html.theme-transitioning textarea,
html.theme-transitioning .badge,
html.theme-transitioning .pricing-card,
html.theme-transitioning .blog-card,
html.theme-transitioning .faq-item,
html.theme-transitioning .goal-card {
  transition: background-color 0.3s ease, color 0.3s ease,
              border-color 0.3s ease, fill 0.3s ease, stroke 0.3s ease !important;
}

/* ==========================================================================
   AUTO DARK MODE - prefers-color-scheme: dark with no explicit user choice
   Mirrors the [data-theme="dark"] variable set so users who haven't picked
   a theme via the toggle get a dark UI automatically. CSS-only - no JS
   needed. The:root:not([data-theme]) guard ensures that once a user picks
   any theme (which sets the data-theme attribute on <html>), this block
   is bypassed and their explicit choice wins.
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    /* (S95) palette truth: this block claims to mirror the
       [data-theme="dark"] set, but the values had drifted onto a private
       indigo family (#1A1B2E...) - the same visitor could see two
       different "darks" depending on whether the toggle had ever been
       touched. Aligned to the canonical slate tokens (identical values),
       shadows included, so OS-auto-dark and toggle-dark are one theme. */
    --bg: #0F172A;
    --bg-soft: #1E293B;
    --surface: #1E293B;
    --surface-2: #334155;
    --surface-3: #475569;
    --primary-50: #172554;
    --primary-100: #1E3A8A;
    --primary-text: #60A5FA; /* (D-039) OS-dark mirror companion */
    --accent-50: #052E16;
    --accent-100: #064E3B;
    --amber-50: #451A03;
    --rose-50: #4C0519;
    --text: #F8FAFC;
    --text-2: #E2E8F0;
    --text-3: #CBD5E1;
    --text-muted: #94A3B8;
    --border: #334155;
    --border-2: #475569;
    --border-light: #1E293B;
    --border-control: #94A3B8;
    --border-control-hover: #A3B2C7;
    --glass-bg: rgba(30,41,59,.78);
    --glass-border: rgba(168,179,204,.22);
    --shadow-xs: 0 1px 2px rgba(0,0,0,.28);
    --shadow-sm: 0 2px 4px rgba(0,0,0,.30),0 1px 2px rgba(0,0,0,.32);
    --shadow-md: 0 4px 8px rgba(0,0,0,.32),0 2px 4px rgba(0,0,0,.30);
    --shadow-lg: 0 12px 24px rgba(0,0,0,.38),0 4px 8px rgba(0,0,0,.30);
    --shadow-xl: 0 24px 48px rgba(0,0,0,.44),0 8px 16px rgba(0,0,0,.36);
    --shadow-2xl: 0 32px 64px rgba(0,0,0,.52);
    color-scheme: dark;
  }
}

*,*::before,*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-padding-top: 72px;
  scroll-behavior: smooth;
}

body {
  overflow-x: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  animation: pageFadeIn 0.3s ease;
}

img,svg {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color:var(--primary-text);
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

a:hover {
  color: var(--primary-d);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: 0;
  background: none;
}

input,select,textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  box-sizing: border-box;
  min-height: 44px;
}

/* Exclude checkboxes/radios from the 44px min-height (would create giant controls) */
input[type="checkbox"], input[type="radio"] {
  min-height: 0;
}

ul,ol {
  list-style: none;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 24px);
}

.container-narrow {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 24px;
}

.section {
  padding: clamp(32px, 8vw, 64px) 0;
}

.section-sm {
  padding: 40px 0;
  padding-top: 8px;
  margin-bottom: 48px;
}

.section-lg {
  padding: 96px 0;
}

h1,h2,h3,h4 {
  font-family: var(--font-sans);
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
  line-height: 1.2;
}

h1 {
  letter-spacing: -.03em;
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 800;
}

h2 {
  font-size: clamp(24px, 3vw, 32px);
}

h3 {
  font-size: clamp(18px, 2vw, 22px);
}

h4 {
  font-weight: 600;
  font-size: 16px;
}

p {
  margin-bottom: 1em;
  line-height: 1.7;
}

.lead {
  font-weight: 400;
  font-size: 17px;
  line-height: 1.6;
  color: var(--text-3);
  max-width: 720px;
}

.eyebrow {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 10px;
  color:var(--primary-text);
}

.text-muted {
  color: var(--text-muted);
}

.text-center {
  text-align: center;
}

.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;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-bottom: 1px solid var(--border);
  transition: box-shadow 0.2s ease;
}

.site-header .container {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 100%;
  flex-wrap: nowrap;
}

/* NOTE: Do NOT set overflow on.site-header - it clips nav dropdowns.
   Horizontal overflow prevention is handled by body { overflow-x: hidden; } */

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 19px;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-serif);
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.brand:hover {
  color:var(--primary-text);
}

.brand-mark {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease;
}

.brand-mark svg {
  width: 19px;
  height: 19px;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 1px;
  min-width: 0;
}

.main-nav>a {
  padding: 8px 14px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  transition: all .15s;
  white-space: nowrap;
}

/* ============================================================
 * Dashboard-style flat nav (direct <a> children carrying an
 * inline.nav-icon SVG) - see dashboard/includes/header.php.
 * The public site nests links inside.nav-item wrappers (rules
 * elsewhere in this file); the flat dashboard pattern needs its
 * own sizing or the SVGs default to their intrinsic ~76px and
 * blow the header up to 115px tall with wrapped labels.
 * ============================================================ */
.main-nav>a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.main-nav>a>.nav-icon {
  width: 15px;
  height: 15px;
  flex: none;
  opacity: .65;
  transition: opacity .15s ease;
}

.main-nav>a:hover>.nav-icon,
.main-nav>a.active>.nav-icon {
  opacity: 1;
}

.main-nav>a:hover {
  color:var(--primary-text);
  background: var(--primary-50);
}

.main-nav>a.active {
  color:var(--primary-text);
  background: var(--primary-50);
}


.nav-cta {
  background: var(--primary);
  color: #fff;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: 14px;
  transition: all .15s;
}

.nav-cta:hover {
  background: var(--primary-d);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.menu-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  color: var(--text);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.menu-toggle:hover {
  background: var(--surface-3);
}

.menu-toggle svg {
  width: 20px;
  height: 20px;
}

/* ---- Header auth area (JS-rendered #navAuth) -------------------------
   The user chip (premium badge + avatar + name + admin pill + caret) is
   rendered by auth.js with inline styles. These class-based rules give
   the header room to breathe on narrow screens: below the hamburger
   breakpoint the name text and the admin shortcut collapse away (both
   remain available inside the user menu), so the bar never overflows
   or clips on phones. */
.nav-auth {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
@media (max-width: 980px) {
  .nav-auth .nav-user-name,
  .nav-auth .nav-admin-link {
    display: none !important;
  }
  .nav-auth .nav-user-wrap {
    gap: 4px;
  }
}
@media (max-width: 480px) {
  .site-header .container {
    gap: 8px;
  }
  .nav-auth .premium-badge {
    display: none !important;
  }
  .header-actions .theme-toggle {
    width: 32px;
    height: 32px;
  }
  .header-actions {
    gap: 4px;
  }
  /* ( UI-1) Logged-out phones: brand 119 + Log In/Sign Up 151 +
     bell/theme/hamburger 114 + gaps exceeded the 390px viewport by ~22px
     (horizontal page overflow). Compact CTA buttons + tighter action
     gaps clear it. NOTE: refined-polish.css carries a similar rule but
     is not loaded by any page - design-system.css is the live owner. */
  .nav-auth .btn,
  .nav-auth .btn-sm {
    padding: 6px 10px;
    font-size: 12.5px;
  }
}


.btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: 14px;
  border: 1.5px solid transparent;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  white-space: nowrap;
  /* S105: a button label must never be shaved by a tight flex row.
     nowrap+overflow:hidden resolve min-width:auto to 0, letting flex
     shrink the control under its own label ("Search" cut to 49px).
     Buttons keep their label; sibling inputs/rows absorb the space,
     and any genuinely unavoidable squeeze ellipsizes cleanly. */
  flex-shrink: 0;
  text-overflow: ellipsis;
  font-family: inherit;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--primary), var(--primary-d));
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, .2);
}

.btn-primary:hover {
  background: var(--primary-d);
  box-shadow: 0 6px 20px rgba(79, 70, 229, .3);
  transform: translateY(-1px);
  color: #fff;
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-d));
  color: #fff;
  box-shadow: 0 2px 8px rgba(16, 185, 129, .2);
}

.btn-accent:hover {
  background: var(--accent-d);
  box-shadow: 0 6px 20px rgba(16, 185, 129, .3);
  transform: translateY(-1px);
  color: #fff;
}

.btn-dark {
  background: var(--text);
  color: #fff;
}

.btn-dark:hover {
  background: var(--text-2);
  color: #fff;
  transform: translateY(-1px);
}

.btn-ghost {
  background: var(--surface);
  color: var(--text-2);
  border-color: var(--border-2);
}

.btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--primary);
  color:var(--primary-text);
}

.btn-light {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-light:hover {
  background: var(--surface-2);
}

.btn-sage {
  background: linear-gradient(135deg, var(--accent), var(--accent-d));
  color: #fff;
}

.btn-sage:hover {
  background: var(--accent-d);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
}

.btn-block {
  display: flex;
  width: 100%;
}

.card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
  padding: 24px;
  transition: all .2s ease;
  box-shadow: var(--shadow-sm);
}

.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-l);
}

.card-solid {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 16px;
}

.tool-card {
  background: var(--surface);
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 22px;
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: all .25s cubic-bezier(.4, 0, .2, 1);
  position: relative;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-xs);
  animation: slideUp .35s ease backwards;
}

@media (max-width:480px) {
  .tool-card {
    padding: 16px;
  }
}

.tool-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .3s ease;
}

.tool-card:hover {
  color: var(--text);
  transform: translateY(-3px);
  box-shadow: var(--shadow-xl);
  border-color: var(--primary-l);
}

.tool-card:hover::before {
  transform: scaleX(1);
}

.tool-card .icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: var(--text-3);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

/* (v8.20.2) Soft-tint icon chips - the contextual multi-color icon set
   needs a quiet stage, not a saturated block: each category keeps its
   hue identity via an 8-12% wash + hairline border. Alpha-based washes
   work in both themes. */
.tool-card .icon.terracotta,.tool-card .icon.primary {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 16%, transparent);
}

.tool-card .icon.sage,.tool-card .icon.accent {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
}

.tool-card .icon.mustard,.tool-card .icon.amber {
  background: color-mix(in srgb, var(--amber) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber) 24%, transparent);
}

.tool-card .icon.berry,.tool-card .icon.rose {
  background: color-mix(in srgb, var(--rose) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--rose) 16%, transparent);
}

.tool-card .icon.azure {
  background: color-mix(in srgb, var(--info) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--info) 18%, transparent);
}

.tool-card h3 {
  font-size: 16px;
  margin-bottom: 6px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.tool-card .meta {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.tool-card p {
  font-size: 13px;
  color: var(--text-3);
  flex: 1;
  line-height: 1.5;
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tool-card .arrow {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color:var(--primary-text);
  font-weight: 600;
  font-size: 13px;
}

.tool-card .arrow svg {
  transition: transform .15s ease;
  width: 14px;
  height: 14px;
}

.tool-card:hover .arrow svg {
  transform: translateX(3px);
}

.goal-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.goal-card {
  padding: 28px 24px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: all .25s ease;
  display: block;
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}

.goal-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-l);
  color: var(--text);
}

.goal-card .emoji {
  font-size: 22px;
  margin-bottom: 8px;
  display: block;
}

.goal-card h3 {
  font-size: 20px;
  margin-bottom: 6px;
  color: var(--text);
  font-weight: 700;
}

.goal-card p {
  font-size: 14px;
  color: var(--text-3);
  line-height: 1.5;
  margin: 0;
}

.goal-card .tools-count {
  font-size: 12px;
  font-weight: 600;
  color:var(--primary-text);
  margin-top: 14px;
  display: block;
}

.hero {
  position: relative;
  padding: 64px 0 56px;
  overflow: hidden;
  background: var(--surface);
}

.hero-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 800px 600px at 20% 0%, var(--primary-50), transparent 60%),
    radial-gradient(ellipse 600px 400px at 80% 100%, var(--accent-50), transparent 60%);
  opacity: 0.6;
  pointer-events: none;
}

.hero .container {
  position: relative;
  z-index: 1;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 48px;
  align-items: center;
}

.hero h1 {
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 16px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.hero h1 em {
  color:var(--primary-text);
  font-style: normal;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
}

.hero .lead {
  margin-bottom: 28px;
  max-width: 560px;
  font-size: 18px;
  line-height: 1.6;
  color: var(--text-3);
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.hero-stats {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.hero-stat strong {
  display: block;
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.02em;
}

.hero-stat span {
  line-height: 1.3;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
  display: block;
}

.hero-visual {
  position: relative;
}

.hero-card-stack {
  position: relative;
  max-width: 420px;
  margin: 0 auto;
}

.hero-card {
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  animation: scaleIn .5s ease .1s backwards;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow-xl);
}

.macro-rings {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 20px 0;
}

.macro-ring {
  text-align: center;
}

.macro-ring svg {
  width: 72px;
  height: 72px;
  margin: 0 auto 6px;
  display: block;
}

.macro-ring .label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.macro-ring .value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.hero-mini-card {
  animation: slideUp .4s ease .3s backwards;
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 16px;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  z-index: 2;
}

.hero-mini-card .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.hero-mini-card.tl {
  top: -16px;
  left: -16px;
}

.hero-mini-card.br {
  bottom: -16px;
  right: -16px;
}

.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  line-height: 1.5;
}

.breadcrumb a {
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: var(--r-sm);
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
}

.breadcrumb a:hover {
  color:var(--primary-text);
  background: var(--primary-50);
}

.breadcrumb .sep {
  color: var(--border-2);
  margin: 0 2px;
  user-select: none;
}

.breadcrumb .current {
  color: var(--text-2);
  padding: 4px 8px;
  font-weight: 500;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 40px;
  align-items: start;
  padding: 32px 0 64px;
}

.tool-main h1 {
  margin-bottom: 12px;
}

.calc-widget {
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
  box-shadow: var(--shadow-md);
}

.calc-widget h2 {
  font-size: 18px;
  margin-bottom: 6px;
  font-weight: 700;
  color: var(--text);
}

.calc-widget .widget-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.form-grid.full {
  grid-column: 1/-1;
}

.form-group {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  align-items: center;
  gap: 4px;
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  line-height: 1.4;
  margin-bottom: 2px;
}

.form-group input,.form-group select,.form-group textarea {
  padding: 10px 14px;
  border: 1.5px solid var(--border-control);
  border-radius: var(--r-sm);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s ease,box-shadow .15s ease,background .15s ease;
}

.form-group input:focus,.form-group select:focus,.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-50);
}

.form-group .hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.form-group .unit {
  position: relative;
}

.form-group .unit input {
  padding-right: 42px;
}

.form-group .unit::after {
  content: attr(data-unit);
  position: absolute;
  right: 14px;
  bottom: 11px;
  font-size: 12px;
  color: var(--text-muted);
  pointer-events: none;
  font-weight: 500;
}

.radio-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.radio-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface);
  transition: all .15s ease;
  white-space: nowrap;
  user-select: none;
}

.radio-pill input {
  margin: 0;
}

.radio-pill:hover {
  border-color: var(--primary-l);
  background: var(--primary-50);
}

.radio-pill.active {
  transform: translateY(-1px);
  background: linear-gradient(135deg, var(--primary), var(--primary-d));
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, .2);
}

.segmented {
  display: inline-flex;
  background: var(--surface-3);
  border-radius: var(--r-sm);
  padding: 3px;
  gap: 2px;
}

.segmented button {
  padding: 7px 14px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all .15s ease;
}

.segmented button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

.results {
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  margin-top: 24px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  display: none;
}

.results.show {
  display: block;
  animation: resultsSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.results h3 {
  font-size: 13px;
  color: var(--accent-d);
  margin-bottom: 18px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.result-item {
  text-align: center;
  padding: 18px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: all .2s ease;
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.result-item .value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.result-item .label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.result-bar {
  height: 8px;
  background: var(--surface-3);
  border-radius: 4px;
  overflow: hidden;
  margin: 14px 0;
}

.result-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 4px;
  transition: width .6s cubic-bezier(.4, 0, .2, 1);
}

.result-msg {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.6;
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
}

.tool-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 80px;
  /* (S258-D1) the sticky-rail containment law (mirrors the .pub corpus
     rule): a sticky rail taller than the viewport minus its top offset
     clips its own bottom content forever — the rail scrolls internally
     exactly when it is too tall to stick in full. */
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}

.sidebar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px;
  box-shadow: var(--shadow-xs);
}

.sidebar-card h3 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.sidebar-card ul {
  display: flex;
  flex-direction: column;
  gap: 2px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-card a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  color: var(--text-3);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: all .15s;
  line-height: 1.4;
}

.sidebar-card a:hover {
  background: var(--primary-50);
  color: var(--primary-d);
}

.sidebar-card a svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: .5;
}

.article {
  font-size: 16px;
  line-height: 1.75;
  color: var(--text-2);
  max-width: 720px;
}

.article h2 {
  margin-top: 36px;
  margin-bottom: 14px;
  line-height: 1.3;
  font-size: 26px;
  margin: 36px 0 14px;
  color: var(--text);
  font-weight: 700;
}

.article h3 {
  margin-top: 26px;
  margin-bottom: 10px;
  line-height: 1.35;
  font-size: 20px;
  margin: 26px 0 10px;
  color: var(--text);
  font-weight: 600;
}

.article p {
  text-align: left;
  line-height: 1.75;
  margin-bottom: 16px;
}

.article ul,.article ol {
  margin: 0 0 18px 0;
  padding-left: 22px;
}

.article ul li,.article ol li {
  margin-bottom: 8px;
  list-style: disc;
}

.article ol li {
  list-style: decimal;
}

.article strong {
  color: var(--text);
  font-weight: 600;
}

.article em {
  font-style: italic;
  color: var(--text-3);
}

.article a {
  color:var(--primary-text);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  text-decoration-color: var(--primary-l);
  transition: text-decoration-color .15s ease;
}

.article a:hover {
  text-decoration-color: var(--primary);
}

.article blockquote {
  border-left: 4px solid var(--primary);
  padding: 14px 22px;
  background: linear-gradient(90deg, var(--primary-50), var(--surface));
  margin: 22px 0;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-style: italic;
  color: var(--text-2);
  font-size: 16px;
  line-height: 1.7;
}

.article table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 20px 0;
  font-size: 14px;
  background: var(--surface);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border);
  white-space: normal;
}

.article th,.article td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.article th {
  background: var(--surface-3);
  font-weight: 600;
  color: var(--text);
  font-size: 13px;
}

.article tr:last-child td {
  border-bottom: 0;
}

.article code {
  background: var(--surface-3);
  padding: 2px 7px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.88em;
  color: var(--primary-d);
  font-weight: 500;
}

.faq-list {
  margin-top: 36px;
}

.faq-list h2 {
  margin-bottom: 16px;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: 8px;
  overflow: hidden;
  transition: all .15s ease;
}

.faq-item:hover {
  border-color: var(--primary-l);
}

.faq-q {
  padding: 16px 20px;
  font-weight: 600;
  color: var(--text);
  font-size: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  background: none;
  width: 100%;
  text-align: left;
  border: 0;
  font-family: inherit;
  line-height: 1.4;
}

.faq-q .icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  color:var(--primary-text);
  font-size: 18px;
  transition: all .2s ease;
}

.faq-item.open .faq-q .icon {
  transform: rotate(45deg);
  background: var(--primary);
  color: #fff;
}

.faq-a {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.faq-item.open .faq-a {
  max-height: 600px;
}

.faq-a-inner {
  padding: 0 20px 18px;
  color: var(--text-3);
  font-size: 15px;
  line-height: 1.65;
}

.site-footer {
  background: #0F172A;
  color: #94A3B8;
  padding: 56px 0 24px;
  margin-top: 80px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 36px;
}

.footer-brand .brand {
  color: #fff;
  margin-bottom: 12px;
}

.footer-brand p {
  font-size: 14px;
  color: #64748B;
  line-height: 1.6;
  max-width: 280px;
}

.footer-col h4 {
  font-size: 12px;
  color: #fff;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}

.footer-col ul {
  display: flex;
  flex-direction: column;
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-col a {
  color: #94A3B8;
  font-size: 14px;
  text-decoration: none;
  transition: color .15s;
  line-height: 1.4;
}

.footer-col a:hover {
  color: var(--primary-l);
}

.footer-bottom {
  border-top: 1px solid #1E293B;
  padding-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #64748B;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-social {
  display: flex;
  gap: 8px;
}

.footer-social a {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #1E293B;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94A3B8;
  transition: all .15s ease;
}

.footer-social a:hover {
  background: var(--primary);
  color: #fff;
}

.meal-builder {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 20px;
}

.menu-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px;
  box-shadow: var(--shadow-xs);
}

.menu-search {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 14px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") 12px center no-repeat;
  margin-bottom: 16px;
  transition: all .15s;
  color: var(--text);
}

.menu-search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-50);
}

.menu-section {
  margin-bottom: 16px;
}

.menu-section h4 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 6px;
}

.menu-list::-webkit-scrollbar {
  width: 6px;
}

.menu-list::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: 3px;
}

.menu-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  transition: all .15s ease;
  font-size: 14px;
}

.menu-item:hover {
  border-color: var(--primary);
  background: var(--primary-50);
  transform: translateX(2px);
  box-shadow: var(--shadow-xs);
}

.menu-item .name {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

.menu-item .meta {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  display: flex;
  gap: 8px;
  align-items: center;
}

.tray-panel {
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px;
  position: sticky;
  top: 88px;
  box-shadow: var(--shadow-md);
}

.tray-panel h3 {
  font-size: 16px;
  color: var(--accent-d);
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tray-empty {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 24px 0;
}

.tray-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: 6px;
  font-size: 14px;
  transition: all .15s ease;
}

.tray-item .name {
  flex: 1;
  font-weight: 500;
  color: var(--text);
}

.tray-item .qty {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 12px;
}

.tray-item .qty button {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--text-2);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  border: 0;
  cursor: pointer;
  transition: all .15s;
}

.tray-item .qty button:hover {
  background: var(--primary);
  color: #fff;
}

.tray-item .qty span {
  min-width: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.tray-item .remove {
  background: none;
  color: var(--rose);
  font-size: 18px;
  padding: 0 4px;
  line-height: 1;
  border: 0;
  cursor: pointer;
  transition: all .15s;
}

.tray-totals {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 2px solid var(--border);
}

.tray-totals .row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 14px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.tray-totals .row.calories {
  font-weight: 800;
  font-size: 18px;
  color: var(--text);
  padding: 8px 0;
  border-top: 1px solid var(--border);
  margin-top: 6px;
}

.tray-totals .row.calories span:last-child {
  color:var(--primary-text);
}

.diary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.date-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 4px;
  box-shadow: var(--shadow-xs);
}

.date-nav button {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  border: 0;
  background: none;
  cursor: pointer;
  transition: all .15s;
}

.date-nav button:hover {
  background: var(--surface-3);
}

.date-nav .date {
  padding: 0 12px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.macro-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.macro-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px;
  text-align: center;
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}

.macro-tile .ring {
  width: 64px;
  height: 64px;
  margin: 0 auto 8px;
  position: relative;
}

.macro-tile .ring svg {
  transform: rotate(-90deg);
}

.macro-tile .ring .value {
  line-height: 1;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.macro-tile .label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.macro-tile .target {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================================================
 * FOOD DIARY - complete layer (Phase I fix)
 * ============================================================
 * The diary JS (assets/js/modules/diary.js) renders its summary
 * bar, macro rings and quick-add bar into the DOM, but the CSS
 * for those classes was never written - the bottom of the diary
 * rendered as an unstyled text pile ("0/2000cal Remaining2000")
 * and the ring numbers displayed rotated sideways.
 *
 * Fixes:
 * 1..macro-summary.macro-rings → 4 columns (the generic
 *.macro-rings is 3-col; the diary has 4 rings: cal/P/C/F)
 * 2. Remove the CSS -90° SVG rotation - the JS already rotates
 * the progress arc via an SVG transform attribute; rotating
 * the whole <svg> ALSO rotated the center number sideways.
 * 3. Full styling for.diary-summary-bar /.summary-cal /
 *.cal-value /.summary-remaining /.summary-macro-bar /
 *.macro-bar-legend (previously: no CSS at all).
 * 4..diary-quickadd-bar /.quickadd-btn - the pill action row.
 * ============================================================ */

/* --- 1. Ring grid: 4 columns on desktop, 2 on small screens --- */
.macro-summary.macro-rings {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 20px 0 24px;
}

@media (max-width: 640px) {
  .macro-summary.macro-rings {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}

/* --- 2. Kill the double rotation (JS rotates the arc itself) --- */
.macro-tile .ring svg {
  transform: none;
  width: 84px;
  height: 84px;
  display: block;
  margin: 0 auto;
}

.macro-tile .ring {
  width: auto;
  height: auto;
  margin-bottom: 8px;
}

/* Ring states - subtle tinted card backgrounds */
.macro-tile.ring-ok {
  border-color: var(--accent-100);
}
.macro-tile.ring-close {
  border-color: var(--amber-100);
  background: linear-gradient(180deg, var(--amber-50) 0%, var(--surface) 60%);
}
.macro-tile.ring-over {
  border-color: var(--rose-50);
  background: linear-gradient(180deg, var(--rose-50) 0%, var(--surface) 60%);
}

/* --- 3. Bottom container: sticky summary + quick actions --- */
.diary-bottom-container {
  position: sticky;
  bottom: 16px;
  z-index: 40;
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.diary-summary-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg, 16px);
  padding: 14px 20px;
  box-shadow: var(--shadow-md, 0 8px 24px rgba(15, 23, 42, 0.12));
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}

.summary-cal {
  display: flex;
  align-items: baseline;
  gap: 3px;
  white-space: nowrap;
}

.summary-cal .cal-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.summary-cal .cal-divider {
  font-size: 16px;
  color: var(--text-muted);
  font-weight: 500;
}

.summary-cal .cal-goal {
  font-size: 16px;
  color: var(--text-2);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.summary-cal .cal-unit {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.summary-remaining {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 72px;
}

.summary-remaining .remaining-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.summary-remaining .remaining-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent-d);
  font-variant-numeric: tabular-nums;
}

.summary-remaining .remaining-value.over {
  color: var(--rose);
}

.summary-macro-bar {
  flex: 1;
  min-width: 180px;
}

.summary-macro-bar .macro-bar {
  height: 10px;
  border-radius: 5px;
  margin: 0 0 6px;
  background: var(--surface-3);
}

.macro-bar-legend {
  display: flex;
  gap: 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.macro-bar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.macro-bar-legend i {
  width: 8px;
  height: 8px;
  border-radius: 3px;
  display: inline-block;
}

/* --- 4. Quick-add pill row --- */
.diary-quickadd-bar {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.quickadd-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-xs, 0 1px 3px rgba(15, 23, 42, 0.08));
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.quickadd-btn svg {
  width: 16px;
  height: 16px;
  stroke: var(--primary);
}

.quickadd-btn:hover {
  transform: translateY(-1px);
  border-color: var(--primary-l);
  color: var(--text);
  box-shadow: var(--shadow-sm, 0 2px 8px rgba(15, 23, 42, 0.12));
}

.quickadd-btn:active {
  transform: translateY(0);
}

@media (max-width: 640px) {
  .diary-summary-bar {
    gap: 12px;
    padding: 12px 14px;
  }
  .summary-cal .cal-value {
    font-size: 22px;
  }
  .summary-remaining .remaining-value {
    font-size: 16px;
  }
  .macro-bar-legend {
    gap: 8px;
  }
  .quickadd-btn {
    padding: 9px 14px;
    font-size: 12px;
  }
}

.meal-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}

.meal-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.meal-section-head h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.meal-section-head .total {
  font-size: 14px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.meal-section-head .total strong {
  color: var(--text);
}

.meal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
}

.meal-row:last-child {
  border-bottom: 0;
}

.meal-row .info {
  flex: 1;
  min-width: 0;
}

.meal-row .info .name {
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
  word-break: break-word;
}

.meal-row .info .sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.meal-row .macros {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 200px;
  display: flex;
  gap: 6px;
  text-align: right;
  justify-content: flex-end;
  flex-shrink: 0;
}

.meal-row .macros span {
  min-width: 42px;
}

.meal-row .actions {
  display: flex;
  gap: 4px;
  margin-left: 12px;
}

.meal-row .actions button {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
  transition: all .15s;
  font-weight: 600;
}

.meal-row .actions button:hover {
  background: var(--rose-50);
  color: var(--rose);
}

.empty-meal {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

textarea.form-control {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 14px;
  background: var(--surface);
  font-family: inherit;
  resize: vertical;
  min-height: 120px;
}

textarea.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-50);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--surface-3);
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}

.chip.terracotta,.chip.primary {
  background: var(--primary-50);
  color: var(--primary-d);
}

.chip.sage,.chip.accent {
  background: var(--accent-50);
  color: var(--accent-d);
}

.chip.mustard,.chip.amber {
  background: var(--amber-50);
  color: #92400E;
}

.chip.berry,.chip.rose {
  background: var(--rose-50);
  color: var(--rose);
}

.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.filter-chip {
  padding: 8px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
  font-family: inherit;
}

.filter-chip:hover {
  border-color: var(--primary-l);
  color:var(--primary-text);
  background: var(--primary-50);
}

.filter-chip.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-d));
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, .25);
}

.stat-banner {
  border: 1px solid #374151;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  background: linear-gradient(135deg, #111827, #1a1f2e);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.stat-banner .item {
  padding: 24px;
  text-align: center;
  border-right: 1px solid #1E293B;
  transition: background .2s ease;
}

.stat-banner .item:last-child {
  border-right: 0;
}

.stat-banner .num {
  color: transparent;
  font-size: 30px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-l), var(--accent-l));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}

.stat-banner .lbl {
  font-size: 12px;
  color: #94A3B8;
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.search-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all .15s ease;
}

.search-result:hover {
  border-color: var(--primary);
  background: var(--primary-50);
  transform: translateX(2px);
}

.search-result .info {
  flex: 1;
}

.search-result .name {
  font-weight: 600;
  color: var(--text);
  font-size: 15px;
}

.search-result .meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.search-result .macros {
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  display: flex;
  gap: 10px;
}

.search-result .add-btn {
  margin-left: 12px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--r-sm);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  border: 0;
  cursor: pointer;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state .icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  opacity: 0.35;
}

.empty-state h3 {
  font-size: 17px;
  color: var(--text-2);
  margin-bottom: 6px;
  font-weight: 600;
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 16px;
  line-height: 1.5;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
  animation: modalFadeIn 0.2s ease;
}

.modal {
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-2xl);
  animation: modalSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-head h3 {
  font-size: 17px;
  font-weight: 600;
}

.modal-head .close {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: none;
  border: 0;
  cursor: pointer;
}

.modal-head .close:hover {
  background: var(--surface-3);
  color: var(--text);
}

.modal-body {
  padding: 24px;
}

.modal-foot {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap; /* multiple buttons wrap instead of overflowing on narrow modals */
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: var(--bg);
  padding: 12px 20px;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 500;
  z-index: 1200;
  box-shadow: var(--shadow-xl);
  transition: transform .3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 90vw;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  animation: toastSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast .icon {
  color: var(--accent);
}
/* (S132 N12, D-B2 wave) the canonical module emits kind classes from the
   closed FC-4 vocabulary: toast-warn (not the legacy toast-warning the
   dash-ui era used). The legacy selector stays as a migration alias and
   retires with the legacy sheets (S140); the canonical class is the
   contract the served A-16 CANON row already pins. */
.toast-warning .icon,
.toast-warn .icon { color: #F59E0B !important; }
.toast-error .icon { color: #EF4444 !important; }
.toast-info .icon { color: #3B82F6 !important; }
.toast-upsell .icon { color: #8B5CF6 !important; }

/* (S132 D-B2) the persistent kinds' dismiss control renders the canonical
   "x" SVG through the FC-2 icon bridge — the button is a 24px touch
   target (A-14 floor) and the glyph inherits the toast's contrast. */
.toast .toast-dismiss {
  appearance: none;
  background: none;
  border: 0;
  padding: 4px;
  margin: 0 -6px 0 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex: none;
  color: inherit;
  cursor: pointer;
  border-radius: 6px;
}
.toast .toast-dismiss svg { width: 14px; height: 14px; display: block; }
.toast .toast-dismiss:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; }

/* (S132 FC-4) the upsell action link: same family, no legacy styling. */
.toast .toast-action {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-left: 2px;
  white-space: nowrap;
}
.toast .toast-action:hover { text-decoration: none; }

.chart-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}

.chart-container h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.chart-container .chart-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.chart-canvas {
  width: 100%;
  height: 280px;
}

.log-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.log-table th,.log-table td {
  padding: 12px 14px;
  text-align: left;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.log-table th {
  background: var(--surface-3);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text);
}

.log-table tr:last-child td {
  border-bottom: 0;
}

.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(200px,1fr));
  gap: 16px;
}

.compare-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px;
  box-shadow: var(--shadow-xs);
}

.compare-col .food-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.compare-col .food-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.compare-col .nutrient-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 6px 0;
  border-bottom: 1px dotted var(--border);
}

.compare-col .nutrient-row:last-child {
  border-bottom: 0;
}

.compare-col .nutrient-row .name {
  color: var(--text-3);
}

.compare-col .nutrient-row .val {
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.compare-col .nutrient-row.best {
  background: var(--accent-50);
  margin: 0 -8px;
  padding: 6px 8px;
  border-radius: 4px;
}

.compare-col .nutrient-row.best .val {
  color: var(--accent-d);
}

.cmdk-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
}

.cmdk-overlay.open {
  display: flex;
  animation: cmdkFadeIn 0.15s ease;
}

.cmdk-modal {
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  max-width: 560px;
  width: 90%;
  box-shadow: var(--shadow-2xl);
  overflow: hidden;
  animation: cmdkSlideDown 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.cmdk-input {
  width: 100%;
  padding: 18px 24px;
  border: 0;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
  background: transparent;
  color: var(--text);
  outline: none;
  font-weight: 500;
  font-family: inherit;
}

.cmdk-input::placeholder {
  color: var(--text-muted);
}

.cmdk-results {
  max-height: 400px;
  overflow-y: auto;
  padding: 8px;
}

.cmdk-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  text-decoration: none;
  transition: all .1s;
  gap: 12px;
}

.cmdk-item.selected,.cmdk-item:hover {
  background: var(--primary-50);
  color: var(--primary-d);
}

.cmdk-item-title {
  font-weight: 600;
  font-size: 14px;
}

.cmdk-item-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.cmdk-item-type {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  flex-shrink: 0;
}

.cmdk-empty {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 14px;
}

.cmdk-footer {
  padding: 10px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.cmdk-footer kbd {
  background: var(--surface-3);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.theme-toggle,.cmdk-trigger {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: all .15s;
}

.theme-toggle:hover,.cmdk-trigger:hover {
  background: var(--surface-3);
  color:var(--primary-text);
}

.theme-toggle svg,.cmdk-trigger svg {
  width: 16px;
  height: 16px;
}

.icon-moon {
  display: none;
}

[data-theme="dark"] .icon-sun {
  display: none;
}

[data-theme="dark"] .icon-moon {
  display: block;
}

.cmdk-trigger {
  display: none;
}

.newsletter {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--r-lg);
  padding: 48px;
  color: #fff;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.newsletter h2 {
  color: #fff;
  margin-bottom: 8px;
  position: relative;
}

.newsletter p {
  color: rgba(255,255,255,.9);
  margin-bottom: 24px;
  max-width: 540px;
  margin-left: auto;
  margin-right: auto;
  position: relative;
}

.newsletter form {
  display: flex;
  gap: 8px;
  max-width: 480px;
  margin: 0 auto;
  flex-wrap: wrap;
  position: relative;
}

.newsletter input {
  flex: 1;
  min-width: 200px;
  padding: 13px 16px;
  border: 0;
  border-radius: var(--r-sm);
  font-size: 15px;
  background: #fff;
  color: var(--text);
}

.newsletter input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255,255,255,.3);
}

.newsletter button {
  padding: 13px 24px;
  background: var(--text);
  color: #fff;
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  border: 0;
  transition: all .15s;
}

.newsletter button:hover {
  background: var(--text-2);
  transform: translateY(-1px);
}

.section-head {
  text-align: center;
  max-width: 720px;
  margin: 0 auto 32px;
}

.section-head h2 {
  line-height: 1.3;
  margin-bottom: 10px;
}

.section-head p {
  font-size: 17px;
  color: var(--text-3);
  line-height: 1.5;
}

.section-head.left {
  text-align: left;
  margin: 0 0 32px;
}

@media (max-width:768px) {
  .section-head {
    margin-bottom: 20px;
  }
}

.flex {
  display: flex;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.gap-2 {
  gap: 8px;
}

.gap-3 {
  gap: 12px;
}

.gap-4 {
  gap: 16px;
}

.gap-6 {
  gap: 24px;
}

.mt-2 {
  margin-top: 8px;
}

.mt-4 {
  margin-top: 16px;
}

.mt-6 {
  margin-top: 24px;
}

.mb-2 {
  margin-bottom: 8px;
}

.mb-4 {
  margin-bottom: 16px;
}

.mb-6 {
  margin-bottom: 24px;
}

.text-sm {
  font-size: 13px;
}

.text-xs {
  font-size: 12px;
}

.font-mono {
  font-family: var(--font-mono);
}

.hidden {
  display: none;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 16px;
}

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

.btn:focus-visible,.filter-chip:focus-visible,.radio-pill:focus-visible,.menu-item:focus-visible {
  outline: 2.5px solid var(--primary);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--primary);
  color: #fff;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 0 0 var(--r-sm) 0;
  z-index: 500;
  transition: top .15s;
}

.skip-link:focus {
  top: 0;
  color: #fff;
}

.tool-grid .tool-card:nth-child(1) {
  animation-delay: .02s;
}

.tool-grid .tool-card:nth-child(2) {
  animation-delay: .05s;
}

.tool-grid .tool-card:nth-child(3) {
  animation-delay: .08s;
}

.tool-grid .tool-card:nth-child(4) {
  animation-delay: .11s;
}

.tool-grid .tool-card:nth-child(5) {
  animation-delay: .14s;
}

.tool-grid .tool-card:nth-child(6) {
  animation-delay: .17s;
}

.tool-grid .tool-card:nth-child(7) {
  animation-delay: .20s;
}

.tool-grid .tool-card:nth-child(8) {
  animation-delay: .23s;
}

.tool-grid .tool-card:nth-child(9) {
  animation-delay: .26s;
}

.tool-grid .tool-card:nth-child(n+10) {
  animation-delay: .30s;
}

.glossary-item {
  animation: slideUp .25s ease backwards;
}

.glossary-item:nth-child(n) {
  animation-delay: calc(.02s * var(--i, 0));
}

.results.show .result-item {
  animation: itemPopIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

.results.show .result-item:nth-child(1) {
  animation-delay: 0.05s;
}

.results.show .result-item:nth-child(2) {
  animation-delay: 0.1s;
}

.results.show .result-item:nth-child(3) {
  animation-delay: 0.15s;
}

.results.show .result-item:nth-child(4) {
  animation-delay: 0.2s;
}

.tool-card:active {
  transform: translateY(-2px) scale(.99);
}

.section-sm:not(:first-of-type) {
  border-top: 1px solid var(--border-light);
  padding-top: 40px;
}

.article pre {
  background: #1a1a2e;
  color: #e0e0e0;
  padding: 16px 20px;
  border-radius: var(--r-sm);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  margin: 20px 0;
}

.article pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

[data-theme="dark"] .article code {
  background: var(--surface-3);
  color: var(--primary-l);
}

.article table th {
  background: linear-gradient(180deg,var(--surface-3),var(--surface-2));
  padding: 12px 16px;
  text-align: left;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-2);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.article table tr:hover td {
  background: var(--primary-50);
}

.stat-banner .item:hover {
  background: rgba(255,255,255,.03);
}

.result-item:hover {
  border-color: var(--primary-l);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.form-group input:hover,.form-group select:hover,.form-group textarea:hover {
  border-color: var(--border-control-hover);
}

.btn-primary::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg,transparent,rgba(255,255,255,.2),transparent);
  transition: left .5s ease;
}

.btn-primary:hover::after {
  left: 100%;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: 5px;
  border: 2px solid var(--bg);
  transition: background 0.15s;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

::selection {
  background: var(--primary-100);
  color: var(--text);
}

[data-theme="dark"] ::selection {
  background: rgba(129,140,248,.3);
  color: #fff;
}

[data-theme="dark"] .article blockquote {
  background: linear-gradient(90deg,rgba(129,140,248,.15),var(--surface));
  border-left-color: var(--primary-l);
}

[data-theme="dark"] .stat-banner {
  background: linear-gradient(135deg,#1E293B,#0F172A);
}

.badge-new {
  margin-left: 6px;
  animation: scaleIn .3s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--r-pill);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: middle;
}

.badge-new::before {
  content: "";
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
}

.tool-card[data-new="true"] {
  border-color: var(--accent);
}

.tool-card[data-new="true"]::after {
  content: "NEW";
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  letter-spacing: 0.05em;
}

.goal-hero {
  padding: 48px;
  border-radius: var(--r-lg);
  margin-bottom: 32px;
  text-align: center;
}

.goal-hero h1 {
  margin: 8px 0;
}

.goal-hero .lead {
  max-width: 580px;
  margin: 16px auto 24px;
}

.site-header.scrolled {
  box-shadow: var(--shadow-sm);
}

.site-footer .brand {
  color: #fff;
}

.site-footer .brand-mark {
  background: linear-gradient(135deg,var(--primary),var(--accent));
}

[data-theme="sepia"] {
  --bg: #F4EAD2;
  --bg-soft: #EDE0C2;
  --surface: #FAF1DC;
  --surface-2: #F0E4C8;
  --surface-3: #E5D5B0;
  --primary: #7C4A03;
  --primary-text: #7C4A03; /* (D-039) sepia text companion (passes on sepia surfaces) */
  --primary-d: #5C3702;
  --primary-l: #A86A1A;
  --primary-50: #F5E6CD;
  --primary-100: #EBD2A4;
  --accent: #6B7F3A;
  --accent-d: #4F5F2A;
  --accent-l: #94A55C;
  --accent-50: #EDF0DD;
  --accent-100: #DAE0BC;
  --amber: #B87203;
  --amber-l: #D8941A;
  --amber-50: #F8E9CC;
  --amber-100: #F0D6A0;
  --rose: #A04848;
  --rose-l: #C26868;
  --rose-50: #F2DDDD;
  --text: #3A2810;
  --text-2: #5A4020;
  --text-3: #7A5C38;
  --text-muted: #756139;
  --border: #D9C6A0;
  --border-2: #C9B285;
  --border-light: #E8DCBC;
  --border-control: #9A7A4E; /* (D-040) sepia boundary: 3.55:1 */
  --border-control-hover: #8A6B40; /* 4.39:1 */
  --shadow-xs: 0 1px 2px rgba(58,40,16,.06);
  --shadow-sm: 0 2px 4px rgba(58,40,16,.06),0 1px 2px rgba(58,40,16,.08);
  --shadow-md: 0 4px 8px rgba(58,40,16,.06),0 2px 4px rgba(58,40,16,.08);
  --shadow-lg: 0 12px 24px rgba(58,40,16,.08),0 4px 8px rgba(58,40,16,.06);
  --shadow-xl: 0 24px 48px rgba(58,40,16,.10),0 8px 16px rgba(58,40,16,.08);
  --shadow-2xl: 0 32px 64px rgba(58,40,16,.14);
  --glass-bg: rgba(250,241,220,.85);
  --glass-border: rgba(250,241,220,.6);
  --glass-blur: 12px;
}

[data-theme="high-contrast"] {
  --bg: #FFFFFF;
  --bg-soft: #F5F5F5;
  --surface: #FFFFFF;
  --surface-2: #F0F0F0;
  --surface-3: #E0E0E0;
  --primary: #0000FF;
  --primary-text: #0000FF; /* (D-039) high-contrast text companion */
  --primary-d: #0000CC;
  --primary-l: #3333FF;
  --primary-50: #E6E6FF;
  --primary-100: #CCCCFF;
  --accent: #006600;
  --accent-d: #004400;
  --accent-l: #009900;
  --accent-50: #E6FFE6;
  --accent-100: #CCFFCC;
  --amber: #CC6600;
  --amber-l: #FF9933;
  --amber-50: #FFEBD6;
  --amber-100: #FFD6A8;
  --rose: #CC0000;
  --rose-l: #FF3333;
  --rose-50: #FFE6E6;
  --text: #000000;
  --text-2: #1A1A1A;
  --text-3: #333333;
  --text-muted: #555555;
  --border: #000000;
  --border-control: #000000; /* (D-040) high-contrast boundary (the model) */
  --border-control-hover: #000000;
  --border-2: #333333;
  --border-light: #666666;
  --shadow-xs: 0 0 0 1px #000;
  --shadow-sm: 0 0 0 1px #000;
  --shadow-md: 0 0 0 2px #000;
  --shadow-lg: 0 4px 8px rgba(0,0,0,.3),0 0 0 2px #000;
  --shadow-xl: 0 8px 16px rgba(0,0,0,.4),0 0 0 2px #000;
  --shadow-2xl: 0 16px 32px rgba(0,0,0,.5),0 0 0 2px #000;
  --glass-bg: #FFFFFF;
  --glass-border: #000000;
  --glass-blur: 0px;
}

[data-theme="high-contrast"] .btn {
  border-width: 2px;
  font-weight: 700;
}

[data-theme="high-contrast"] .tool-card,[data-theme="high-contrast"] .card {
  border-width: 2px;
}

[data-theme="high-contrast"] a {
  text-decoration: underline;
}

[data-theme="high-contrast"] .filter-chip.active {
  background: #0000FF;
  color: #FFFFFF;
  border-color: #0000FF;
}

[data-theme="colorblind"] {
  --bg: #F7F8FA;
  --bg-soft: #EEF0F4;
  --surface: #FFFFFF;
  --surface-2: #F9FAFB;
  --surface-3: #F0F2F5;
  /* Use blue/orange instead of red/green which are hard for deuteranopes */
  --primary: #0072B2;
  --primary-text: #0072B2; /* (D-039) colorblind text companion */
  --primary-d: #005485;
  --primary-l: #3399CC;
  --primary-50: #E6F0F8;
  --primary-100: #CCE2F0;
  --accent: #E69F00;
  --accent-d: #A07000;
  --accent-l: #FFB733;
  --accent-50: #FCF0D6;
  --accent-100: #F5E1AD;
  --amber: #E69F00;
  --amber-l: #FFB733;
  --amber-50: #FCF0D6;
  --amber-100: #F5E1AD;
  --rose: #D55E00;
  --rose-l: #EE7E33;
  --rose-50: #FBE6D6;
  --text: #111827;
  --text-2: #374151;
  --text-3: #4B5563;
  --text-muted: #6B7280;
  --border: #E5E7EB;
  --border-2: #D1D5DB;
  --border-light: #F3F4F6;
  --border-control: #64748B; /* (D-040) colorblind boundary */
  --border-control-hover: #475569;
  --shadow-xs: 0 1px 2px rgba(17,24,39,.04);
  --shadow-sm: 0 2px 4px rgba(17,24,39,.04),0 1px 2px rgba(17,24,39,.06);
  --shadow-md: 0 4px 8px rgba(17,24,39,.04),0 2px 4px rgba(17,24,39,.06);
  --shadow-lg: 0 12px 24px rgba(17,24,39,.06),0 4px 8px rgba(17,24,39,.04);
  --shadow-xl: 0 24px 48px rgba(17,24,39,.08),0 8px 16px rgba(17,24,39,.06);
  --shadow-2xl: 0 32px 64px rgba(17,24,39,.12);
  --glass-bg: rgba(255,255,255,.72);
  --glass-border: rgba(255,255,255,.5);
  --glass-blur: 16px;
}

.theme-switcher {
  position: relative;
  display: inline-block;
}

.theme-switcher-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  min-width: 180px;
  z-index: 200;
  display: none;
  margin-top: 4px;
}

.theme-switcher-menu.open {
  display: block;
  animation: scaleIn .15s ease;
}

.theme-switcher-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  background: none;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--r-sm);
  text-align: left;
  transition: all .1s;
}

.theme-switcher-menu button:hover {
  background: var(--surface-3);
  color: var(--text);
}

.theme-switcher-menu button.active {
  background: var(--primary-50);
  color: var(--primary-d);
  font-weight: 600;
}

.theme-switcher-menu button .swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--border-2);
  flex-shrink: 0;
}

.theme-switcher-menu button .swatch.light {
  background: linear-gradient(135deg,#fff 50%,#16A34A 50%);
}

/* Auto (day/night): sun over night sky - the mode resolves by device time */
.theme-switcher-menu button .swatch.auto {
  background: linear-gradient(135deg,#FDE68A 50%,#0F172A 50%);
}

.theme-switcher-menu button .swatch.dark {
  background: linear-gradient(135deg,#0F172A 50%,#818CF8 50%);
}

.theme-switcher-menu button .swatch.sepia {
  background: linear-gradient(135deg,#F4EAD2 50%,#7C4A03 50%);
}

.theme-switcher-menu button .swatch.high-contrast {
  background: linear-gradient(135deg,#fff 50%,#000 50%);
}

.theme-switcher-menu button .swatch.colorblind {
  background: linear-gradient(135deg,#0072B2 50%,#E69F00 50%);
}

.theme-toggle-wrap {
  position: relative;
}

.nutrition-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px;
  transition: all .2s ease;
  position: relative;
  overflow: hidden;
}

.nutrition-card:hover {
  border-color: var(--primary-l);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.nutrition-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg,var(--primary),var(--accent));
  opacity: 0;
  transition: opacity .2s ease;
}

.nutrition-card:hover::before {
  opacity: 1;
}

.nutrition-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.nutrition-card-header .food-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.nutrition-card-header .food-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

.nutrition-card-header .calorie-badge {
  background: linear-gradient(135deg,var(--primary),var(--primary-d));
  color: #fff;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.macro-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin: 10px 0;
  background: var(--surface-3);
}

.macro-bar .seg-protein {
  background: var(--primary);
  transition: width .4s ease;
}

.macro-bar .seg-carbs {
  background: var(--amber);
  transition: width .4s ease;
}

.macro-bar .seg-fat {
  background: var(--rose);
  transition: width .4s ease;
}

.macro-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.macro-bar-labels span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.macro-bar-labels .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.macro-bar-labels .dot.protein {
  background: var(--primary);
}

.macro-bar-labels .dot.carbs {
  background: var(--amber);
}

.macro-bar-labels .dot.fat {
  background: var(--rose);
}

.nutrition-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(100px,1fr));
  gap: 10px;
  margin-top: 12px;
}

.nutrient-cell {
  background: var(--surface-2);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  text-align: center;
  transition: all .15s ease;
}

.nutrient-cell:hover {
  background: var(--surface-3);
  transform: scale(1.02);
}

.nutrient-cell .value {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.nutrient-cell .value.primary {
  color: var(--primary-d);
}

.nutrient-cell .value.accent {
  color: var(--accent-d);
}

.nutrient-cell .value.amber {
  color: var(--amber);
}

.nutrient-cell .value.rose {
  color: var(--rose);
}

.nutrient-cell .unit {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.nutrient-cell .label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: 2px;
  font-weight: 600;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--surface);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.data-table thead {
  background: linear-gradient(180deg,var(--surface-3),var(--surface-2));
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-2);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.data-table th.numeric {
  text-align: right;
}

.data-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.data-table td.numeric {
  text-align: right;
  font-weight: 600;
  color: var(--text);
}

.data-table td.label-cell {
  font-weight: 500;
  color: var(--text);
}

.data-table tbody tr:hover td {
  background: var(--primary-50);
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table .highlight-row td {
  background: var(--accent-50);
  font-weight: 700;
}

.data-table .highlight-row td:first-child {
  border-left: 3px solid var(--accent);
}

.nutrition-label {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 16px 20px;
  max-width: 320px;
  font-size: 13px;
}

.nutrition-label-header {
  border-bottom: 4px solid var(--text);
  padding-bottom: 6px;
  margin-bottom: 8px;
}

.nutrition-label-header h3 {
  font-size: 24px;
  font-weight: 800;
  margin: 0;
  color: var(--text);
}

.nutrition-label-calories {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 4px solid var(--text);
}

.nutrition-label-calories .label {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

.nutrition-label-calories .value {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
}

.nutrition-label-rows {
  padding-top: 4px;
}

.nutrition-label-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.nutrition-label-row.sub {
  padding-left: 16px;
  font-size: 12px;
}

.nutrition-label-row .label {
  font-weight: 600;
  color: var(--text);
}

.nutrition-label-row .value {
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.nutrition-label-row .daily-value {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.progress-ring {
  position: relative;
  display: inline-block;
}

.progress-ring svg {
  transform: rotate(-90deg);
}

.progress-ring .ring-bg {
  fill: none;
  stroke: var(--surface-3);
  stroke-width: 6;
}

.progress-ring .ring-fill {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset .6s cubic-bezier(.4,0,.2,1);
}

.progress-ring .ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.progress-ring .ring-value {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.progress-ring .ring-unit {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all .2s ease;
}

.stat-card:hover {
  border-color: var(--primary-l);
  box-shadow: var(--shadow-sm);
}

.stat-card .icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card .icon-wrap.primary {
  background: var(--primary-50);
  color: var(--primary-d);
}

.stat-card .icon-wrap.accent {
  background: var(--accent-50);
  color: var(--accent-d);
}

.stat-card .icon-wrap.amber {
  background: var(--amber-50);
  color: var(--amber);
}

.stat-card .icon-wrap.rose {
  background: var(--rose-50);
  color: var(--rose);
}

.stat-card .stat-info {
  flex: 1;
  min-width: 0;
}

.stat-card .stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
}

.stat-card .stat-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat-card .stat-trend {
  font-size: 12px;
  font-weight: 600;
  margin-top: 2px;
}

.stat-card .stat-trend.up {
  color: var(--accent-d);
}

.stat-card .stat-trend.down {
  color: var(--rose);
}

.result-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
  padding: 24px;
  margin-top: 20px;
  box-shadow: var(--shadow-md);
}

.result-panel-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent-d);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-panel-title::before {
  content: "";
  width: 4px;
  height: 16px;
  background: var(--accent);
  border-radius: 2px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.badge.good {
  background: var(--accent-50);
  color: var(--accent-d);
}

.badge.warn {
  background: var(--amber-50);
  color: var(--amber);
}

.badge.bad {
  background: var(--rose-50);
  color: var(--rose);
}

.badge.neutral {
  background: var(--surface-3);
  color: var(--text-3);
}

.interpretation-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--r-sm);
  margin: 14px 0;
  font-size: 14px;
  line-height: 1.5;
}

.interpretation-banner.good {
  background: var(--accent-50);
  border-left: 4px solid var(--accent);
}

.interpretation-banner.warn {
  background: var(--amber-50);
  border-left: 4px solid var(--amber);
}

.interpretation-banner.bad {
  background: var(--rose-50);
  border-left: 4px solid var(--rose);
}

.interpretation-banner .icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.interpretation-banner .text {
  color: var(--text-2);
}

.interpretation-banner .text strong {
  color: var(--text);
}

.range-indicator {
  position: relative;
  height: 28px;
  background: var(--surface-3);
  border-radius: 14px;
  margin: 12px 0;
  overflow: visible;
}

.range-indicator .range-segment {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.range-indicator .seg-low {
  background: var(--rose);
  border-radius: 14px 0 0 14px;
  left: 0;
  width: 20%;
}

.range-indicator .seg-normal {
  background: var(--accent);
  left: 20%;
  width: 50%;
}

.range-indicator .seg-high {
  background: var(--amber);
  left: 70%;
  width: 20%;
}

.range-indicator .seg-very-high {
  background: var(--rose);
  border-radius: 0 14px 14px 0;
  left: 90%;
  width: 10%;
}

.range-indicator .marker {
  position: absolute;
  top: -6px;
  bottom: -6px;
  width: 4px;
  background: var(--text);
  border-radius: 2px;
  transition: left .4s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 0 0 3px var(--surface);
}

.range-indicator .marker::after {
  content: attr(data-value);
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  background: var(--surface);
  padding: 2px 6px;
  border-radius: var(--r-xs);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.compare-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  background: var(--surface);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.compare-table th {
  background: linear-gradient(180deg,var(--primary),var(--primary-d));
  color: #fff;
  padding: 14px 12px;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
}

.compare-table th:first-child {
  background: var(--surface-3);
  color: var(--text);
  text-align: left;
}

.compare-table th .food-cal {
  font-size: 18px;
  font-weight: 800;
  display: block;
  margin-top: 4px;
}

.compare-table td {
  padding: 10px 12px;
  text-align: center;
  border-bottom: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
  font-variant-numeric: tabular-nums;
}

.compare-table td:first-child {
  text-align: left;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-2);
}

.compare-table td.best {
  background: var(--accent-50);
  font-weight: 700;
  color: var(--accent-d);
}

.compare-table tbody tr:hover td {
  background: var(--primary-50);
}

.compare-table tbody tr:hover td:first-child {
  background: var(--surface-3);
}

.compare-table tbody tr:last-child td {
  border-bottom: 0;
}

.food-result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px 18px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all .2s ease;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
}

.food-result-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateX(2px);
}

.food-result-card .food-info {
  min-width: 0;
}

.food-result-card .food-info .name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 3px;
}

.food-result-card .food-info .meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.food-result-card .food-info .meta span {
  display: flex;
  align-items: center;
  gap: 3px;
}

.food-result-card .food-nutrition {
  display: flex;
  gap: 12px;
  align-items: center;
}

.food-result-card .nutrition-pill {
  background: var(--surface-2);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.food-result-card .nutrition-pill.cal {
  background: var(--primary-50);
  color: var(--primary-d);
}

.food-result-card .nutrition-pill.protein {
  background: var(--accent-50);
  color: var(--accent-d);
}

.food-result-card .nutrition-pill.carbs {
  background: var(--amber-50);
  color: var(--amber);
}

.food-result-card .nutrition-pill.fat {
  background: var(--rose-50);
  color: var(--rose);
}

.food-result-card .add-btn {
  background: var(--primary);
  color: #fff;
  border: 0;
  border-radius: var(--r-sm);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}

.food-result-card .add-btn:hover {
  background: var(--primary-d);
  transform: scale(1.05);
}

.meal-section-enhanced {
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.meal-section-enhanced .meal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
  border-bottom: 1px solid var(--border);
}

.meal-section-enhanced .meal-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.meal-section-enhanced .meal-header .meal-totals {
  font-size: 13px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.meal-section-enhanced .meal-header .meal-totals strong {
  color: var(--text);
}

.meal-section-enhanced .meal-body {
  padding: 12px 20px;
}

.menu-item .meta::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  margin-right: 4px;
}

.menu-item:hover .meta {
  color: var(--primary-d);
}

.tray-panel h3::before {
  content: "";
  width: 4px;
  height: 18px;
  background: linear-gradient(180deg, var(--accent), var(--accent-d));
  border-radius: 2px;
}

.tray-item:hover {
  border-color: var(--primary-l);
  box-shadow: var(--shadow-xs);
}

.article table thead {
  background: linear-gradient(180deg,var(--surface-3),var(--surface-2));
}

.article table th.numeric {
  text-align: right;
}

.article table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.article table td.numeric {
  text-align: right;
  font-weight: 600;
  color: var(--text);
}

.article table tbody tr:hover td {
  background: var(--primary-50);
}

.article table tbody tr:last-child td {
  border-bottom: 0;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 14px;
  border: 1.5px solid var(--border-control);
  border-radius: var(--r-sm);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  line-height: 1.4;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
  border-color: var(--border-control-hover);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  background: var(--surface);
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-50);
}

.form-group label::before {
  content: "";
  width: 3px;
  height: 12px;
  background: var(--primary);
  border-radius: 2px;
  opacity: 0;
  transition: opacity .15s ease;
  display: none;
}

.form-group:focus-within label::before {
  opacity: 1;
}

.btn-primary:active {
  box-shadow: 0 2px 4px rgba(79,70,229,.2);
  transform: translateY(0);
}

.results h3::before {
  content: "";
  width: 4px;
  height: 16px;
  background: linear-gradient(180deg, var(--accent), var(--accent-d));
  border-radius: 2px;
}

.result-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: 0;
  transition: opacity .2s ease;
}

.result-item:hover::before {
  opacity: 1;
}

.article ul, .article ol {
  text-align: left;
  margin-bottom: 18px;
  margin: 0 0 18px 0;
  padding-left: 22px;
}

.article li {
  margin-bottom: 8px;
  line-height: 1.65;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.radio-pill input[type="radio"] {
  margin: 0;
  width: auto;
  padding: 0;
  border: 0;
  accent-color: var(--primary);
}

.radio-pill.active input[type="radio"] {
  accent-color: #fff;
}

[data-theme="dark"] .site-footer {
  background: #0B1120;
}

[data-theme="dark"] .footer-bottom {
  border-top-color: #1E293B;
}

.article table,
.data-table,
.compare-table {
  display: block;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.menu-list::-webkit-scrollbar-track {
  background: transparent;
}

[data-theme="dark"] .macro-bar {
  background: var(--surface-3);
}

[data-theme="dark"] .nutrition-pill.cal {
  background: rgba(99,102,241,.2);
  color: var(--primary-l);
}

[data-theme="dark"] .nutrition-pill.protein {
  background: rgba(16,185,129,.2);
  color: var(--accent-l);
}

[data-theme="dark"] .nutrition-pill.carbs {
  background: rgba(245,158,11,.2);
  color: var(--amber-l);
}

[data-theme="dark"] .nutrition-pill.fat {
  background: rgba(244,63,94,.2);
  color: var(--rose-l);
}

[data-theme="dark"] .modal-overlay {
  background: rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .toast {
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border-2);
}

.main-nav a {
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  border-radius: var(--r-sm);
  transition: all .15s;
  white-space: nowrap;
}

.main-nav a:hover {
  color:var(--primary-text);
  background: var(--primary-50);
}

.main-nav a.active {
  color: var(--primary-d);
  font-weight: 600;
}

.main-nav a.nav-cta {
  background: var(--primary-50);
  color: var(--primary-d);
  padding: 7px 14px;
  font-weight: 600;
  border: 1px solid var(--primary-100);
}

.main-nav a.nav-cta:hover {
  background: var(--primary-100);
  color: var(--primary-d);
  border-color: var(--primary-l);
}

.theme-toggle, .cmdk-trigger {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.theme-toggle:hover, .cmdk-trigger:hover {
  background: var(--surface-3);
  color:var(--primary-text);
}

.cmdk-item.selected, .cmdk-item:hover {
  background: var(--primary-50);
  color: var(--primary-d);
}

[data-theme="dark"] .cmdk-overlay {
  background: rgba(0, 0, 0, 0.6);
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Inter', -apple-system, sans-serif;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.trust-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 6px 20px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-3);
  flex-wrap: wrap;
}

.trust-bar .trust-item {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.trust-bar .trust-item svg {
  width: 13px;
  height: 13px;
  color: var(--accent);
}

[data-theme="dark"] .trust-bar {
  background: var(--surface);
  border-bottom-color: var(--border);
}

[data-theme="dark"] .hero-bg {
  background: radial-gradient(ellipse 800px 600px at 20% 0%, rgba(99,102,241,.08), transparent 60%),
    radial-gradient(ellipse 600px 400px at 80% 100%, rgba(16,185,129,.08), transparent 60%);
  opacity: 1;
}

/* (v8.20.2) This later block previously re-imposed gradients over the
   earlier soft tints. The multi-color icon set carries its own colors;
   the chips stay quiet washes in both themes. */
.tool-card .icon.terracotta,
.tool-card .icon.primary {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 16%, transparent);
}

.tool-card .icon.sage,
.tool-card .icon.accent,
.tool-card .icon.teal {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
}

.tool-card .icon.mustard,
.tool-card .icon.amber,
.tool-card .icon.orange {
  background: color-mix(in srgb, var(--amber) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber) 24%, transparent);
}

.tool-card .icon.berry,
.tool-card .icon.rose {
  background: color-mix(in srgb, var(--rose) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--rose) 16%, transparent);
}

.tool-card .icon.indigo,
.tool-card .icon.purple {
  background: color-mix(in srgb, #8467BA 10%, transparent);
  border: 1px solid color-mix(in srgb, #8467BA 20%, transparent);
}

.cat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.cat-header .cat-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cat-header .cat-icon.terracotta,
.cat-header .cat-icon.primary {
  background: var(--primary-50);
  color: var(--primary-d);
}

.cat-header .cat-icon.sage,
.cat-header .cat-icon.accent {
  background: var(--accent-50);
  color: var(--accent-d);
}

.cat-header .cat-icon.mustard,
.cat-header .cat-icon.amber {
  background: var(--amber-50);
  color: var(--amber);
}

.cat-header .cat-icon.berry,
.cat-header .cat-icon.rose {
  background: var(--rose-50);
  color: var(--rose);
}

.cat-header .cat-icon.orange {
  background: #FFF7ED;
  color: #EA580C;
}

.cat-header .cat-icon.indigo,
.cat-header .cat-icon.purple {
  background: #EEF2FF;
  color: #16A34A;
}

[data-theme="dark"] .cat-header .cat-icon.terracotta,
[data-theme="dark"] .cat-header .cat-icon.primary {
  background: rgba(99,102,241,.15);
}

[data-theme="dark"] .cat-header .cat-icon.sage,
[data-theme="dark"] .cat-header .cat-icon.accent {
  background: rgba(16,185,129,.15);
}

[data-theme="dark"] .cat-header .cat-icon.mustard,
[data-theme="dark"] .cat-header .cat-icon.amber {
  background: rgba(245,158,11,.15);
}

[data-theme="dark"] .cat-header .cat-icon.berry,
[data-theme="dark"] .cat-header .cat-icon.rose {
  background: rgba(244,63,94,.15);
}

[data-theme="dark"] .cat-header .cat-icon.orange {
  background: rgba(249,115,22,.15);
}

[data-theme="dark"] .cat-header .cat-icon.indigo,
[data-theme="dark"] .cat-header .cat-icon.purple {
  background: rgba(99,102,241,.15);
}

.cat-header .cat-icon svg {
  width: 26px;
  height: 26px;
}

.cat-header .cat-info h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.cat-header .cat-info p {
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--text-muted);
}

.goal-card::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .3s ease;
}

.goal-card:hover::after {
  transform: scaleX(1);
}

.article ul li, .article ol li {
  margin-bottom: 8px;
  line-height: 1.65;
}

.article ul li {
  list-style: disc;
}

.article table,
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 20px 0;
  font-size: 14px;
  background: var(--surface);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.article table thead,
.data-table thead {
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
}

.article table th,
.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.article table td,
.data-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}

.article table tbody tr:nth-child(even),
.data-table tbody tr:nth-child(even) {
  background: var(--surface-2);
}

.article table tbody tr:hover,
.data-table tbody tr:hover {
  background: var(--primary-50);
}

.article table tbody tr:last-child td,
.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.newsletter::before {
  content: "";
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,.1) 0%, transparent 50%);
  pointer-events: none;
}

.section-head.left h1 {
  margin-bottom: 8px;
}

.chip.terracotta, .chip.primary {
  background: var(--primary-50);
  color: var(--primary-d);
}

.chip.sage, .chip.accent {
  background: var(--accent-50);
  color: var(--accent-d);
}

.chip.mustard, .chip.amber {
  background: var(--amber-50);
  color: #92400E;
}

.chip.berry, .chip.rose {
  background: var(--rose-50);
  color: var(--rose);
}

.tool-grid .tool-card:nth-child(n+9) {
  animation-delay: .26s;
}

.tray-item .remove:hover {
  transform: scale(1.2);
}

.macro-tile::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
  opacity: 0.6;
}

.macro-tile:nth-child(1)::before {
  background: var(--primary);
}

.macro-tile:nth-child(2)::before {
  background: var(--accent);
}

.macro-tile:nth-child(3)::before {
  background: var(--amber);
}

.macro-tile:nth-child(4)::before {
  background: var(--rose);
}

.tool-card, .goal-card, .card, .result-item, .meal-section-enhanced, .menu-item, .tray-item {
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

input, select, textarea, .radio-pill, .filter-chip {
  transition: all 0.15s ease;
}

.results.show .result-item:nth-child(5) {
  animation-delay: 0.25s;
}

* {
  transition-property: background-color, border-color, color, box-shadow;
  transition-duration: 0.15s;
  transition-timing-function: ease;
}

.tool-card, .btn, .goal-card, .filter-chip, .menu-item, .tray-item,
.result-item, .radio-pill, .food-result-card, .meal-section-enhanced {
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.tool-card:hover, .goal-card:hover {
  transform: translateY(-3px);
}

.loading {
  opacity: 0.6;
  pointer-events: none;
}

.auth-card {
  animation: authCardSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.dashboard-hero {
  animation: heroSlideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.dash-card {
  animation: dashCardSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

.dash-card:nth-child(1) {
  animation-delay: 0.1s;
}

.dash-card:nth-child(2) {
  animation-delay: 0.15s;
}

.dash-card:nth-child(3) {
  animation-delay: 0.2s;
}

.dash-card:nth-child(4) {
  animation-delay: 0.25s;
}

.dash-card:nth-child(5) {
  animation-delay: 0.3s;
}

.dash-card:nth-child(6) {
  animation-delay: 0.35s;
}

.brand:hover .brand-mark {
  transform: scale(1.05);
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
}

.nav-item > a {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  border-radius: var(--r-sm);
  transition: all 0.15s ease;
  white-space: nowrap;
  cursor: pointer;
}

.nav-item > a:hover {
  color:var(--primary-text);
  background: var(--primary-50);
}

.nav-item > a.active {
  color: var(--primary-d);
  font-weight: 600;
}

.nav-item > a .nav-icon {
  width: 13px;
  height: 13px;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.nav-item > a:hover .nav-icon {
  opacity: 1;
}

.nav-chevron {
  width: 10px !important;
  height: 10px !important;
  margin-left: 1px;
  opacity: 0.35;
  transition: transform 0.2s ease, opacity 0.15s;
}

.nav-item:hover .nav-chevron {
  transform: rotate(180deg);
  opacity: 0.7;
}

.nav-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.06);
  padding: 5px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
  z-index: 9999;
  margin-top: 2px;
}

.nav-item:hover .nav-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.nav-dropdown a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.1s ease;
  white-space: nowrap;
}

.nav-dropdown a:hover {
  background: var(--primary-50);
  color: var(--primary-d);
}

.nav-dropdown a .dd-icon {
  width: 13px;
  height: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: color 0.1s;
}

.nav-dropdown a:hover .dd-icon {
  color:var(--primary-text);
}

.nav-dropdown .dd-divider {
  height: 1px;
  background: var(--border);
  margin: 3px 0;
}

.nav-mega {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  width: 520px;
  max-width: 90vw;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.06);
  padding: 12px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
  z-index: 9999;
  margin-top: 2px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px;
}

.nav-item:hover .nav-mega {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.nav-mega a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.1s ease;
}

.nav-mega a:hover {
  background: var(--primary-50);
  color: var(--primary-d);
}

.nav-mega a .dd-icon {
  width: 13px;
  height: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.nav-mega a:hover .dd-icon {
  color:var(--primary-text);
}

.nav-mega .mega-label {
  flex: 1;
}

.nav-mega .mega-count {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  background: var(--surface-3);
  padding: 1px 7px;
  border-radius: 20px;
}

.nav-item > a.nav-cta {
  background: var(--primary-50);
  color: var(--primary-d);
  font-weight: 600;
  border: 1px solid var(--primary-100);
  padding: 7px 14px;
}

.nav-item > a.nav-cta:hover {
  background: var(--primary-100);
  border-color: var(--primary-l);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

@media (max-width:768px) {
  .section {
  padding: 48px 0;
  }
  .section-sm {
  padding: 32px 0;
  }
  .section-lg {
  padding: 64px 0;
  }
}

@media (max-width:1100px) {
  .main-nav > a, .main-nav a:not(.nav-cta) {
    padding: 8px 8px;
    font-size: 13px;
  }
  .site-header .container {
    gap: 6px;
    padding: 0 16px;
  }
  .brand { font-size: 17px; }
  .brand-mark { width: 30px; height: 30px; }
  .brand-mark svg { width: 16px; height: 16px; }
}

@media (max-width:980px) {
  .main-nav {
  display: none;
  position: absolute;
  top: 60px;
  left: 0;
  right: 0;
  flex-direction: column;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  gap: 4px;
  box-shadow: var(--shadow-xl);
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform: translateY(-8px);
  opacity: 0;
  pointer-events: none;
  }
  .main-nav.open {
  display: flex;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  }
  .main-nav>a {
  padding: 12px 14px;
  font-size: 15px;
  width: 100%;
  }
  .menu-toggle {
  display: flex;
  }
  .hero-grid {
  grid-template-columns: 1fr;
  gap: 32px;
  }
  .hero-card-stack {
  max-width: 380px;
  margin: 0 auto;
  }
  .hero-mini-card {
  display: none;
  }
  .tool-layout {
  grid-template-columns: 1fr;
  gap: 32px;
  }
  .tool-sidebar {
  position: static;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 14px;
  }
  .tool-sidebar .sidebar-card {
  flex: 1;
  min-width: 240px;
  }
  .main-nav a {
  padding: 12px 14px;
  font-size: 15px;
  width: 100%;
  }
}

@media (max-width:900px) {
  .goal-grid {
  grid-template-columns: repeat(2, 1fr);
  }
  .footer-grid {
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  }
  .meal-builder {
  grid-template-columns: 1fr;
  }
  .footer-brand {
  grid-column: 1/-1;
  }
}

@media (max-width:520px) {
  .goal-grid {
  grid-template-columns: 1fr;
  }
  .footer-grid {
  grid-template-columns: 1fr;
  }
  .tool-grid {
  grid-template-columns: 1fr;
  }
  .hero-actions {
  flex-direction: column;
  }
  .hero-actions .btn {
  width: 100%;
  }
  /* Newsletter form: stack input + button vertically on small screens */
  .newsletter-section form,
  .newsletter form {
  flex-direction: column;
  }
  .newsletter-section form input,
  .newsletter-section form button,
  .newsletter form input,
  .newsletter form button {
  width: 100%;
  min-width: 0;
  }
  /* Hero stats: 2 per row on very small screens */
  .hero-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  }
}

@media (max-width:680px) {
  .macro-summary {
  grid-template-columns: repeat(2, 1fr);
  }
  .stat-banner {
  grid-template-columns: repeat(2, 1fr);
  }
  .stat-banner .item:nth-child(2) {
  border-right: 0;
  }
  .grid-2,.grid-3 {
  grid-template-columns: 1fr;
  }
  .container {
  padding: 0 16px;
  }
  .container-narrow {
  padding: 0 16px;
  }
  .nutrition-grid {
  grid-template-columns: repeat(3,1fr);
  }
  .food-result-card {
  grid-template-columns: 1fr;
  gap: 10px;
  }
  .food-result-card .food-nutrition {
  flex-wrap: wrap;
  gap: 6px;
  }
  .compare-table {
  font-size: 12px;
  }
  .compare-table th,.compare-table td {
  padding: 8px 6px;
  }
  .stat-card {
  padding: 14px;
  }
  .stat-card .stat-value {
  font-size: 18px;
  }
  .calc-widget {
  padding: 18px;
  }
  .form-grid {
  grid-template-columns: 1fr !important;
  }
  .result-grid {
  grid-template-columns: repeat(2, 1fr) !important;
  }
  .hero {
  padding: 40px 0 32px;
  }
  .hero-stats {
  gap: 20px;
  }
  .hero-stat strong {
  font-size: 24px;
  }
  .newsletter {
  padding: 32px 20px;
  }
  .brand {
  font-size: 17px;
  }
  .brand-mark {
  width: 30px;
  height: 30px;
  }
}

@media (max-width:640px) {
  .field-row {
  grid-template-columns: 1fr;
  }
}

@media (min-width:981px) {
  .cmdk-trigger {
  display: flex;
  }
}

@media print {
  .site-header,.site-footer,.tool-sidebar,.menu-toggle,.nav-cta {
  display: none;
  }
  body {
  background: #fff;
  color: #000;
  font-size: 11pt;
  line-height: 1.5;
  }
  .container {
  max-width: 100%;
  }
  .tool-sidebar,.site-header,.site-footer,.cmdk-overlay,.cmdk-trigger,.theme-toggle,.menu-toggle,.btn,.ai-fab,.diary-quickadd-bar,.diary-bottom-container,.skip-to-content {
  display: none!important;
  }
  .tool-layout {
  grid-template-columns: 1fr !important;
  }
  .calc-widget,.results,.article {
  box-shadow: none!important;
  border: 1px solid #ccc!important;
  }
  h1,h2,h3 {
  page-break-after: avoid;
  }
  .article {
  font-size: 11pt;
  }
  .site-header, .site-footer, .tool-sidebar, .menu-toggle,
  .nav-cta, .cmdk-overlay, .cmdk-trigger, .theme-toggle,
  .btn, .filter-bar, .hero-bg, .hero-mini-card {
  display: none !important;
  }
  .calc-widget, .results, .article {
  box-shadow: none !important;
  border: 1px solid #ccc !important;
  background: #fff !important;
  }
  h1, h2, h3 {
  page-break-after: avoid;
  }
}

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

@media (max-width:560px) {
  .form-grid {
  grid-template-columns: 1fr!important;
  }
  .result-grid {
  grid-template-columns: repeat(2,1fr)!important;
  }
  .macro-summary {
  grid-template-columns: repeat(2,1fr)!important;
  }
}

@media (max-width:980px) {
  .menu-toggle {
  display: flex;
  }
  .main-nav {
  display: none;
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 0;
  flex-direction: column;
  background: var(--surface);
  padding: 12px;
  gap: 1px;
  overflow-y: auto;
  z-index: 999;
  animation: mobileNavSlide 0.25s ease;
  }
  .main-nav.open {
  display: flex;
  }
  .nav-item {
  width: 100%;
  flex-direction: column;
  align-items: stretch;
  }
  .nav-item > a {
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  }
  .nav-dropdown, .nav-mega {
  position: static;
  transform: none;
  opacity: 1;
  visibility: visible;
  box-shadow: none;
  border: 0;
  padding: 0 0 0 14px;
  width: 100%;
  min-width: 100%;
  max-width: 100%;
  display: none;
  grid-template-columns: 1fr;
  }
  .nav-item.expanded .nav-dropdown, .nav-item.expanded .nav-mega {
  display: grid;
  }
  .nav-chevron {
  /* Keep the chevron visible in the mobile menu: it is the affordance
     that a category expands on tap, and it flips when expanded. */
  display: inline-block;
  opacity: 0.7;
  }
  .nav-item.expanded .nav-chevron {
  transform: rotate(180deg);
  }
  .cmdk-trigger {
  display: none;
  }
  @keyframes mobileNavSlide {
  from { opacity: 0; transform: translateX(-16px); }
      to { opacity: 1; transform: translateX(0); }
  }
}

@keyframes fadeIn {
  from {
  opacity: 0;
  transform: translateY(8px);
  }
  to {
  opacity: 1;
  transform: translateY(0);
  }
}

@keyframes spin {
  from {
  transform: rotate(0);
  }
  to {
  transform: rotate(360deg);
  }
}

@keyframes slideUp {
  from {
  opacity: 0;
  transform: translateY(12px);
  }
  to {
  opacity: 1;
  transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
  opacity: 0;
  transform: scale(0.95);
  }
  to {
  opacity: 1;
  transform: scale(1);
  }
}

@keyframes shimmer {
  0% {
  background-position: -200% 0;
  }
  100% {
  background-position: 200% 0;
  }
}

@keyframes pulse {
  0%,100% {
  opacity: 1;
  transform: scale(1);
  }
  50% {
  opacity: 0.5;
  transform: scale(0.8);
  }
  0%, 100% {
  opacity: 1;
  transform: scale(1);
  }
}

@keyframes pageFadeIn {
  from {
  opacity: 0;
  }
  to {
  opacity: 1;
  }
}

@keyframes resultsSlideIn {
  from {
  opacity: 0;
  transform: translateY(12px);
  }
  to {
  opacity: 1;
  transform: translateY(0);
  }
}

@keyframes itemPopIn {
  from {
  opacity: 0;
  transform: translateY(8px) scale(0.95);
  }
  to {
  opacity: 1;
  transform: translateY(0) scale(1);
  }
}

@keyframes toastSlideUp {
  from {
  opacity: 0;
  transform: translateX(-50%) translateY(100px);
  }
  to {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  }
}

@keyframes modalFadeIn {
  from {
  opacity: 0;
  }
  to {
  opacity: 1;
  }
}

@keyframes modalSlideUp {
  from {
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  }
  to {
  opacity: 1;
  transform: translateY(0) scale(1);
  }
}

@keyframes cmdkFadeIn {
  from {
  opacity: 0;
  }
  to {
  opacity: 1;
  }
}

@keyframes cmdkSlideDown {
  from {
  opacity: 0;
  transform: translateY(-20px);
  }
  to {
  opacity: 1;
  transform: translateY(0);
  }
}

@keyframes authCardSlideUp {
  from {
  opacity: 0;
  transform: translateY(20px);
  }
  to {
  opacity: 1;
  transform: translateY(0);
  }
}

@keyframes heroSlideIn {
  from {
  opacity: 0;
  transform: translateY(10px);
  }
  to {
  opacity: 1;
  transform: translateY(0);
  }
}

@keyframes dashCardSlideUp {
  from {
  opacity: 0;
  transform: translateY(15px);
  }
  to {
  opacity: 1;
  transform: translateY(0);
  }
}

/* ============================================================
   ENHANCED RESPONSIVE & ACCESSIBILITY 
   ============================================================ */

/* ===== Auto dark mode for users who haven't set a preference =====
   (Full variable set defined at the top of this file - see line ~163.
   This block is kept only as a color-scheme hint for native form controls.) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
  }
}

/* ===== Prevent horizontal overflow on ALL containers ===== */
*, *::before, *::after {
  max-width: 100%;
}

/* But don't break positioned elements */
html, body {
  max-width: none;
}

/* ===== Tables: horizontal scroll on small screens ===== */
.table-wrapper, .calc-widget > table, .data-table {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ===== Better mobile breakpoints ===== */
@media (max-width:480px) {
  .container, .container-narrow {
    padding: 0 12px;
  }
  body {
    font-size: 14px;
  }
  h1 { font-size: clamp(22px, 6vw, 28px) !important; }
  h2 { font-size: clamp(18px, 5vw, 24px) !important; }
  h3 { font-size: clamp(16px, 4vw, 20px) !important; }
  .hero h1 { font-size: clamp(24px, 7vw, 32px) !important; }
  .stat-value { font-size: 1.5rem !important; }
  .calc-widget { padding: 12px !important; }
  .admin-card { padding: 12px !important; }
  .card-body { padding: 12px !important; }
  .form-grid { grid-template-columns: 1fr !important; }
  .form-row { grid-template-columns: 1fr !important; }
  .form-row.triple { grid-template-columns: 1fr !important; }
  .stat-grid { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
  .save-bar { padding: 12px !important; flex-direction: column !important; gap: 8px; }
  .save-bar button { width: 100%; }
  .admin-page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .modal-body, .modal-content { max-width: 95vw !important; }
}

/* (UI-AUDIT W8) Sticky save bars must clear the mobile bottom nav
   (.mn-bottom-nav, fixed z-index 900 injected by mobile-nav.js): raise the bar
   above the nav AND offset it up so the primary CTA is reachable, and cancel
   the negative side margins that bleed the bar 12px off-screen once.container
   padding shrinks to 12px on phones (dashboard/goals.php). */
@media (max-width: 768px) {
  body.mn-has-nav .save-bar {
    z-index: 950;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }
}
@media (max-width: 480px) {
  .save-bar {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}

/* ===== Ultra-small screens (320px) ===== */
@media (max-width:360px) {
  .container, .container-narrow {
    padding: 0 8px;
  }
  .stat-grid { grid-template-columns: 1fr !important; }
  .brand { font-size: 15px !important; }
  .brand-mark { width: 26px !important; height: 26px !important; }
  .main-nav > a { padding: 6px 4px !important; font-size: 12px !important; }
}

/* ===== Touch-friendly tap targets ===== */
@media (hover: none) and (pointer: coarse) {
  button, .btn, a.btn, input[type="submit"], input[type="button"] {
    min-height: 40px;
    min-width: 40px;
  }
  .nav-item > a, .main-nav > a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

/* ===== Focus-visible for keyboard navigation ===== */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 3px;
}

button:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ===== Print optimization ===== */
@media print {
  body { background: white !important; color: black !important; }
  .site-header, .site-footer, .ai-fab, .ai-chat-panel, .menu-toggle,
  .theme-toggle, .nav-cta, .cmdk-trigger, .cmdk-overlay,
  .admin-sidebar, .save-bar, .admin-toast-container,
  button[aria-label], .no-print {
    display: none !important;
  }
  main { padding: 0 !important; }
  .container { max-width: 100% !important; padding: 0 !important; }
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
  table, img, svg { page-break-inside: avoid; }
  h1, h2, h3 { page-break-after: avoid; }
}

/* ===== Loading skeleton animation =====
   Base `.skeleton` class animates a shimmer gradient. Variants:
   - `.skeleton-text` - inline-block text-shaped skeleton (with.w-* width helpers)
   - `.skeleton-card` - card-shaped skeleton wrapper (bordered, padded)
   - `.skeleton-circle` - circular skeleton (avatars, rings)
   Use them as loading placeholders. The shimmer uses CSS variables only
   so they look correct in both light and dark themes automatically. */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes skeletonPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

/* Text-line skeleton - inline-block so it sits in normal text flow.
   Width helpers (.w-25/.w-33/.w-50/.w-75/.w-100) let you simulate
   varying text lengths for a more realistic placeholder. */
.skeleton-text {
  display: block;
  height: 12px;
  margin-bottom: 8px;
  border-radius: var(--r-xs, 4px);
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
.skeleton-text:last-child { margin-bottom: 0; }
.skeleton-text.w-100 { width: 100%; }
.skeleton-text.w-75  { width: 75%; }
.skeleton-text.w-50  { width: 50%; }
.skeleton-text.w-33  { width: 33%; }
.skeleton-text.w-25  { width: 25%; }

/* Larger text-line variant for headings */
.skeleton-text.lg { height: 18px; }
.skeleton-text.sm { height: 10px; margin-bottom: 6px; }

/* Card skeleton - a bordered container that holds.skeleton-text lines.
   Use it as a drop-in loading state for any card-shaped widget. */
.skeleton-card {
  border: 1px solid var(--border, #E5E7EB);
  border-radius: var(--r, 12px);
  padding: 16px;
  background: var(--surface, #fff);
  box-shadow: var(--shadow-xs);
}
.skeleton-card .skeleton-text:last-child { margin-bottom: 0; }

/* Circular skeleton - for avatars, macro rings, icons. */
.skeleton-circle {
  display: inline-block;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
.skeleton-circle.sm { width: 32px; height: 32px; }
.skeleton-circle.lg { width: 64px; height: 64px; }
.skeleton-circle.xl { width: 96px; height: 96px; }

/* Row skeleton - for list items (e.g. search result rows). */
.skeleton-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light, #F3F4F6);
}
.skeleton-row:last-child { border-bottom: 0; }

/* Reduced-motion fallback: skip the shimmer, use a static pulse. */
@media (prefers-reduced-motion: reduce) {
  .skeleton,
  .skeleton-text,
  .skeleton-circle {
    animation: skeletonPulse 2s ease-in-out infinite;
    background: var(--surface-3);
    background-size: auto;
  }
}

/* ===== Smooth scrolling for in-page anchors ===== */
html {
  scroll-behavior: smooth;
}

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

/* ===== Better image rendering ===== */
img {
  image-rendering: -webkit-optimize-contrast;
}

/* ===== Selection styling ===== */
::selection {
  background: var(--primary-50);
  color: var(--primary-d);
}

/* ===== Scrollbar styling (modern browsers) ===== */
@media (min-width:981px) {
  ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
  }
  ::-webkit-scrollbar-track {
    background: var(--surface-2);
  }
  ::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: 5px;
  }
  ::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
  }
}

/* ============================================================
   UI/UX POLISH 
   ============================================================ */

/* ===== Smooth hover transitions on interactive elements ===== */
button, .btn, a.btn, input[type="submit"], input[type="button"],
.nav-item > a, .main-nav > a, .calc-card, .tool-card, .blog-card,
.stat-card, .goal-card, .feature-card, .pricing-card {
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

/* ===== Card hover lift effect ===== */
.calc-card:hover, .tool-card:hover, .blog-card:hover, .stat-card:hover,
.goal-card:hover, .feature-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.08));
}

/* ===== Button press effect ===== */
button:active, .btn:active, input[type="submit"]:active, input[type="button"]:active {
  transform: translateY(1px);
}

/* ===== Better placeholder styling ===== */
input::placeholder, textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

/* ===== Input focus glow ===== */
input:focus, textarea:focus, select:focus {
  box-shadow: 0 0 0 3px var(--primary-50, rgba(99, 102, 241, 0.1));
}

/* ===== Better link transitions ===== */
a {
  transition: color 0.15s ease;
}

/* ===== Tooltip styling ===== */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  background: var(--text, #1f2937);
  color: var(--surface, #fff);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1000;
}
[data-tooltip]:hover::after {
  opacity: 1;
}

/* ===== Loading state for buttons ===== */
.btn-loading, .admin-btn.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btnSpin 0.6s linear infinite;
  color:var(--primary-text);
}
@keyframes btnSpin {
  to { transform: rotate(360deg); }
}

/* ===== Better empty states ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}
.empty-state .empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 4px;
}
.empty-state .empty-desc {
  font-size: 13px;
  line-height: 1.5;
}

/* ===== Improved table styling ===== */
table.data-table, .calc-widget table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.data-table th, .calc-widget table th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  color: var(--text-2);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
table.data-table td, .calc-widget table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
table.data-table tr:hover, .calc-widget table tbody tr:hover {
  background: var(--surface-2);
}

/* ===== Badge improvements ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge.success { background: rgba(16, 185, 129, 0.12); color: #047857; }
.badge.danger { background: rgba(225, 29, 48, 0.12); color: #b91c1c; }
.badge.info { background: rgba(37, 99, 235, 0.12); color: #2563EB; }
.badge.muted { background: var(--surface-3); color: var(--text-muted); }
.badge.warning { background: rgba(245, 158, 11, 0.12); color: #92400e; }

/* ===== Dark mode badge colors ===== */
[data-theme="dark"] .badge.success { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
[data-theme="dark"] .badge.danger { background: rgba(225, 29, 48, 0.2); color: #fca5a5; }
[data-theme="dark"] .badge.info { background: rgba(99, 102, 241, 0.2); color: #a5b4fc; }
[data-theme="dark"] .badge.warning { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }

/* ===== Improved form field styling ===== */
.form-field {
  margin-bottom: 16px;
}
.form-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}
.form-field .field-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== Section spacing ===== */
.section {
  padding: clamp(32px, 8vw, 64px) 0;
}
.section-sm {
  padding: 32px 0;
}
.section-lg {
  padding: 96px 0;
}

/* ===== Heading improvements ===== */
h1, h2, h3, h4, h5, h6 {
  letter-spacing: -0.02em;
  line-height: 1.25;
}

/* ===== Responsive iframe/video ===== */
.video-container, .iframe-container {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
}
.video-container iframe, .iframe-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ===== Skip to content link (accessibility) ===== */
.skip-link,
.skip-to-content {
  position: absolute;
  top: -100px;
  left: 8px;
  background: var(--primary);
  color: #fff;
  padding: 10px 18px;
  z-index: 9999;
  text-decoration: none;
  border-radius: 0 0 6px 6px;
  font-size: 14px;
  font-weight: 600;
  transition: top .15s ease;
}
.skip-link:focus,
.skip-to-content:focus {
  top: 0;
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ===== Visually hidden but accessible ===== */
.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;
}

/* ============================================================
    GLASSY PROFESSIONAL ENHANCEMENTS
   ============================================================ */

.glass-card {
  background: var(--glass-bg, rgba(255,255,255,.72));
  backdrop-filter: blur(var(--glass-blur, 16px));
  -webkit-backdrop-filter: blur(var(--glass-blur, 16px));
  border: 1px solid var(--glass-border, rgba(255,255,255,.5));
  border-radius: var(--r-lg, 20px);
  box-shadow: var(--shadow-md);
}

.gradient-text {
  background: linear-gradient(135deg, var(--primary, #2563EB), var(--accent, #22C55E));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.btn-primary, .admin-btn.primary {
  background: linear-gradient(135deg, var(--primary, #2563EB), var(--primary-d, #1D4ED8));
  color: #fff;
  border: none;
  box-shadow: 0 2px 8px rgba(99,102,241,.25), 0 1px 2px rgba(0,0,0,.04);
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn-primary:hover, .admin-btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99,102,241,.35), 0 2px 4px rgba(0,0,0,.06);
}

.calc-widget, .dash-card, .admin-card {
  transition: box-shadow .2s ease, transform .2s ease;
}
.calc-widget:hover, .dash-card:hover {
  box-shadow: var(--shadow-lg);
}

.hero-gradient {
  background: linear-gradient(135deg, var(--primary-50, #EEF2FF) 0%, transparent 50%, var(--accent-50, #ECFDF5) 100%);
}

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], textarea, select {
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.auth-shell {
  box-shadow: 0 24px 64px rgba(17,24,39,.10), 0 8px 16px rgba(17,24,39,.06);
  border-radius: var(--r-2xl, 32px);
  overflow: hidden;
}
.auth-value {
  background: linear-gradient(155deg, var(--primary-d, #1D4ED8) 0%, var(--primary, #2563EB) 50%, var(--accent-d, #16A34A) 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.auth-value::before {
  content: "";
  position: absolute;
  top: -80px; right: -80px;
  width: 260px; height: 260px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  pointer-events: none;
}
.auth-value::after {
  content: "";
  position: absolute;
  bottom: -60px; left: -60px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
  pointer-events: none;
}
.auth-form-panel { background: var(--surface, #fff); padding: 44px 36px; }
@media (max-width: 768px) { .auth-form-panel { padding: 28px 20px; } }

.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"] {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--border, #E5E7EB);
  border-radius: var(--r-sm, 8px);
  font-size: 14px; font-family: inherit;
  background: var(--surface-2, #F8FAFC);
  color: var(--text, #111827);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.auth-form input:focus {
  outline: none;
  border-color: var(--primary, #2563EB);
  background: var(--surface, #fff);
  box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}
.auth-form label {
  font-size: 13px; font-weight: 600;
  color: var(--text-2, #374151);
  margin-bottom: 6px; display: block;
}

.password-strength .meter { display: flex; gap: 4px; margin-top: 6px; }
.password-strength .meter span {
  flex: 1; height: 4px; border-radius: 2px;
  background: var(--surface-3, #F1F4F9);
  transition: background .25s ease;
}
.password-strength .meter.weak span:nth-child(1) { background: var(--rose, #F43F5E); }
.password-strength .meter.fair span:nth-child(-n+2) { background: var(--amber, #F59E0B); }
.password-strength .meter.good span:nth-child(-n+3) { background: var(--accent, #22C55E); }
.password-strength .meter.strong span { background: var(--accent-d, #16A34A); }

.stat-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #E5E7EB);
  border-radius: var(--r, 12px);
  padding: 16px; position: relative; overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--primary, #2563EB), var(--accent, #22C55E));
  opacity: 0; transition: opacity .2s ease;
}
.stat-card:hover::before { opacity: 1; }

[data-theme="dark"] .auth-value {
  background: linear-gradient(155deg, var(--macrition-navy) 0%, var(--accent-d) 50%, var(--macrition-orange) 100%);
}
[data-theme="dark"] .auth-form-panel { background: var(--surface, #1E293B); }
[data-theme="dark"] .glass-card {
  background: rgba(30,41,59,.72);
  border-color: rgba(148,163,184,.2);
}

main { animation: pageFadeIn 0.3s ease; }
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.btn-gradient {
  background: linear-gradient(135deg, var(--primary, #2563EB), var(--accent, #22C55E));
  color: #fff; border: none;
  box-shadow: 0 2px 12px rgba(99,102,241,.25);
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn-gradient:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(99,102,241,.35);
}

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.section-header h2 {
  font-size: clamp(20px, 3vw, 28px);
  font-weight: 800; letter-spacing: -0.03em; margin: 0;
}

.dash-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #E5E7EB);
  border-radius: var(--r, 12px);
  padding: 20px;
  box-shadow: var(--shadow-xs);
}

.admin-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #E5E7EB);
  border-radius: var(--r, 12px);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.admin-card .card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border, #E5E7EB);
  background: var(--surface-2, #F8FAFC);
}
.admin-card .card-body { padding: 20px; }
.admin-card .card-subtitle { font-size: 13px; color: var(--text-muted, #6B7280); margin-top: 2px; }

[data-theme="dark"] .admin-card {
  background: var(--surface, #1E293B);
  border-color: var(--border, #334155);
}
[data-theme="dark"] .admin-card .card-header {
  background: var(--surface-2, #0F172A);
  border-color: var(--border, #334155);
}

/* ===== Weekly Chart Bars ===== */
#weeklyChart > div {
  cursor: pointer;
  transition: height .3s ease, opacity .3s ease;
}
#weeklyChart > div:hover {
  opacity: 1 !important;
  transform: scaleY(1.05);
}
#weeklyChartLabels > div {
  font-weight: 600;
}

/* ===== Nutrition Score Ring ===== */
#nutritionScoreRing {
  transition: background .3s ease;
}

/* ===== Quick Actions Bar ===== */
.quick-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 20px;
}
.quick-actions-bar .qa-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
}
.quick-actions-bar .qa-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
@media (max-width: 600px) {
  .quick-actions-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .quick-actions-bar .qa-buttons {
    justify-content: center;
  }
  .quick-actions-bar .qa-buttons .btn {
    flex: 1;
    text-align: center;
  }
}

/* ==========================================================================
.calc-filter - lightweight search box for calculator category index pages.
   Lets users filter the tool-grid by typing. Sits between section-head and
   tool-grid. Requires a sibling <input> + tool-grid on the page; the filter
   JS is injected inline by each category index page.
   ========================================================================== */
.calc-filter {
  position: relative;
  max-width: 420px;
  margin: 0 0 24px;
}
.calc-filter input {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 14px 11px 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-pill);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.calc-filter input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-50);
}
.calc-filter input::placeholder {
  color: var(--text-muted);
  opacity: .7;
}
.calc-filter svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}
.calc-filter .filter-empty {
  display: none;
}
.calc-filter .filter-empty.show {
  display: block;
}
/* Standalone empty-state for category pages - child of.tool-grid, spans all columns */
.tool-grid .filter-empty {
  display: none;
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
  font-size: 14px;
  background: var(--surface);
  border: 1px dashed var(--border-2);
  border-radius: var(--r-md);
  margin-bottom: 0;
  animation: none;
}
.tool-grid .filter-empty.show {
  display: block;
}
.filter-empty .btn-link {
  background: none;
  border: none;
  color:var(--primary-text);
  font-weight: 600;
  cursor: pointer;
  padding: 0 4px;
  text-decoration: underline;
  font-size: inherit;
  font-family: inherit;
}
@media (max-width: 540px) {
  .calc-filter {
    max-width: 100%;
  }
}

/* ==========================================================================
.0 GLOSSY PROFESSIONAL POLISH (upgrade-glossy-dashboard-1)
   Additive enhancement layer - glassmorphism utilities, gradient helpers,
   shimmer effects, micro-interactions, focus rings, themed scrollbars.
   All rules below are NEW or complement existing rules without removing them.
   ========================================================================== */

/* ---- 1. Glassmorphism utility classes ------------------------------- */

/*.glass-card already exists at line ~6081. This block extends it with a
   subtle inner highlight + hover lift for premium feel. It is additive -
   earlier.glass-card rules still apply. */
.glass-card {
  position: relative;
  background-image: linear-gradient(135deg, rgba(255,255,255,.18), rgba(255,255,255,.04));
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,.25);
}
[data-theme="dark"] .glass-card {
  background-image: linear-gradient(135deg, rgba(148,163,184,.08), rgba(148,163,184,.02));
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(148,163,184,.12);
}

/* Sticky header with frosted blur (used on dashboards, admin pages, app headers) */
.glass-header {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 1px 0 rgba(255,255,255,.06), 0 4px 16px rgba(17,24,39,.04);
  position: sticky;
  top: 0;
  z-index: 50;
}
[data-theme="dark"] .glass-header {
  box-shadow: 0 1px 0 rgba(0,0,0,.25), 0 4px 16px rgba(0,0,0,.28);
}

/* Modal surface using glass + dark backdrop blur */
.glass-modal {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2xl), inset 0 1px 0 rgba(255,255,255,.25);
}
.glass-modal-backdrop {
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
[data-theme="dark"] .glass-modal {
  background: rgba(30,41,59,.82);
  border-color: rgba(148,163,184,.22);
}

/* ---- 2. Gradient utilities ----------------------------------------- */

/* Solid primary-to-accent gradient surface */
.gradient-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
}
[data-theme="dark"] .gradient-primary {
  background: linear-gradient(135deg, var(--primary-d) 0%, var(--accent-d) 100%);
}

/*.gradient-text already exists at line ~6090. We add the data-theme dark variant
   and an animated companion class.gradient-text-animated (alias of shimmer-text). */
[data-theme="dark"] .gradient-text {
  background: linear-gradient(135deg, var(--primary-l), var(--accent-l));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Gradient border using mask-composite (cutout technique).
   Works in Chrome/Firefox/Safari 14+. Falls back to a solid border. */
.gradient-border {
  position: relative;
  border: 1px solid transparent;
  background-clip: padding-box;
}
.gradient-border::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  z-index: 1;
}
@supports not ((-webkit-mask-composite: xor) or (mask-composite: exclude)) {
  .gradient-border { border: 1.5px solid var(--primary); }
  .gradient-border::before { display: none; }
}

/* ---- 3. Shimmer effects -------------------------------------------- */

/* Animated shimmer overlay. Apply to a relatively-positioned element;
   drop a <span class="shimmer"></span> inside or use on skeleton loaders. */
.shimmer {
  position: relative;
  overflow: hidden;
}
.shimmer::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    transparent 20%,
    rgba(255,255,255,.45) 50%,
    transparent 80%
  );
  background-size: 200% 100%;
  animation: shimmerSweep 1.6s linear infinite;
  pointer-events: none;
}
[data-theme="dark"] .shimmer::after {
  background: linear-gradient(
    100deg,
    transparent 20%,
    rgba(148,163,184,.16) 50%,
    transparent 80%
  );
  background-size: 200% 100%;
}
@keyframes shimmerSweep {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Standalone shimmer text - animated gradient sweep across glyphs */
.shimmer-text {
  background: linear-gradient(
    100deg,
    var(--text) 30%,
    var(--primary-l) 45%,
    var(--accent-l) 55%,
    var(--text) 70%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: shimmerText 2.4s linear infinite;
}
@keyframes shimmerText {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- 4. Micro-interaction utilities -------------------------------- */

/* Lift on hover - 2px translate with softening shadow */
.hover-lift {
  transition: transform .2s cubic-bezier(.4,0,.2,1), box-shadow .2s cubic-bezier(.4,0,.2,1);
  will-change: transform;
}
.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Glow on hover - primary-tinted halo */
.hover-glow {
  transition: box-shadow .25s ease, transform .15s ease;
}
.hover-glow:hover {
  box-shadow:
    0 0 0 1px var(--primary-100),
    0 8px 24px rgba(99,102,241,.18),
    0 2px 8px rgba(17,24,39,.06);
}
[data-theme="dark"] .hover-glow:hover {
  box-shadow:
    0 0 0 1px rgba(99,102,241,.35),
    0 8px 24px rgba(99,102,241,.28),
    0 2px 8px rgba(0,0,0,.4);
}

/* Press = active state - slight scale-down for tactile feedback */
.press {
  transition: transform .08s ease;
}
.press:active {
  transform: scale(.97);
}

/* Global application: apply hover-lift + press to all tool-cards, btn-primary,
   goal-cards, dash-cards, stat-cards. Uses higher specificity (compound selector)
   than the existing single-class rules so the lift stacks on top of existing
   hover transforms. */
.tool-card.hover-lift,
.tool-card {
  transition: transform .2s cubic-bezier(.4,0,.2,1), box-shadow .2s cubic-bezier(.4,0,.2,1), border-color .2s ease;
}
.tool-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-l);
}
.tool-card:active {
  transform: translateY(0) scale(.985);
}

.btn-primary {
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.btn-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}
.btn-primary:active {
  transform: translateY(0) scale(.97);
  filter: brightness(.97);
}

.goal-card {
  transition: transform .2s cubic-bezier(.4,0,.2,1), box-shadow .2s cubic-bezier(.4,0,.2,1), border-color .2s ease;
}
.goal-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.goal-card:active {
  transform: translateY(0) scale(.98);
}

.dash-card {
  transition: transform .2s cubic-bezier(.4,0,.2,1), box-shadow .25s cubic-bezier(.4,0,.2,1), border-color .2s ease;
}
.dash-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-l);
}
.dash-card:active {
  transform: translateY(0) scale(.995);
}

.stat-card {
  transition: transform .2s cubic-bezier(.4,0,.2,1), box-shadow .2s ease;
}
.stat-card:active {
  transform: translateY(0) scale(.98);
}

/* ---- 5. Professional card styling enhancements -------------------- */

/* Tool card: subtle gradient overlay on hover + border glow */
.tool-card {
  position: relative;
  isolation: isolate;
}
.tool-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--primary-50) 0%, transparent 40%, var(--accent-50) 100%);
  opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
  z-index: -1;
}
.tool-card:hover::after {
  opacity: .6;
}
[data-theme="dark"] .tool-card:hover::after {
  opacity: .35;
}

/* Stat card: always-on gradient accent bar on top (replaces hover-only::before
   at line ~6199 - both rules coexist; this one makes the bar always visible) */
.stat-card::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: .65;
  transition: opacity .2s ease, height .2s ease;
  pointer-events: none;
}
.stat-card:hover::after {
  opacity: 1;
  height: 4px;
}

/* ---- 6. Enhanced focus states ------------------------------------- */

/* Universal consistent focus ring. Stacks with existing per-element focus
   rules without removing them - uses outline + box-shadow combo so it works
   even on elements with their own box-shadow. */
*:focus-visible {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--primary-50), 0 0 0 1px var(--primary) !important;
  border-radius: inherit;
}
/* Inputs already get a 3px primary-50 ring via existing rules - give them a
   slightly stronger primary edge for clarity. */
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
button:focus-visible,
.btn:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--primary-50) !important;
}
/* Dark mode: brighter focus ring for contrast */
[data-theme="dark"] *:focus-visible {
  box-shadow: 0 0 0 3px rgba(99,102,241,.4), 0 0 0 1px var(--primary-l) !important;
}
[data-theme="dark"] input:focus-visible,
[data-theme="dark"] textarea:focus-visible,
[data-theme="dark"] select:focus-visible,
[data-theme="dark"] button:focus-visible,
[data-theme="dark"] .btn:focus-visible,
[data-theme="dark"] a:focus-visible,
[data-theme="dark"] [tabindex]:focus-visible {
  outline-color: var(--primary-l);
  box-shadow: 0 0 0 4px rgba(99,102,241,.32) !important;
}

/* ---- 7. Scroll styling -------------------------------------------- */

/* Thin, themed scrollbar (6px width). Existing::-webkit-scrollbar rules at
   line ~5826 use 10px - these override to be sleeker. The Firefox
   scrollbar-width property handles non-webkit browsers. */
html {
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}
@media (min-width: 981px) {
  ::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }
  ::-webkit-scrollbar-track {
    background: transparent;
  }
  ::-webkit-scrollbar-thumb {
    background: var(--border-2);
    border-radius: 3px;
  }
  ::-webkit-scrollbar-thumb:hover {
    background: var(--primary-l);
  }
  ::-webkit-scrollbar-corner {
    background: transparent;
  }
}
[data-theme="dark"] html {
  scrollbar-color: var(--surface-3) transparent;
}

/* Smooth scroll behavior - already on html at line ~198, re-asserted for safety */
html {
  scroll-behavior: smooth;
}

/* ---- 8. Selection styling ----------------------------------------- */

/* Existing::selection at line ~5819 uses primary-50 background. We make the
   selected text slightly bolder and add a small text-shadow for legibility on
   photos. Additive only - earlier rule still applies. */
::selection {
  background: var(--primary-50);
  color: var(--primary-d);
  text-shadow: 0 1px 2px rgba(255,255,255,.35);
}
[data-theme="dark"] ::selection {
  background: rgba(99,102,241,.32);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
}

/* Reduced motion: kill all the new animations */
@media (prefers-reduced-motion: reduce) {
  .shimmer::after,
  .shimmer-text,
  .hover-lift,
  .hover-glow,
  .press,
  .tool-card,
  .btn-primary,
  .goal-card,
  .dash-card,
  .stat-card {
    animation: none !important;
    transition: none !important;
  }
  .hover-lift:hover,
  .tool-card:hover,
  .btn-primary:hover,
  .goal-card:hover,
  .dash-card:hover {
    transform: none !important;
  }
}

/* ==========================================================================
   END.0 GLOSSY POLISH
   ========================================================================== */

/* ==========================================================================
.0 GLASSMORPHISM IMMERSIVE SYSTEM (glassmorphism-foundation-1)
   --------------------------------------------------------------------------
   A comprehensive depth-rich glassmorphism layer for Macrition. Adds:
     • Enhanced glass design tokens (blur, saturate, bg, borders, shadows)
     • Glass surface classes (cards, panels, widgets)
     • Frosted input fields, navigation, buttons, modals, badges, chips,
       tags, stat cards, progress bars, and circular rings
     • A 4-tier depth layering system using translateZ for HW acceleration
     • Ambient background effects (glow, mesh, orb) with reduced-motion guards
     • Tactile hover/active micro-interactions with organic easing
     • Mobile responsive tuning (lower blur, higher opacity)
     • Full dark mode parity
     • Performance: will-change hints + @supports fallback + reduced motion
   ALL rules below are ADDITIVE - earlier rules in this file continue to
   apply. Existing variables (--primary, --accent, --shadow-*, --r-*, etc.)
   are reused so theme presets continue to cascade correctly.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. ENHANCED GLASS DESIGN TOKENS
   --------------------------------------------------------------------------
   Re-declares --glass-blur / --glass-bg / --glass-border with upgraded
   values and adds the rest of the immersive palette. Because this block
   appears last in the cascade, it wins over the values set at line ~81
   and ~117 - but only for the variables listed here. Every other design
   token (--primary, --accent, --surface, --shadow-*, etc.) is inherited
   untouched. */
:root {
  --glass-blur: 20px;
  --glass-saturate: 180%;
  --glass-bg: rgba(255, 255, 255, 0.65);
  --glass-bg-dark: rgba(15, 23, 42, 0.55);
  --glass-border: rgba(255, 255, 255, 0.25);
  --glass-border-dark: rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 8px 32px rgba(17, 24, 39, 0.08);
  --glass-shadow-hover: 0 12px 40px rgba(17, 24, 39, 0.12);
  --glass-highlight: linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0) 50%);

  /* Easing curves - organic motion */
  --glass-ease: cubic-bezier(0.22, 1, 0.36, 1);          /* ease-out-back (gentle) */
  --glass-ease-press: cubic-bezier(0.34, 1.56, 0.64, 1); /* overshoot for tactile */
  --glass-ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);     /* material standard */
}

/* Auto dark mode (no explicit user choice) - mirror the dark glass tokens */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --glass-bg: rgba(15, 23, 42, 0.55);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.32);
    --glass-shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.42);
    --glass-highlight: linear-gradient(135deg, rgba(148, 163, 184, 0.18) 0%, rgba(148, 163, 184, 0) 50%);
  }
}

/* Explicit dark theme */
[data-theme="dark"] {
  --glass-bg: rgba(15, 23, 42, 0.55);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.32);
  --glass-shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.42);
  --glass-highlight: linear-gradient(135deg, rgba(148, 163, 184, 0.18) 0%, rgba(148, 163, 184, 0) 50%);
}

/* --------------------------------------------------------------------------
   2. GLASS SURFACE CLASSES
   -------------------------------------------------------------------------- */

/* Base frosted glass card - the workhorse surface for the immersive layer */
.glass-surface {
  position: relative;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  box-shadow: var(--glass-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  will-change: transform;
  isolation: isolate;
  overflow: hidden;
}
/* Light-leak edge: subtle gradient highlight along the top-left edge */
.glass-surface::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--glass-highlight);
  opacity: 0.7;
  pointer-events: none;
  z-index: 0;
}
.glass-surface > * { position: relative; z-index: 1; }

/* Elevated glass - more shadow, slightly less transparency (lifted card) */
.glass-surface-elevated {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(calc(var(--glass-blur) + 4px)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) + 4px)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl), var(--glass-shadow-hover), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  will-change: transform;
}
.glass-surface-elevated::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--glass-highlight);
  opacity: 0.85;
  pointer-events: none;
  z-index: 0;
}
.glass-surface-elevated > * { position: relative; z-index: 1; }

/* Flat glass - minimal shadow, more transparency (background panel/widget) */
.glass-surface-flat {
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(calc(var(--glass-blur) - 6px)) saturate(140%);
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) - 6px)) saturate(140%);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  will-change: transform;
}

/* Hover variant - adds lift + glow + brighten on hover. Combine with any
.glass-surface* class: <div class="glass-surface glass-surface-hover"> */
.glass-surface-hover {
  transition:
    transform 0.3s var(--glass-ease),
    box-shadow 0.3s var(--glass-ease),
    border-color 0.3s var(--glass-ease-smooth),
    background 0.3s var(--glass-ease-smooth);
}
.glass-surface-hover:hover {
  transform: translateY(-3px) translateZ(0);
  box-shadow: var(--glass-shadow-hover), 0 0 0 1px var(--primary-100), inset 0 1px 0 rgba(255, 255, 255, 0.55);
  border-color: rgba(99, 102, 241, 0.35);
  background: rgba(255, 255, 255, 0.72);
}
.glass-surface-hover:active {
  transform: translateY(-1px) translateZ(0) scale(0.992);
  transition-duration: 0.08s;
}

/* Dark mode variants - deeper, more opaque glass with subtle light edges */
[data-theme="dark"] .glass-surface,
:root:not([data-theme]) .glass-surface {
  /* rely on cascade - explicit override only for non-themed auto dark */
}
[data-theme="dark"] .glass-surface {
  background: var(--glass-bg-dark);
  border-color: var(--glass-border-dark);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .glass-surface::before {
  background: var(--glass-highlight);
  opacity: 0.5;
}
[data-theme="dark"] .glass-surface-elevated {
  background: rgba(15, 23, 42, 0.7);
  border-color: var(--glass-border-dark);
  box-shadow: var(--shadow-xl), 0 12px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
[data-theme="dark"] .glass-surface-flat {
  background: rgba(30, 41, 59, 0.65);
  border-color: var(--glass-border-dark);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
[data-theme="dark"] .glass-surface-hover:hover {
  background: rgba(30, 41, 59, 0.78);
  border-color: rgba(99, 102, 241, 0.45);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(99, 102, 241, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* --------------------------------------------------------------------------
   3. GLASS INPUT FIELDS
   --------------------------------------------------------------------------
   Additive to the existing input rules at lines ~237, ~4782, ~6121, ~6719.
   Apply as <input class="glass-input"> (or alongside.fld /.form-control). */
.glass-input {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
  color: var(--text);
  padding: 12px 16px;
  font-size: 14px;
  font-family: inherit;
  box-shadow: inset 0 1px 2px rgba(17, 24, 39, 0.04), 0 1px 0 rgba(255, 255, 255, 0.4);
  transition:
    border-color 0.2s var(--glass-ease-smooth),
    box-shadow 0.2s var(--glass-ease-smooth),
    background 0.2s var(--glass-ease-smooth),
    backdrop-filter 0.2s var(--glass-ease-smooth);
  will-change: transform;
}
.glass-input::placeholder { color: var(--text-muted); }
.glass-input:hover {
  border-color: var(--primary-l);
  background: rgba(255, 255, 255, 0.65);
}
.glass-input:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  color: #2563EB;
  box-shadow:
    inset 0 1px 3px rgba(37, 99, 235, 0.12),
    0 0 0 4px var(--primary-50),
    0 0 0 1px var(--primary),
    0 4px 16px rgba(99, 102, 241, 0.15);
}
[data-theme="dark"] .glass-input {
  background: rgba(15, 23, 42, 0.55);
  border-color: var(--glass-border-dark);
  color: var(--text);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 0 rgba(255, 255, 255, 0.04);
}
[data-theme="dark"] .glass-input::placeholder { color: var(--text-muted); }
[data-theme="dark"] .glass-input:hover {
  border-color: var(--primary-l);
  background: rgba(30, 41, 59, 0.65);
}
[data-theme="dark"] .glass-input:focus {
  background: rgba(30, 41, 59, 0.78);
  border-color: var(--primary-l);
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.5),
    0 0 0 4px rgba(99, 102, 241, 0.25),
    0 0 0 1px var(--primary-l),
    0 4px 16px rgba(99, 102, 241, 0.25);
}

/* --------------------------------------------------------------------------
   4. GLASS NAVIGATION
   -------------------------------------------------------------------------- */
.glass-nav {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border);
  border-radius: var(--r-pill);
  box-shadow: var(--glass-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  padding: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  will-change: transform;
}
.glass-nav-item {
  position: relative;
  padding: 8px 16px;
  border-radius: var(--r-pill);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  transition:
    color 0.2s var(--glass-ease-smooth),
    background 0.25s var(--glass-ease),
    box-shadow 0.25s var(--glass-ease),
    transform 0.15s var(--glass-ease-smooth);
}
.glass-nav-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.glass-nav-item:active {
  transform: scale(0.96);
  transition-duration: 0.08s;
}
.glass-nav-item.active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-d) 100%);
  box-shadow:
    0 4px 12px rgba(99, 102, 241, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}
[data-theme="dark"] .glass-nav {
  background: var(--glass-bg-dark);
  border-color: var(--glass-border-dark);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .glass-nav-item { color: var(--text-3); }
[data-theme="dark"] .glass-nav-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
[data-theme="dark"] .glass-nav-item.active {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-d) 100%);
  box-shadow:
    0 4px 16px rgba(99, 102, 241, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25);
}

/* --------------------------------------------------------------------------
   5. GLASS BUTTONS
   -------------------------------------------------------------------------- */
.btn-glass {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition:
    transform 0.2s var(--glass-ease),
    background 0.2s var(--glass-ease-smooth),
    box-shadow 0.2s var(--glass-ease-smooth),
    border-color 0.2s var(--glass-ease-smooth),
    filter 0.2s var(--glass-ease-smooth);
  will-change: transform;
}
.btn-glass:hover {
  background: rgba(255, 255, 255, 0.75);
  border-color: var(--primary-l);
  transform: translateY(-2px) translateZ(0);
  box-shadow: var(--shadow-md), 0 0 0 1px var(--primary-100), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  filter: brightness(1.03);
}
.btn-glass:active {
  transform: translateY(0) scale(0.97);
  transition-duration: 0.08s;
  box-shadow: var(--shadow-xs), inset 0 1px 2px rgba(17, 24, 39, 0.1);
}

/* Primary-tinted glass button */
.btn-glass-primary {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.85) 0%, rgba(79, 70, 229, 0.85) 100%);
  color: #fff;
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.btn-glass-primary:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.95) 0%, rgba(79, 70, 229, 0.95) 100%);
  border-color: var(--primary);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4), 0 0 0 1px var(--primary-l), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  filter: brightness(1.06);
}

/* Accent-tinted glass button */
.btn-glass-accent {
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.85) 0%, rgba(13, 148, 136, 0.85) 100%);
  color: #fff;
  border-color: rgba(20, 184, 166, 0.5);
  box-shadow: 0 4px 12px rgba(20, 184, 166, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.btn-glass-accent:hover {
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.95) 0%, rgba(13, 148, 136, 0.95) 100%);
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(20, 184, 166, 0.4), 0 0 0 1px var(--accent-l), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  filter: brightness(1.06);
}

[data-theme="dark"] .btn-glass {
  background: rgba(30, 41, 59, 0.6);
  border-color: var(--glass-border-dark);
  color: var(--text);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .btn-glass:hover {
  background: rgba(30, 41, 59, 0.8);
  border-color: var(--primary-l);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(99, 102, 241, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
[data-theme="dark"] .btn-glass-primary {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.9) 0%, rgba(79, 70, 229, 0.9) 100%);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
[data-theme="dark"] .btn-glass-primary:hover {
  box-shadow: 0 8px 28px rgba(99, 102, 241, 0.55), 0 0 0 1px var(--primary-l), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
[data-theme="dark"] .btn-glass-accent {
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.9) 0%, rgba(13, 148, 136, 0.9) 100%);
  box-shadow: 0 4px 16px rgba(20, 184, 166, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
[data-theme="dark"] .btn-glass-accent:hover {
  box-shadow: 0 8px 28px rgba(20, 184, 166, 0.55), 0 0 0 1px var(--accent-l), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* --------------------------------------------------------------------------
   6. GLASS MODAL / OVERLAY (extends existing.glass-modal* at lines ~6448)
   -------------------------------------------------------------------------- */
/* Backdrop: deeper blur for focus separation. Existing rule at line ~6456
   sets blur(6px) - this stacks to push it to a richer frosted dim. */
.glass-modal-backdrop {
  background: radial-gradient(ellipse at center, rgba(15, 23, 42, 0.4) 0%, rgba(15, 23, 42, 0.55) 100%);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
}
/* Modal container - add light-leak highlight and refined shadow */
.glass-modal {
  position: relative;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(calc(var(--glass-blur) + 4px)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) + 4px)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-2xl), 0 0 0 1px rgba(255, 255, 255, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  overflow: hidden;
  will-change: transform;
}
.glass-modal::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--glass-highlight);
  opacity: 0.6;
  pointer-events: none;
  z-index: 0;
}
.glass-modal > * { position: relative; z-index: 1; }

/* Modal header - frosted divider with subtle gradient bottom edge */
.glass-modal-header {
  position: relative;
  padding: 20px 24px;
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--glass-border);
}
.glass-modal-header::after {
  content: "";
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--primary-l) 50%, transparent 100%);
  opacity: 0.5;
}
[data-theme="dark"] .glass-modal {
  background: rgba(15, 23, 42, 0.82);
  border-color: var(--glass-border-dark);
  box-shadow: 0 32px 64px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
[data-theme="dark"] .glass-modal::before { opacity: 0.35; }
[data-theme="dark"] .glass-modal-header {
  background: rgba(30, 41, 59, 0.45);
  border-bottom-color: var(--glass-border-dark);
}
[data-theme="dark"] .glass-modal-header::after {
  background: linear-gradient(90deg, transparent 0%, var(--primary) 50%, transparent 100%);
  opacity: 0.6;
}

/* --------------------------------------------------------------------------
   7. DEPTH LAYERING SYSTEM
   --------------------------------------------------------------------------
   Uses translateZ for hardware-accelerated depth. Apply alongside any
   surface class to push it visually forward in the z-stack. */
/* (S258-D1) the depth micro-scale's z-index lines (1-4) are retired:
   elevation is expressed by the translateZ transforms alone; the raw
   2/3/4 were non-ladder z-index values the A-06 wall flagged (the
   depth-2 dashboard metric cards) — the depth classes never overlap
   siblings, so the micro-z was dead weight that violated the ladder.
   The wrapped bundles re-derive this sheet at build time. */
.depth-1 {
  transform: translateZ(1px);
  box-shadow: var(--shadow-xs);
}
.depth-2 {
  transform: translateZ(2px);
  box-shadow: var(--shadow-md);
}
.depth-3 {
  transform: translateZ(4px);
  box-shadow: var(--shadow-lg);
}
.depth-4 {
  transform: translateZ(8px);
  box-shadow: var(--shadow-xl);
}
/* When a depth class is combined with hover transforms, preserve the Z */
.depth-1:hover { transform: translateZ(1px) translateY(-2px); }
.depth-2:hover { transform: translateZ(2px) translateY(-2px); }
.depth-3:hover { transform: translateZ(4px) translateY(-3px); }
.depth-4:hover { transform: translateZ(8px) translateY(-4px); }

/* --------------------------------------------------------------------------
   8. AMBIENT BACKGROUND EFFECTS
   -------------------------------------------------------------------------- */

/* Radial glow behind an element - apply to a parent with position:relative
   and an absolute-positioned::before, OR drop an empty <div class="ambient-glow">
   as the first child of a relative container. */
.ambient-glow {
  position: absolute;
  inset: -20%;
  background: radial-gradient(circle at 50% 50%, var(--primary-50) 0%, transparent 60%);
  opacity: 0.7;
  filter: blur(40px);
  pointer-events: none;
  z-index: 0;
  border-radius: 50%;
}
.ambient-glow.accent {
  background: radial-gradient(circle at 50% 50%, var(--accent-50) 0%, transparent 60%);
}
.ambient-glow.warm {
  background: radial-gradient(circle at 50% 50%, var(--amber-50) 0%, transparent 60%);
}

/* Animated gradient mesh - performant (only background-position animates) */
.ambient-mesh {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(at 20% 30%, var(--primary-50) 0px, transparent 50%),
    radial-gradient(at 80% 20%, var(--accent-50) 0px, transparent 50%),
    radial-gradient(at 60% 80%, var(--amber-50) 0px, transparent 50%),
    radial-gradient(at 30% 70%, var(--rose-50) 0px, transparent 50%);
  background-size: 200% 200%, 200% 200%, 200% 200%, 200% 200%;
  animation: ambientMeshShift 18s var(--glass-ease-smooth) infinite alternate;
  opacity: 0.6;
  pointer-events: none;
  z-index: 0;
}
@keyframes ambientMeshShift {
  0%   { background-position: 0% 0%, 100% 0%, 50% 100%, 0% 50%; }
  100% { background-position: 100% 50%, 0% 100%, 0% 50%, 100% 0%; }
}

/* Floating orb - a blurred soft circle that drifts gently */
.ambient-orb {
  position: absolute;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--primary-l) 0%, var(--primary) 40%, transparent 70%);
  filter: blur(50px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
  animation: ambientOrbFloat 14s ease-in-out infinite;
}
.ambient-orb.accent {
  background: radial-gradient(circle at 30% 30%, var(--accent-l) 0%, var(--accent) 40%, transparent 70%);
}
.ambient-orb.warm {
  background: radial-gradient(circle at 30% 30%, var(--amber-l) 0%, var(--amber) 40%, transparent 70%);
}
@keyframes ambientOrbFloat {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  33%      { transform: translate3d(40px, -30px, 0) scale(1.08); }
  66%      { transform: translate3d(-30px, 25px, 0) scale(0.94); }
}

[data-theme="dark"] .ambient-glow { opacity: 0.4; }
[data-theme="dark"] .ambient-mesh { opacity: 0.35; }
[data-theme="dark"] .ambient-orb { opacity: 0.25; }

/* --------------------------------------------------------------------------
   9. GLASS BADGES & CHIPS
   -------------------------------------------------------------------------- */
.glass-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(10px) saturate(160%);
  -webkit-backdrop-filter: blur(10px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  line-height: 1.4;
}
.glass-badge.primary {
  background: rgba(99, 102, 241, 0.18);
  color: var(--primary-d);
  border-color: rgba(99, 102, 241, 0.35);
}
.glass-badge.accent {
  background: rgba(20, 184, 166, 0.18);
  color: var(--accent-d);
  border-color: rgba(20, 184, 166, 0.35);
}
.glass-badge.warm {
  background: rgba(245, 158, 11, 0.18);
  color: var(--amber);
  border-color: rgba(245, 158, 11, 0.35);
}
.glass-badge.danger {
  background: rgba(244, 63, 94, 0.18);
  color: var(--rose);
  border-color: rgba(244, 63, 94, 0.35);
}

.glass-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(10px) saturate(150%);
  -webkit-backdrop-filter: blur(10px) saturate(150%);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  transition:
    background 0.2s var(--glass-ease-smooth),
    border-color 0.2s var(--glass-ease-smooth),
    box-shadow 0.2s var(--glass-ease-smooth),
    transform 0.15s var(--glass-ease-press);
}
.glass-chip:hover {
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--primary-l);
  transform: translateY(-1px);
}
.glass-chip:active { transform: translateY(0) scale(0.96); }
.glass-chip.selected,
.glass-chip[aria-pressed="true"] {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.85), rgba(79, 70, 229, 0.85));
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.glass-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

[data-theme="dark"] .glass-badge,
[data-theme="dark"] .glass-chip,
[data-theme="dark"] .glass-tag {
  background: rgba(30, 41, 59, 0.55);
  border-color: var(--glass-border-dark);
  color: var(--text-3);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
[data-theme="dark"] .glass-badge.primary { background: rgba(99, 102, 241, 0.25); color: var(--primary-l); border-color: rgba(99, 102, 241, 0.4); }
[data-theme="dark"] .glass-badge.accent  { background: rgba(20, 184, 166, 0.25); color: var(--accent-l); border-color: rgba(20, 184, 166, 0.4); }
[data-theme="dark"] .glass-badge.warm    { background: rgba(245, 158, 11, 0.25); color: var(--amber-l); border-color: rgba(245, 158, 11, 0.4); }
[data-theme="dark"] .glass-badge.danger  { background: rgba(244, 63, 94, 0.25); color: var(--rose-l); border-color: rgba(244, 63, 94, 0.4); }
[data-theme="dark"] .glass-chip:hover { background: rgba(30, 41, 59, 0.75); border-color: var(--primary-l); }
[data-theme="dark"] .glass-chip.selected,
[data-theme="dark"] .glass-chip[aria-pressed="true"] {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.9), rgba(79, 70, 229, 0.9));
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* --------------------------------------------------------------------------
   10. GLASS STATS / METRICS
   -------------------------------------------------------------------------- */
.glass-stat {
  position: relative;
  padding: 20px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  box-shadow: var(--glass-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  overflow: hidden;
  will-change: transform;
}
/* Top accent bar - light leak */
.glass-stat::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: 0.7;
}
/* Soft glow behind the number */
.glass-stat::after {
  content: "";
  position: absolute;
  top: -40px; right: -40px;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--primary-50) 0%, transparent 70%);
  opacity: 0.6;
  filter: blur(20px);
  pointer-events: none;
  z-index: 0;
}
.glass-stat > * { position: relative; z-index: 1; }

.glass-stat-value {
  display: block;
  font-family: var(--font-sans);
  font-size: 32px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  margin-bottom: 4px;
}
.glass-stat-value.text,
[data-theme="dark"] .glass-stat-value.text {
  background: none;
  -webkit-text-fill-color: initial;
  color: var(--text);
  -webkit-text-fill-color: var(--text);
}
.glass-stat-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
[data-theme="dark"] .glass-stat {
  background: var(--glass-bg-dark);
  border-color: var(--glass-border-dark);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .glass-stat::after {
  background: radial-gradient(circle, rgba(99, 102, 241, 0.18) 0%, transparent 70%);
  opacity: 0.7;
}
[data-theme="dark"] .glass-stat-value {
  background: linear-gradient(135deg, var(--primary-l) 0%, var(--accent-l) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* --------------------------------------------------------------------------
   11. GLASS PROGRESS ELEMENTS
   -------------------------------------------------------------------------- */
.glass-progress {
  position: relative;
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-pill);
  box-shadow: inset 0 1px 2px rgba(17, 24, 39, 0.08), 0 1px 0 rgba(255, 255, 255, 0.4);
  overflow: hidden;
}
.glass-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: var(--r-pill);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: width 0.5s var(--glass-ease);
  position: relative;
}
/* Shimmering specular highlight moving across the fill */
.glass-progress-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.5) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: glassProgressShimmer 2.4s linear infinite;
  border-radius: inherit;
}
@keyframes glassProgressShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
[data-theme="dark"] .glass-progress {
  background: rgba(30, 41, 59, 0.5);
  border-color: var(--glass-border-dark);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 0 rgba(255, 255, 255, 0.04);
}
[data-theme="dark"] .glass-progress-fill {
  background: linear-gradient(90deg, var(--primary-l) 0%, var(--accent-l) 100%);
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Circular progress - for SVG rings. Apply.glass-ring to the <svg> or its
   container; style the circle stroke via existing CSS variables. */
.glass-ring {
  filter: drop-shadow(0 4px 12px rgba(99, 102, 241, 0.2));
}
.glass-ring circle,
.glass-ring .ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.3);
  stroke-width: 8;
  stroke-linecap: round;
}
.glass-ring .ring-fill {
  stroke: url(#glass-ring-gradient);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s var(--glass-ease);
}
/* Fallback solid stroke when no <linearGradient id="glass-ring-gradient"> */
.glass-ring .ring-fill:not([stroke]) {
  stroke: var(--primary);
}
[data-theme="dark"] .glass-ring circle,
[data-theme="dark"] .glass-ring .ring-track {
  stroke: rgba(255, 255, 255, 0.08);
}
[data-theme="dark"] .glass-ring {
  filter: drop-shadow(0 4px 16px rgba(99, 102, 241, 0.4));
}

/* --------------------------------------------------------------------------
   12. HOVER / ACTIVE MICRO-INTERACTIONS
   -------------------------------------------------------------------------- */

/* Brighten glass on hover - increases background opacity + light edge */
.hover-glass-brighten {
  transition:
    background 0.25s var(--glass-ease-smooth),
    box-shadow 0.25s var(--glass-ease-smooth),
    border-color 0.25s var(--glass-ease-smooth);
}
.hover-glass-brighten:hover {
  background: rgba(255, 255, 255, 0.78) !important;
  border-color: rgba(255, 255, 255, 0.45) !important;
  box-shadow: var(--glass-shadow-hover), inset 0 1px 0 rgba(255, 255, 255, 0.55) !important;
}
[data-theme="dark"] .hover-glass-brighten:hover {
  background: rgba(30, 41, 59, 0.78) !important;
  border-color: rgba(255, 255, 255, 0.15) !important;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
}

/* Press = depress effect on active - slight scale-down + inset shadow */
.hover-glass-press {
  transition:
    transform 0.12s var(--glass-ease-press),
    box-shadow 0.12s var(--glass-ease-press);
  will-change: transform;
}
.hover-glass-press:active {
  transform: scale(0.97) translateZ(0);
  box-shadow: var(--shadow-xs), inset 0 2px 4px rgba(17, 24, 39, 0.12) !important;
}
[data-theme="dark"] .hover-glass-press:active {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(0, 0, 0, 0.45) !important;
}

/* Colored glow on hover - primary-tinted halo */
.hover-glass-glow {
  transition:
    box-shadow 0.3s var(--glass-ease),
    transform 0.2s var(--glass-ease),
    border-color 0.25s var(--glass-ease-smooth);
}
.hover-glass-glow:hover {
  transform: translateY(-2px) translateZ(0);
  border-color: var(--primary-l) !important;
  box-shadow:
    0 0 0 1px var(--primary-100),
    0 8px 24px rgba(99, 102, 241, 0.25),
    0 2px 8px rgba(17, 24, 39, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
}
.hover-glass-glow.accent:hover {
  border-color: var(--accent-l) !important;
  box-shadow:
    0 0 0 1px var(--accent-100),
    0 8px 24px rgba(20, 184, 166, 0.25),
    0 2px 8px rgba(17, 24, 39, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
}
[data-theme="dark"] .hover-glass-glow:hover {
  border-color: var(--primary-l) !important;
  box-shadow:
    0 0 0 1px rgba(99, 102, 241, 0.4),
    0 8px 28px rgba(99, 102, 241, 0.4),
    0 2px 8px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
}
[data-theme="dark"] .hover-glass-glow.accent:hover {
  border-color: var(--accent-l) !important;
  box-shadow:
    0 0 0 1px rgba(20, 184, 166, 0.4),
    0 8px 28px rgba(20, 184, 166, 0.4),
    0 2px 8px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
}

/* --------------------------------------------------------------------------
   13. RESPONSIVE GLASS (mobile performance + readability)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  :root {
    --glass-blur: 10px;        /* halve blur for mobile GPU performance */
    --glass-saturate: 140%;    /* less saturation = less compositing cost */
    --glass-bg: rgba(255, 255, 255, 0.8); /* higher opacity = readability */
  }
  [data-theme="dark"] {
    --glass-bg: rgba(15, 23, 42, 0.78);
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
      --glass-bg: rgba(15, 23, 42, 0.78);
    }
  }

  .glass-surface,
  .glass-surface-elevated,
  .glass-surface-flat,
  .glass-modal,
  .glass-nav,
  .glass-stat {
    backdrop-filter: blur(10px) saturate(140%);
    -webkit-backdrop-filter: blur(10px) saturate(140%);
  }
  .glass-surface-elevated {
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
  }

  /* Stat numbers shrink on small screens */
  .glass-stat-value { font-size: 26px; }

  /* Orbs become smaller / cheaper */
  .ambient-orb {
    width: 200px;
    height: 200px;
    filter: blur(35px);
  }

  /* Modal header padding tightens */
  .glass-modal-header { padding: 16px 18px; }

  /* Depth layering reduced on mobile (translateZ can cause subpixel
     artifacts on low-DPR mobile displays) */
  .depth-1, .depth-2, .depth-3, .depth-4 {
    transform: none;
  }
}

/* Very small screens - disable ambient mesh animation entirely */
@media (max-width: 480px) {
  .ambient-mesh { animation: none; opacity: 0.4; }
  .ambient-orb { animation: none; }
  .glass-stat-value { font-size: 22px; }
}

/* --------------------------------------------------------------------------
   14. PERFORMANCE: @supports fallback + reduced motion
   -------------------------------------------------------------------------- */

/* Fallback for browsers without backdrop-filter support - give glass
   surfaces an opaque-enough background so content stays readable. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass-surface,
  .glass-surface-elevated,
  .glass-surface-flat,
  .glass-modal,
  .glass-nav,
  .glass-stat,
  .glass-input,
  .btn-glass,
  .glass-badge,
  .glass-chip,
  .glass-tag,
  .glass-progress {
    background: var(--surface);
  }
  [data-theme="dark"] .glass-surface,
  [data-theme="dark"] .glass-surface-elevated,
  [data-theme="dark"] .glass-surface-flat,
  [data-theme="dark"] .glass-modal,
  [data-theme="dark"] .glass-nav,
  [data-theme="dark"] .glass-stat,
  [data-theme="dark"] .glass-input,
  [data-theme="dark"] .btn-glass,
  [data-theme="dark"] .glass-badge,
  [data-theme="dark"] .glass-chip,
  [data-theme="dark"] .glass-tag,
  [data-theme="dark"] .glass-progress {
    background: var(--surface);
  }
  .glass-modal-backdrop { background: rgba(15, 23, 42, 0.7); }
}

/* Universal reduced-motion guard - disables ALL.0 animations and
   depth transforms. Stacks with the existing block at line ~6799. */
@media (prefers-reduced-motion: reduce) {
  .glass-surface,
  .glass-surface-elevated,
  .glass-surface-flat,
  .glass-surface-hover,
  .glass-input,
  .glass-nav-item,
  .btn-glass,
  .btn-glass-primary,
  .btn-glass-accent,
  .glass-chip,
  .glass-progress-fill,
  .glass-ring .ring-fill,
  .hover-glass-brighten,
  .hover-glass-press,
  .hover-glass-glow,
  .depth-1, .depth-2, .depth-3, .depth-4 {
    animation: none !important;
    transition: none !important;
    transform: none !important;
    will-change: auto !important;
  }
  .ambient-mesh,
  .ambient-orb,
  .glass-progress-fill::after {
    animation: none !important;
  }
  .ambient-orb { transform: none !important; }
  .glass-surface-hover:hover,
  .btn-glass:hover,
  .hover-glass-glow:hover,
  .depth-1:hover, .depth-2:hover, .depth-3:hover, .depth-4:hover {
    transform: none !important;
  }
  .glass-surface-hover:active,
  .btn-glass:active,
  .hover-glass-press:active,
  .glass-chip:active,
  .glass-nav-item:active {
    transform: none !important;
  }
}

/* ==========================================================================
   END.0 GLASSMORPHISM IMMERSIVE SYSTEM
   ==========================================================================

/* ==========================================================================
   PAGINATION CONTROLS (.0)
   Used by blog, restaurants, tools, resources index pages.
   Powered by /assets/js/pagination.js
   ========================================================================== */
.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 32px auto 16px;
  padding: 16px 0;
  font-family: var(--font-sans);
}
.pagination-controls .page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s ease;
  text-decoration: none;
  box-sizing: border-box;
}
.pagination-controls .page-btn:hover:not(.disabled):not(.active) {
  background: var(--primary-50);
  border-color: var(--primary);
  color: var(--primary-d);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.pagination-controls .page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  cursor: default;
}
.pagination-controls .page-btn.disabled {
  opacity: .45;
  cursor: not-allowed;
}
.pagination-controls .page-ellipsis {
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  color: var(--text-muted);
  font-size: 14px;
}
.pagination-controls .page-info {
  margin-left: 16px;
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}
@media (max-width: 640px) {
  .pagination-controls .page-info {
    width: 100%;
    text-align: center;
    margin: 8px 0 0;
  }
  .pagination-controls .page-btn {
    min-width: 36px;
    height: 36px;
    font-size: 13px;
    padding: 0 8px;
  }
}

/* ==========================================================================
   ARTICLE IMAGES (blog post image styling)
   ========================================================================== */
.article-image {
  margin: 24px 0;
  border-radius: var(--r-md);
  overflow: hidden;
}
.article-image img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--r-md);
}
.article-image figcaption {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
}
.article-image .image-credit {
  font-style: normal;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.8;
}

/* ==========================================================================
   VIDEO EMBEDS (blog post video styling)
   ========================================================================== */
.video-embed {
  position: relative;
  margin: 24px 0;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: var(--r-md);
}
.video-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ==========================================================================
   RESEARCH ARTICLE BLOCKS & AUTHOR PROFILES (V8290-CMS)
   ========================================================================== */
.article-byline-author {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.article-byline-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid rgba(62,142,99,0.3);
}
.article-featured-media {
  margin: 24px 0 32px;
  border-radius: var(--r-lg, 14px);
  overflow: hidden;
  background: var(--surface-2, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
}
.article-featured-media img {
  width: 100%;
  max-height: 520px;
  object-fit: cover;
  display: block;
}
.article-featured-media figcaption {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-muted);
  border-top: 1px solid var(--border, #e2e8f0);
  background: var(--surface, #ffffff);
}
.author-bio-card {
  margin: 40px 0 32px;
  padding: 24px;
  border-radius: var(--r-lg, 14px);
  background: var(--surface-2, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
@media (max-width: 640px) {
  .author-bio-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}
.author-bio-card img {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary, #3E8E63);
  flex-shrink: 0;
}

/* Callout Boxes */
.article-callout {
  margin: 28px 0;
  padding: 18px 22px;
  border-radius: var(--r-md, 10px);
  border-left: 4px solid var(--primary, #3E8E63);
  background: var(--surface-2, #f8fafc);
  font-size: 15px;
  line-height: 1.6;
}
.article-callout.callout-takeaway {
  border-left-color: #3E8E63;
  background: rgba(62, 142, 99, 0.06);
}
.article-callout.callout-clinical {
  border-left-color: #3D7FBF;
  background: rgba(61, 127, 191, 0.06);
}
.article-callout.callout-study {
  border-left-color: #8B5CF6;
  background: rgba(139, 92, 246, 0.06);
}
.article-callout.callout-warning {
  border-left-color: #D9705B;
  background: rgba(217, 112, 91, 0.06);
}
.article-callout-header {
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.callout-takeaway .article-callout-header { color: #2e6d4c; }
.callout-clinical .article-callout-header { color: #2b5d8f; }
.callout-study .article-callout-header { color: #6d3ec4; }
.callout-warning .article-callout-header { color: #b84c37; }

/* Multi-Image Comparison Gallery */
.article-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 28px 0;
}
.article-gallery figure {
  margin: 0;
  border-radius: var(--r-md, 10px);
  overflow: hidden;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--surface, #ffffff);
}
.article-gallery img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}
.article-gallery figcaption {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* Scientific Data Table */
.article-data-table-wrap {
  margin: 28px 0;
  overflow-x: auto;
  border-radius: var(--r-md, 10px);
  border: 1px solid var(--border, #e2e8f0);
}
.article-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  text-align: left;
}
.article-data-table th {
  background: var(--surface-2, #f8fafc);
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text, #1e293b);
  border-bottom: 2px solid var(--border, #e2e8f0);
}
.article-data-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}
.article-data-table tr:last-child td {
  border-bottom: none;
}
.article-data-table tr:hover td {
  background: rgba(0, 0, 0, 0.02);
}

/* Citation / PubMed Box */
.article-citation-box {
  margin: 24px 0;
  padding: 14px 18px;
  border-radius: var(--r-sm, 6px);
  background: var(--surface-2, #f8fafc);
  border: 1px dashed var(--border, #cbd5e1);
  font-size: 13px;
  color: var(--text-muted);
}

/* ==========================================================================
   Comprehensive Theme Mode Support for Newsletter & Cards
   (Light, Dark, Dark-Gray, Sepia, High-Contrast, Colorblind)
   ========================================================================== */

.newsletter-section {
  padding: 64px 24px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.06), rgba(16, 185, 129, 0.06));
  transition: background 0.3s ease, color 0.3s ease;
}

.newsletter-card {
  text-align: center;
  max-width: 680px;
  margin: 0 auto;
  padding: 44px 32px;
  border-radius: var(--r-lg, 16px);
  background: var(--surface-1, #ffffff);
  border: 1px solid var(--border, rgba(0,0,0,0.08));
  box-shadow: 0 20px 40px -15px rgba(0,0,0,0.07);
  transition: all 0.3s ease;
}

.newsletter-eyebrow {
  color: var(--primary, #2563eb);
  background: var(--primary-light, rgba(37, 99, 235, 0.1));
  border: 1px solid rgba(37, 99, 235, 0.2);
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.newsletter-title {
  color: var(--text-1, #0f172a);
  font-size: 28px;
  font-weight: 700;
  margin: 14px 0 8px 0;
  line-height: 1.25;
}

.newsletter-desc {
  font-size: 16px;
  color: var(--text-2, #475569);
  margin-bottom: 24px;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

.newsletter-form {
  display: flex;
  gap: 10px;
  max-width: 480px;
  margin: 0 auto;
  flex-wrap: wrap;
  justify-content: center;
}

.newsletter-input {
  flex: 1;
  min-width: 220px;
  padding: 13px 16px;
  border-radius: var(--r-sm, 8px);
  border: 1.5px solid var(--border-2, #cbd5e1);
  background: var(--surface-1, #ffffff);
  color: var(--text-1, #0f172a);
  font-size: 15px;
  transition: all 0.2s ease;
}

.newsletter-input:focus {
  outline: none;
  border-color: var(--primary, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.newsletter-btn {
  background: var(--primary, #2563eb);
  color: #ffffff;
  border: none;
  font-weight: 600;
  padding: 13px 28px;
  border-radius: var(--r-sm, 8px);
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.newsletter-btn:hover {
  background: var(--primary-d, #1d4ed8);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.newsletter-msg {
  margin-top: 12px;
  font-size: 13px;
  min-height: 18px;
}

.newsletter-footer-note {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-3, #64748b);
}

/* --- Dark Mode --- */
[data-theme="dark"] .newsletter-section {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(30, 41, 59, 0.9));
}
[data-theme="dark"] .newsletter-card {
  background: #1e293b;
  border: 1px solid #334155;
  box-shadow: 0 20px 40px -15px rgba(0,0,0,0.5);
}
[data-theme="dark"] .newsletter-eyebrow {
  color: #60a5fa;
  background: rgba(96, 165, 250, 0.12);
  border-color: rgba(96, 165, 250, 0.25);
}
[data-theme="dark"] .newsletter-title {
  color: #f8fafc;
}
[data-theme="dark"] .newsletter-desc {
  color: #cbd5e1;
}
[data-theme="dark"] .newsletter-input {
  background: #0f172a;
  border-color: #334155;
  color: #f8fafc;
}
[data-theme="dark"] .newsletter-input::placeholder {
  color: #64748b;
}
[data-theme="dark"] .newsletter-btn {
  background: #3b82f6;
  color: #ffffff;
}
[data-theme="dark"] .newsletter-btn:hover {
  background: #2563eb;
}
[data-theme="dark"] .newsletter-footer-note {
  color: #94a3b8;
}

/* --- Dark-Gray / Dark-Grey Mode --- */
[data-theme="dark-gray"] .newsletter-section,
[data-theme="dark-grey"] .newsletter-section {
  background: linear-gradient(135deg, #181c24, #272d37);
}
[data-theme="dark-gray"] .newsletter-card,
[data-theme="dark-grey"] .newsletter-card {
  background: #222831;
  border: 1px solid #393e46;
  box-shadow: 0 20px 40px -15px rgba(0,0,0,0.6);
}
[data-theme="dark-gray"] .newsletter-eyebrow,
[data-theme="dark-grey"] .newsletter-eyebrow {
  color: #00adb5;
  background: rgba(0, 173, 181, 0.15);
  border-color: rgba(0, 173, 181, 0.3);
}
[data-theme="dark-gray"] .newsletter-title,
[data-theme="dark-grey"] .newsletter-title {
  color: #eeeeee;
}
[data-theme="dark-gray"] .newsletter-desc,
[data-theme="dark-grey"] .newsletter-desc {
  color: #b2bec3;
}
[data-theme="dark-gray"] .newsletter-input,
[data-theme="dark-grey"] .newsletter-input {
  background: #181c24;
  border-color: #393e46;
  color: #eeeeee;
}
[data-theme="dark-gray"] .newsletter-input::placeholder,
[data-theme="dark-grey"] .newsletter-input::placeholder {
  color: #718096;
}
[data-theme="dark-gray"] .newsletter-btn,
[data-theme="dark-grey"] .newsletter-btn {
  background: #00adb5;
  color: #ffffff;
}
[data-theme="dark-gray"] .newsletter-footer-note,
[data-theme="dark-grey"] .newsletter-footer-note {
  color: #8c9ba5;
}

/* --- Sepia Mode --- */
[data-theme="sepia"] .newsletter-section {
  background: #f4ecd8;
}
[data-theme="sepia"] .newsletter-card {
  background: #fffdf5;
  border: 1px solid #e2d2b4;
  box-shadow: 0 10px 30px rgba(92, 64, 30, 0.08);
}
[data-theme="sepia"] .newsletter-eyebrow {
  color: #8c5d2b;
  background: rgba(140, 93, 43, 0.12);
  border-color: rgba(140, 93, 43, 0.25);
}
[data-theme="sepia"] .newsletter-title {
  color: #433422;
}
[data-theme="sepia"] .newsletter-desc {
  color: #63503b;
}
[data-theme="sepia"] .newsletter-input {
  background: #fff8e8;
  border-color: #d4c2a3;
  color: #3d2f1e;
}
[data-theme="sepia"] .newsletter-input::placeholder {
  color: #9e8870;
}
[data-theme="sepia"] .newsletter-btn {
  background: #8c5d2b;
  color: #ffffff;
}
[data-theme="sepia"] .newsletter-footer-note {
  color: #7d6852;
}

/* --- High Contrast Mode --- */
[data-theme="high-contrast"] .newsletter-section {
  background: #000000;
}
[data-theme="high-contrast"] .newsletter-card {
  background: #000000;
  border: 3px solid #ffffff;
  box-shadow: none;
}
[data-theme="high-contrast"] .newsletter-eyebrow {
  color: #ffff00;
  background: #000000;
  border: 2px solid #ffff00;
  font-weight: 800;
}
[data-theme="high-contrast"] .newsletter-title {
  color: #ffffff;
  font-weight: 800;
}
[data-theme="high-contrast"] .newsletter-desc {
  color: #ffffff;
  font-size: 18px;
}
[data-theme="high-contrast"] .newsletter-input {
  background: #000000;
  border: 2px solid #ffffff;
  color: #ffffff;
  font-weight: 700;
}
[data-theme="high-contrast"] .newsletter-input::placeholder {
  color: #cccccc;
}
[data-theme="high-contrast"] .newsletter-btn {
  background: #ffff00;
  color: #000000;
  font-weight: 800;
  border: 2px solid #ffffff;
}
[data-theme="high-contrast"] .newsletter-footer-note {
  color: #ffffff;
}

/* --- Colorblind Mode --- */
[data-theme="colorblind"] .newsletter-section {
  background: var(--surface-2);
}
/* (fix) --surface-1/--text-1 were never defined anywhere in the cascade;
   they rendered as transparent/inherited in colorblind mode. Map them
   to the real tokens. */
[data-theme="colorblind"] {
  --surface-1: #FFFFFF;
  --text-1: #0F172A;
}
[data-theme="colorblind"] .newsletter-card {
  background: var(--surface-1);
  border: 2px solid var(--primary);
}
[data-theme="colorblind"] .newsletter-eyebrow {
  color:var(--primary-text);
  border: 2px solid var(--primary);
}
[data-theme="colorblind"] .newsletter-title {
  color: var(--text-1);
}
[data-theme="colorblind"] .newsletter-desc {
  color: var(--text-2);
}
[data-theme="colorblind"] .newsletter-input {
  background: var(--surface-1);
  border: 2px solid var(--primary);
  color: var(--text-1);
}
[data-theme="colorblind"] .newsletter-btn {
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
}
[data-theme="colorblind"] .newsletter-footer-note {
  color: var(--text-3);
}

/* ============================================================
 * DASHBOARD POLISH LAYER (Phase I)
 * ============================================================
 * The user dashboard was reported "messy and visually dull".
 * This layer upgrades the dash-card / metric-card / qa-card
 * system with refined depth, hover affordance, and accent
 * detailing - applied through the shared stylesheet so every
 * dashboard page (index, goals, security, subscription,
 * messages, settings) inherits it without PHP surgery.
 * ============================================================ */

/* --- Card depth + hover lift --- */
.dash-card {
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.22s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.22s ease;
  position: relative;
}
.dash-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.10),
              0 2px 8px rgba(15, 23, 42, 0.05);
  border-color: var(--primary-100);
}

/* Top accent hairline - brand color gradient edge */
.dash-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  border-radius: var(--r-md) var(--r-md) 0 0;
  background: linear-gradient(90deg,
    var(--primary) 0%, var(--primary-l) 35%,
    var(--accent) 70%, var(--accent-l) 100%);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.dash-card:hover::before { opacity: 0.9; }

/* --- Card headers: clearer hierarchy --- */
.dash-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.dash-card-head .head-action {
  opacity: 0.55;
  transition: opacity 0.15s ease;
}
.dash-card:hover .dash-card-head .head-action { opacity: 1; }

/* --- Metric cards: value emphasis + delta coloring --- */
.metric-card {
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.22s ease;
}
.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.09);
}
.metric-card .metric-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-50);
  color:var(--primary-text);
  flex: 0 0 auto;
}
.metric-card .metric-icon svg { width: 19px; height: 19px; }

/* --- Quick-action cards: primary conversion surface --- */
.qa-card {
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.22s ease, border-color 0.22s ease;
  cursor: pointer;
}
.qa-card:hover {
  transform: translateY(-3px) scale(1.01);
  border-color: var(--accent);
  box-shadow: 0 14px 34px rgba(34, 197, 94, 0.14),
              0 2px 8px rgba(15, 23, 42, 0.05);
}
.qa-card .qa-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent-50), var(--primary-50));
  color: var(--accent-d);
  flex: 0 0 auto;
  transition: transform 0.2s ease;
}
.qa-card:hover .qa-icon { transform: scale(1.08) rotate(-3deg); }

/* --- Dashboard hero: richer gradient wash --- */
.dash-hero {
  background-image:
    radial-gradient(480px circle at 85% -10%, rgba(96, 165, 250, 0.18), transparent 60%),
    radial-gradient(380px circle at 0% 110%, rgba(74, 222, 128, 0.14), transparent 60%);
}

/* --- Stat pills in hero --- */
.dp-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
[data-theme="dark"] .dp-stat {
  background: rgba(30, 41, 59, 0.6);
}

/* --- Section rhythm: consistent breathing room --- */
.dash-section + .dash-section { margin-top: 28px; }

/* --- Progress rings on dashboard: smoother arc --- */
.ring-wrap circle {
  transition: stroke-dashoffset 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reduced motion: strip transitions --- */
@media (prefers-reduced-motion: reduce) {
  .dash-card, .metric-card, .qa-card { transition: none; }
  .dash-card:hover, .metric-card:hover, .qa-card:hover { transform: none; }
  .ring-wrap circle { transition: none; }
}

/* ============================================================
 * MICRO-INTERACTION POLISH (ported from -enhancements)
 * ============================================================
 * 's button feel: press-down scale + smooth transitions.
 * Subtle, but it's what made feel responsive to the touch.
 * ============================================================ */
.btn,
.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-gradient,
button[type="submit"],
button[type="button"] {
  transition:
    transform 120ms cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 200ms cubic-bezier(0.16, 1, 0.3, 1),
    background-color 200ms ease,
    border-color 200ms ease;
}
.btn:active,
.btn-primary:active,
.btn-secondary:active,
.btn-ghost:active,
.btn-gradient:active,
button[type="submit"]:active,
button[type="button"]:active {
  transform: translateY(1px) scale(0.985);
}

/* Focus ring parity - keyboard users get the same quality cue */
.btn:focus-visible,
.btn-primary:focus-visible,
.btn-ghost:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/*  card hover lift - applies to interactive cards only */
a.tool-card,
a.goal-card,
a.blog-card,
a.calc-card,
a.feature-card {
  transition:
    transform 200ms cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 200ms cubic-bezier(0.16, 1, 0.3, 1),
    border-color 200ms ease;
}
a.tool-card:active,
a.goal-card:active,
a.blog-card:active {
  transform: translateY(1px) scale(0.992);
}

@media (prefers-reduced-motion: reduce) {
  .btn, .btn-primary, .btn-ghost, a.tool-card, a.goal-card { transition: none; }
  .btn:active, a.tool-card:active { transform: none; }
}

/* ============================================================
 * ( audit UI-1) Header width-tier system. (S133-W1 phase-2) RE-BASED:
 * the public inline band now exists only ≥1280 (the six-row designed
 * composition + the §4 ladder in macrition-ui.css), so the legacy
 * tiers below 1280 serve the drawer band only. The ≤1280 Home-drop
 * tier is retired (C9: the brand is Home; the registry re-orders the
 * band; the drawer always shows Home).
 * dashboard flat nav (6 items) ≈ 640px → fits ≥1080px as-is
 * public band (six rows, the phase-2 composition) → the ladder owns
 * 1280-1365 (L1/L2/L3); ≥1366 renders at the W1 scale
 * ≤1279px - the drawer band: the legacy tighten tier + the dashboard
 * icon-only/tighten tiers keep their pre-phase-2 behavior
 * ============================================================ */
@media (max-width: 1279px) and (min-width: 981px) {
  .main-nav>a,
  .nav-item>a {
    padding-left: 9px;
    padding-right: 9px;
    font-size: 13.5px;
  }
  .main-nav>a>.nav-icon {
    width: 14px;
    height: 14px;
  }
  #navAuth {
    min-width: 0;
  }
  #navAuth a span:not(.avatar):not(.user-avatar) {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
  }
}

@media (max-width: 1279px) and (min-width: 981px) {
  /* (S133-W1 phase-2) the legacy Home-drop tier is RETIRED: C9 retired
     the labeled Home row from the designed composition entirely (the
     brand affordance is its expression), the registry re-orders the
     band so :first-child is no longer Home, and the drawer (the
     complete-registry render) must always show Home. The block's
     original purpose is subsumed by the phase-2 band re-base. */
}

@media (max-width: 1180px) and (min-width: 981px) {
  /* The decorative "FREE" plan badge is 51px of fixed chrome in the
     header. Below 1180px the nav row needs the space more than the
     badge needs to be always-visible - the plan is shown inside the
     user dropdown and on /pricing/. */
  .nav-auth .premium-badge {
    display: none !important;
  }
}

@media (max-width: 1120px) and (min-width: 981px) {
  /* Dashboard flat nav: icon-only. Public nav-item links have bare
     text nodes (no.nav-label span) so they are NOT affected. */
  .main-nav>a {
    padding: 8px 10px;
    gap: 0;
  }
  .main-nav>a>.nav-label {
    display: none;
  }
  .main-nav>a>.nav-icon {
    width: 17px;
    height: 17px;
    opacity: .8;
  }
}

@media (max-width: 1200px) and (min-width: 981px) {
  .nav-item>a {
    padding-left: 7px;
    padding-right: 7px;
    font-size: 13px;
    gap: 4px;
  }
  /* Reclaim fixed-chrome width (the same levers the pre-existing
     ≤1100px tier uses): tighter container padding/gap + a slightly
     smaller brand mark free ~30px for the nav row. */
  .site-header .container {
    gap: 8px;
    padding-left: 14px;
    padding-right: 14px;
  }
  .site-header .brand {
    font-size: 17px;
  }
  .site-header .brand-mark {
    width: 30px;
    height: 30px;
  }
  .nav-item>a>.nav-icon {
    width: 13px;
    height: 13px;
  }
  .nav-item>a>.nav-chevron {
    width: 10px;
    height: 10px;
  }
  .nav-item>a {
    gap: 3px;
  }
}

/* ============================================================
 * ( audit UI-1, part 2) Tablet header tier: 981-1080px.
 * ============================================================
 * Measured worst case at 991px: brand 119 + premium badge 51 +
 * user chip 116 + bell/theme/search 118 + container gaps 36 =
 * ~440px of fixed chrome, leaving ~550px for nav links that need
 * ~630px. No amount of font/padding tightening recovers 80px, so
 * the desktop nav row CANNOT fit below ~1081px - it was silently
 * clipping (nav items hidden behind the auth chip) at every width
 * from 981 to ~1200 before this tier existed.
 *
 * Solution: the hamburger menu normally activates only ≤980px
 * (rules in critical-fixes.css / card-depth.css / refined-polish.css
 * / ui-gradients.css). This self-contained block activates the SAME
 * pattern one breakpoint earlier (981-1150px) without touching the
 * scattered ≤980 rules: show the hamburger, collapse.main-nav into
 * the dropdown panel (the toggle JS in dashboard/includes/header.php
 * and app.js already toggles the.open class), and drop the mega
 * menus to stacked static sub-lists - exactly what the ≤980 rules
 * do, scoped to this tablet band. Above 1080px nothing changes.
 * ============================================================ */
/* (S133-W1) the band follows the measured nav-fit boundary.
   (S133-W1 phase-2) re-based 1479 → 1279: the six-row designed
   composition with the §4 ladder applied owns ≥1280; the served fit
   gate re-measures CTX-1280/1366/1440 in both auth states (the
   fail-loud rule reopens the contract if the measured point exceeds
   1279). The v2 sheet (macrition-ui.css .pub block) is the live owner
   on the public layout; this legacy mirror keeps the same boundary so
   pages that still resolve legacy rules agree with the drawer band. */
@media (max-width: 1279px) and (min-width: 981px) {
  .site-header .menu-toggle {
    display: flex;
  }
  .site-header .main-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: auto;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    z-index: 1000;
    background: var(--surface, #FFFFFF);
    border-bottom: 1px solid var(--border, rgba(15,23,42,0.08));
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.12);
    padding: 12px 0;
  }
  .site-header .main-nav.open {
    display: flex;
    flex-direction: column;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
  .site-header .main-nav>a,
  .site-header .nav-item {
    display: block;
    width: 100%;
  }
  .site-header .main-nav>a,
  .site-header .nav-item>a {
    width: 100%;
    padding: 13px 24px;
    font-size: 15px;
    border-radius: 0;
    justify-content: flex-start;
  }
  .site-header .main-nav>a>.nav-label {
    display: inline;
  }
  .site-header .main-nav>a>.nav-icon {
    width: 17px;
    height: 17px;
  }
  /* Mega/dropdown menus become stacked static lists inside the panel
     if a trigger is toggled (.expanded = app.js's class,.open kept
     for parity with the ≤980 rules). Today's triggers carry real
     hrefs, so they navigate - sub-items stay reachable from the
     destination hub pages, mirroring the ≤980 behavior exactly. */
  .site-header .nav-dropdown,
  .site-header .nav-mega {
    position: static;
    display: none;
    grid-template-columns: 1fr;
    box-shadow: none;
    border: 0;
    padding-left: 24px;
    min-width: 0;
    width: 100%;
  }
  .site-header .nav-item.open .nav-dropdown,
  .site-header .nav-item.open .nav-mega,
  .site-header .nav-item.expanded .nav-dropdown,
  .site-header .nav-item.expanded .nav-mega {
    display: block;
  }
  /* Free vertical space: the user name collapses into the chip
     (name still visible in the dropdown user menu). */
  .nav-auth .nav-user-name,
  .nav-auth .nav-admin-link {
    display: none !important;
  }
}

/* (250-D fleet floating-control law — the Director's finding 2: fixed-edge
   controls must not collide with content/actions "at ALL scrolled positions")
   The back-to-top control is INVISIBLE and POINTER-TRANSPARENT at rest
   (opacity:0 + pointer-events:none — taps pass through to the content it
   used to cover) and reveals only on scroll-up intent or keyboard focus
   (app.js toggles .btt-show). The dock: classic corner on wide screens,
   above the mobile bottom nav (.mn-has-nav, 64px band) + safe-area on
   phones, stacked above the Ask-AI FAB when present (.btt-stack-fab, the
   W12 contract — app.js and modules/ai-assistant.js both apply it on
   either load order). The hit target stays 44px in every state; reduced
   motion slides nothing. */
.back-to-top {
  position: fixed;
  right: 16px;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  /* (S258-D1) the sticky floating-dock tier, not a raw 90: the BTT is a
     sticky scroll affordance — above content and dropdowns, below the
     FAB/overlay plane (900) and the AI popover (950) it stacks with. */
  z-index: var(--mc-z-sticky, 500);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity .24s ease, transform .24s ease;
}
.back-to-top.btt-show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.back-to-top:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.back-to-top.btt-stack-fab {
  right: 20px;
  bottom: calc(136px + env(safe-area-inset-bottom, 0px));
}
@media (max-width: 768px) {
  .back-to-top {
    right: 12px;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }
  body.mn-has-nav .back-to-top {
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }
  .back-to-top.btt-stack-fab {
    bottom: calc(136px + env(safe-area-inset-bottom, 0px));
  }
  /* (S257-D1c, the 257-D lock claim 6124869161) the stack lift must survive
     the nav dock: with the FAB docked at 76px + safe-area (the S257-D1a nav
     reconciliation in ai-assistant.css), the FAB band is [76,124]px above
     the bottom — the bare nav dock (80px) now lands INSIDE the FAB band.
     The compound selector outranks body.mn-has-nav .back-to-top so the W12
     geometry (FAB top 124px + the 12px gap) holds on every nav surface;
     safe-area propagates through both docks. Pinned by s257-floating-dock
     V3 (revealed-btt-zero-fab-intersection at 320/390). */
  body.mn-has-nav .back-to-top.btt-stack-fab {
    bottom: calc(136px + env(safe-area-inset-bottom, 0px));
  }
}
@media (prefers-reduced-motion: reduce) {
  .back-to-top {
    transition: none;
    transform: none;
  }
}
