/* ===========================================================================
   Base — reset + design tokens (dual light/dark theme)

   Rules:
   - Never hardcode palette colors in component CSS; use these tokens.
   - --sage-dark inverts to a light tint in dark mode (like the rest of the
     "strong accent text" tokens) so accent text stays legible everywhere.
   - Chrome tokens (--chrome-*) are theme-invariant: the top bars and drawer
     always render as deep-sage glass with cream text in both themes.
   ========================================================================= */

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

:root {
  --ink: #1a2523;
  --muted: #687875;
  --paper: #f7f5ef;
  --surface: #fffefa;
  --card: linear-gradient(180deg, rgba(255, 254, 250, 0.95), rgba(255, 254, 250, 0.88));
  --card-solid: #fffefa;
  --card-soft: rgba(240, 237, 228, 0.55);
  --field: #fffefa;
  --row: rgba(240, 237, 228, 0.48);
  --line: #d8e1dd;
  --sage: #52796f;
  --sage-dark: #2f514d;
  --sage-soft: rgba(82, 121, 111, 0.10);
  --sage-line: rgba(82, 121, 111, 0.22);
  --terracotta: #c86f4a;
  --terracotta-soft: rgba(200, 111, 74, 0.12);
  --mustard: #d2a039;
  --mustard-ink: #6e5212;
  --mustard-soft: rgba(210, 160, 57, 0.14);
  --terracotta-ink: #8d4329;
  --red: #b3402e;
  /* Primary filled controls (buttons, active chips, user chat bubble) */
  --btn-bg: #2f514d;
  --btn-ink: #ffffff;
  --blue: #527da3;
  --blue-ink: #385f7e;

  /* RGB triplets for alpha composition: rgba(var(--sage-rgb), 0.08) keeps
     per-use alphas while the hue flips with the theme. */
  /* Metric health palette — macros and energy share one visual language
     across the donut, diary totals, nutrition cards and dashboard. */
  --m-protein: var(--sage);
  --m-carbs: var(--mustard);
  --m-fat: var(--terracotta);
  --m-kcal: var(--blue);

  --sage-rgb: 82, 121, 111;
  --sage-dark-rgb: 47, 81, 77;
  --terracotta-rgb: 200, 111, 74;
  --mustard-rgb: 210, 160, 57;
  --blue-rgb: 82, 125, 163;
  --ink-rgb: 26, 37, 35;
  --shadow-rgb: 47, 81, 77;
  --white-accent: #fffefa;
  --glass: rgba(255, 254, 250, 0.82);
  --glass-border: rgba(47, 81, 77, 0.16);
  --shadow-soft: 0 12px 30px rgba(26, 37, 35, 0.14);
  --shadow-card: 0 24px 60px rgba(26, 37, 35, 0.20);
  --shadow-field: 0 2px 10px rgba(26, 37, 35, 0.05);

  /* Theme-invariant chrome (top bars + drawer) */
  --chrome-bg-utility: rgba(24, 40, 36, 0.86);
  --chrome-bg-navbar: rgba(24, 40, 36, 0.55);
  --chrome-bg-drawer: rgba(20, 34, 30, 0.92);
  --chrome-bg-panel-top: rgba(28, 46, 41, 0.96);
  --chrome-bg-panel-bottom: rgba(20, 34, 30, 0.96);
  --chrome-ink: rgba(255, 254, 250, 0.82);
  --chrome-ink-strong: #fffefa;
  --chrome-border: rgba(255, 254, 250, 0.16);
  --chrome-active: linear-gradient(180deg, rgba(82, 121, 111, 0.95), rgba(47, 81, 77, 0.95));

  /* Sticky chrome height contract: pages offset sticky/viewport-locked
     elements against this. AppShell adds --trial-h when the banner shows. */
  --trial-h: 0px;
  --topbar-h: calc(98px + var(--trial-h));

  --font-display: 'Fraunces', 'Inter', ui-serif, Georgia, serif;

  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
}

:root[data-theme="dark"] {
  --ink: #ece9df;
  --muted: #9fafa8;
  --paper: #161b17;
  --surface: #1e2620;
  --card: linear-gradient(180deg, rgba(38, 46, 40, 0.96), rgba(24, 31, 27, 0.92));
  --card-solid: #222a24;
  --card-soft: rgba(44, 53, 46, 0.64);
  --field: #141a16;
  --row: rgba(44, 53, 46, 0.58);
  --line: rgba(214, 223, 217, 0.16);
  --sage: #6fa092;
  --sage-dark: #cde4db;
  --sage-soft: rgba(111, 160, 146, 0.14);
  --sage-line: rgba(111, 160, 146, 0.30);
  --terracotta: #df8e66;
  --terracotta-soft: rgba(223, 142, 102, 0.16);
  --mustard: #e3bb5d;
  --mustard-ink: #eed9a0;
  --mustard-soft: rgba(227, 187, 93, 0.16);
  --terracotta-ink: #f0b695;
  --red: #e57b69;
  --btn-bg: #6fa092;
  --btn-ink: #14201c;
  --blue: #82aacb;
  --blue-ink: #a8c6dd;

  --sage-rgb: 111, 160, 146;
  --sage-dark-rgb: 205, 228, 219;
  --terracotta-rgb: 223, 142, 102;
  --mustard-rgb: 227, 187, 93;
  --blue-rgb: 130, 170, 203;
  --ink-rgb: 236, 233, 223;
  --shadow-rgb: 0, 0, 0;
  --glass: rgba(20, 27, 22, 0.78);
  --glass-border: rgba(228, 236, 230, 0.16);
  --shadow-soft: 0 14px 36px rgba(0, 0, 0, 0.32);
  --shadow-card: 0 24px 64px rgba(0, 0, 0, 0.42);
  --shadow-field: 0 2px 12px rgba(0, 0, 0, 0.22);

  --chrome-bg-utility: rgba(14, 24, 21, 0.88);
  --chrome-bg-navbar: rgba(14, 24, 21, 0.60);
  --chrome-bg-drawer: rgba(12, 20, 18, 0.94);
  --chrome-bg-panel-top: rgba(18, 30, 26, 0.97);
  --chrome-bg-panel-bottom: rgba(12, 20, 18, 0.97);
}

html {
  min-width: 320px;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  text-rendering: optimizeLegibility;
}

#app {
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  font-family: inherit;
}

input {
  font: inherit;
}

::selection {
  background: rgba(200, 111, 74, 0.22);
}

/* ===========================================================================
   Chrome — sticky two-tier top bar, drawer, language/theme controls.
   The chrome is theme-invariant deep-sage glass (tokens --chrome-* in
   base.css); only page content flips with data-theme.

   Height contract: --topbar-h (base.css) = utility 38px + navbar 60px
   (+ trial banner via --trial-h). ≤700px the utility strip hides and the
   navbar shrinks, so --topbar-h is overridden below.
   ========================================================================= */

.app-layout {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  display: block;
}

.app-layout.has-trial {
  --trial-h: 41px;
}

.app-backdrop {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(900px at 12% -10%, rgba(82, 121, 111, 0.22), transparent 60%),
    radial-gradient(800px at 95% 15%, rgba(200, 111, 74, 0.13), transparent 55%),
    radial-gradient(700px at 70% 100%, rgba(210, 160, 57, 0.12), transparent 60%),
    var(--paper);
}

:root[data-theme="dark"] .app-backdrop {
  background:
    radial-gradient(900px at 12% -10%, rgba(82, 121, 111, 0.20), transparent 60%),
    radial-gradient(800px at 95% 15%, rgba(200, 111, 74, 0.10), transparent 55%),
    radial-gradient(700px at 70% 100%, rgba(210, 160, 57, 0.08), transparent 60%),
    #10140f;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
}

/* --- Utility strip ------------------------------------------------------ */

.app-utility {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  padding: 0 clamp(14px, 4vw, 40px);
  color: var(--chrome-ink);
  background: var(--chrome-bg-utility);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--chrome-border);
}

.utility-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mustard);
  white-space: nowrap;
}

.utility-kicker img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  display: block;
}

.utility-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.utility-profile,
.utility-logout {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  padding: 4px 10px;
  border-radius: 8px;
  background: transparent;
  color: var(--chrome-ink);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.utility-profile:hover {
  color: var(--chrome-ink-strong);
  background: rgba(255, 254, 250, 0.08);
}

.utility-profile.active {
  color: var(--chrome-ink-strong);
  background: var(--chrome-active);
}

.utility-logout:hover {
  color: #f2a48d;
  background: rgba(255, 254, 250, 0.06);
}

/* Flagship Assistant shortcut — the gold icon is the prominence; no
   border/background so it never reads as "selected" when it isn't. */

.utility-flagship svg {
  color: var(--mustard);
}

/* --- Theme toggle ------------------------------------------------------- */

.theme-toggle {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 254, 250, 0.16);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.06);
  color: var(--chrome-ink);
}

.theme-toggle:hover {
  color: var(--chrome-ink-strong);
  background: rgba(255, 254, 250, 0.12);
}

/* --- Language controls -------------------------------------------------- */

.lang-badge {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  padding: 1px 4px;
  border-radius: 5px;
  background: rgba(255, 254, 250, 0.12);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.4;
}

.language-switcher {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.lang-pill {
  display: grid;
  place-items: center;
  height: 30px;
  padding: 0 5px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--chrome-ink);
}

.lang-pill:hover,
.lang-pill.active {
  border-color: rgba(255, 254, 250, 0.36);
  background: rgba(255, 254, 250, 0.14);
  color: var(--chrome-ink-strong);
}

.lang-dropdown {
  position: relative;
  flex: 0 0 auto;
}

.lang-dropdown-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--chrome-ink);
  cursor: pointer;
}

.lang-dropdown-btn:hover {
  background: rgba(255, 254, 250, 0.08);
}

.lang-dropdown-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  min-width: 168px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--chrome-border);
  background: linear-gradient(180deg, var(--chrome-bg-panel-top), var(--chrome-bg-panel-bottom));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 24px 48px rgba(10, 18, 16, 0.45);
}

.lang-option {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 9px 12px;
  background: transparent;
  color: var(--chrome-ink);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.lang-option:hover {
  color: var(--chrome-ink-strong);
  background: rgba(255, 254, 250, 0.08);
}

.lang-option.active {
  color: var(--chrome-ink-strong);
  background: var(--chrome-active);
}

/* --- Main navbar -------------------------------------------------------- */

.app-navbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 60px;
  padding: 0 clamp(14px, 4vw, 40px);
  color: var(--chrome-ink-strong);
  background: var(--chrome-bg-navbar);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--chrome-border);
  box-shadow: 0 8px 28px rgba(10, 18, 16, 0.25);
}

.app-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  flex-wrap: nowrap;
}

.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  white-space: nowrap;
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  background: transparent;
  color: rgba(255, 254, 250, 0.78);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
}

.nav-item:hover {
  color: var(--chrome-ink-strong);
  background: rgba(255, 254, 250, 0.08);
}

.nav-item.active {
  color: var(--chrome-ink-strong);
  background: var(--chrome-active);
  box-shadow: 0 6px 18px rgba(10, 18, 16, 0.35);
}

.nav-lock {
  opacity: 0.65;
  margin-left: -2px;
}

.nav-more {
  position: relative;
  flex: 0 0 auto;
}

.nav-more-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  min-width: 188px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--chrome-border);
  background: linear-gradient(180deg, var(--chrome-bg-panel-top), var(--chrome-bg-panel-bottom));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 24px 48px rgba(10, 18, 16, 0.45);
}

.nav-more-panel .nav-item {
  width: 100%;
  justify-content: flex-start;
}

.nav-hamburger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--chrome-ink-strong);
  cursor: pointer;
}

.nav-hamburger:hover {
  color: rgba(255, 254, 250, 0.7);
}

.navbar-quick {
  display: none;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.navbar-quick .utility-profile,
.navbar-quick .utility-logout {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
  gap: 0;
  flex: 0 0 auto;
}

.navbar-quick .utility-profile span,
.navbar-quick .utility-logout span {
  display: none;
}

.app-nav-measure {
  position: absolute;
  left: -9999px;
  top: 0;
  display: flex;
  gap: 6px;
  visibility: hidden;
  pointer-events: none;
}

/* --- Trial banner (inside the sticky topbar) ---------------------------- */

.trial-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 41px;
  padding: 6px 20px;
  background: rgba(82, 125, 163, 0.22);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(82, 125, 163, 0.30);
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--chrome-ink-strong);
}

.trial-banner--urgent {
  background: rgba(200, 111, 74, 0.28);
  border-bottom-color: rgba(200, 111, 74, 0.38);
}

.trial-banner-cta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 12px;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 800;
}

.trial-banner--urgent .trial-banner-cta {
  background: var(--terracotta);
}

/* --- Mobile drawer ------------------------------------------------------ */

.app-drawer-root {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}

.app-drawer-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 18, 16, 0.55);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.app-drawer {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(82vw, 320px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 16px;
  border-right: 1px solid var(--chrome-border);
  background: var(--chrome-bg-drawer);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 24px 60px rgba(10, 18, 16, 0.55);
  transform: translateX(-100%);
  transition: transform 0.24s ease;
  color: var(--chrome-ink);
}

.app-drawer-root.open {
  pointer-events: auto;
}

.app-drawer-root.open .app-drawer-overlay {
  opacity: 1;
}

.app-drawer-root.open .app-drawer {
  transform: translateX(0);
}

.app-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--chrome-border);
}

.drawer-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--chrome-ink);
  cursor: pointer;
}

.drawer-close:hover {
  background: rgba(255, 254, 250, 0.08);
  color: var(--chrome-ink-strong);
}

.app-drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.app-drawer-nav .nav-item {
  width: 100%;
  justify-content: flex-start;
  padding: 12px 14px;
}

.app-drawer-foot {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--chrome-border);
}

.app-drawer-foot .nav-item {
  width: 100%;
  justify-content: flex-start;
}

.app-drawer-foot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* --- Main content area --------------------------------------------------- */

:root {
  --main-pad-y: 34px;
  --main-pad-x: clamp(20px, 5vw, 58px);
}

.app-main {
  min-width: 0;
  padding: var(--main-pad-y) var(--main-pad-x);
}

/* The assistant renders as a height-capped window card inside the normal
   page flow (see styles/assistant.css .asst-page-v2) — no viewport lock. */

/* --- Responsive chrome --------------------------------------------------- */

@media (max-width: 700px) {
  :root {
    --topbar-h: calc(54px + var(--trial-h));
    --main-pad-y: 22px;
    --main-pad-x: 14px;
  }

  .app-utility {
    display: none;
  }

  .app-nav,
  .app-nav-measure {
    display: none;
  }

  .app-navbar {
    min-height: 54px;
    gap: 12px;
  }

  .navbar-quick {
    display: inline-flex;
  }

  .navbar-quick .theme-toggle {
    margin-left: 4px;
  }

  .navbar-quick .utility-logout {
    margin-left: 6px;
  }
}

/* Disabled chrome controls (e.g. registration off) */

.utility-profile:disabled,
.nav-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.utility-profile:disabled:hover,
.nav-item:disabled:hover {
  background: transparent;
  color: var(--chrome-ink);
}

/* ===========================================================================
   Public pages — landing hero, auth panels, glass cards over the backdrop.
   ========================================================================= */

.public-shell {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.public-backdrop {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(1000px at 10% -12%, rgba(82, 121, 111, 0.30), transparent 60%),
    radial-gradient(820px at 96% 12%, rgba(200, 111, 74, 0.18), transparent 56%),
    radial-gradient(760px at 68% 104%, rgba(210, 160, 57, 0.18), transparent 60%),
    var(--paper);
}

:root[data-theme="dark"] .public-backdrop {
  background:
    radial-gradient(1000px at 10% -12%, rgba(82, 121, 111, 0.26), transparent 60%),
    radial-gradient(820px at 96% 12%, rgba(200, 111, 74, 0.13), transparent 56%),
    radial-gradient(760px at 68% 104%, rgba(210, 160, 57, 0.10), transparent 60%),
    #10140f;
}

.public-shell::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 72%, rgba(26, 37, 35, 0.10));
}

/* Public chrome: single utility strip on wide; hamburger bar only ≤700px */

.public-shell .app-utility {
  min-height: 52px;
}

.public-shell .app-navbar {
  display: none;
}

@media (max-width: 700px) {
  .public-shell .app-navbar {
    display: flex;
  }

  .public-shell .navbar-quick {
    display: inline-flex;
  }
}

/* --- Layouts -------------------------------------------------------------- */

.home-layout,
.auth-layout {
  width: min(1120px, calc(100% - 28px));
  flex: 1;
  margin: 0 auto;
  display: grid;
  align-items: center;
  gap: clamp(24px, 5vw, 68px);
  padding: clamp(26px, 5vh, 48px) 0 62px;
}

.home-layout {
  grid-template-columns: minmax(0, 1fr);
  justify-content: center;
}

.auth-layout {
  grid-template-columns: minmax(320px, 430px) minmax(300px, 1fr);
}

/* --- Glass cards ----------------------------------------------------------- */

.card-halo {
  padding: 16px;
  border-radius: 22px;
  background: rgba(255, 254, 250, 0.10);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 4px 32px rgba(26, 37, 35, 0.14);
}

:root[data-theme="dark"] .card-halo {
  background: rgba(20, 27, 22, 0.30);
}

.home-card,
.auth-panel {
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.home-card {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.75fr);
  align-items: center;
  gap: clamp(24px, 4vw, 52px);
  padding: clamp(24px, 5vw, 48px);
}

.home-copy {
  display: grid;
  gap: 18px;
  justify-items: start;
}

.mini-kicker,
.eyebrow {
  width: max-content;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--sage-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.home-title {
  max-width: 12ch;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  line-height: 1.0;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* Sage / mustard / terracotta accent stripe — the ThermoPlanner ribbon */

.tp-stripe {
  width: min(100%, 300px);
  height: 6px;
  display: block;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sage) 0 33%, var(--mustard) 33% 66%, var(--terracotta) 66% 100%);
  box-shadow: 0 8px 18px rgba(47, 81, 77, 0.20);
}

.home-subtitle {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 2.6vw, 1.9rem);
  font-weight: 600;
  line-height: 1.1;
  color: var(--sage-dark);
}

.home-copy-text {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  font-size: 1.06rem;
}

.home-cta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.solid-button,
.ghost-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 9px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-size: 0.95rem;
  font-weight: 800;
  white-space: nowrap;
}

.solid-button {
  color: #fff;
  background: var(--sage-dark);
  box-shadow: 0 14px 28px rgba(47, 81, 77, 0.22);
}

.solid-button:hover {
  background: #24423f;
}

:root[data-theme="dark"] .solid-button {
  color: #14201c;
  background: var(--sage);
}

:root[data-theme="dark"] .solid-button:hover {
  background: #82b2a4;
}

.solid-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.ghost-button {
  color: var(--sage-dark);
  background: var(--card-soft);
  border-color: var(--sage-line);
  backdrop-filter: blur(14px);
}

.ghost-button:hover {
  background: var(--sage-soft);
}

.large {
  min-height: 48px;
  padding: 0 18px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(82, 125, 163, 0.32);
  border-radius: 999px;
  background: var(--card-soft);
  color: var(--blue-ink);
  font-size: 0.85rem;
  font-weight: 750;
}

/* --- Hero visual (planner board mock) -------------------------------------- */

.visual {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
}

.planner-board {
  width: 100%;
  max-width: 400px;
  padding: 22px;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.10), transparent 60%),
    var(--card);
  box-shadow: var(--shadow-soft);
  transform: rotate(1.6deg);
}

.board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

.board-title {
  display: grid;
  gap: 5px;
}

.board-title strong {
  font-size: 1rem;
}

.board-title span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.dial {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 9px solid var(--sage-line);
  border-top-color: var(--terracotta);
  border-right-color: var(--mustard);
}

.meal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.meal-tile {
  min-height: 96px;
  padding: 14px;
  display: grid;
  align-content: space-between;
  border: 1px solid var(--glass-border);
  border-radius: 9px;
  background: var(--card-soft);
}

.meal-tile span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.meal-line {
  height: 9px;
  border-radius: 999px;
  background: var(--sage);
}

.meal-line.short {
  width: 62%;
  background: var(--terracotta);
}

.meal-line.medium {
  width: 78%;
  background: var(--blue);
}

.meal-line.gold {
  width: 54%;
  background: var(--mustard);
}

.visual-caption {
  position: absolute;
  right: 0;
  bottom: -10px;
  width: 62%;
  max-width: 240px;
  padding: 14px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: var(--card);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
  color: var(--sage-dark);
  font-size: 0.9rem;
  font-weight: 800;
}

/* --- Auth panels ------------------------------------------------------------ */

.auth-panel {
  width: 100%;
  padding: 26px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 22px;
}

.panel-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--sage-line);
  border-radius: 9px;
  background: linear-gradient(160deg, var(--sage-soft), var(--mustard-soft));
  color: var(--sage-dark);
}

.auth-title {
  max-width: none;
  margin: 0;
  font-family: var(--font-display);
  color: var(--ink);
  font-size: 1.7rem;
  line-height: 1.08;
  font-weight: 700;
}

.panel-heading p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.92rem;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.form-submit {
  width: 100%;
  margin-top: 4px;
}

.auth-copy-text {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 1rem;
}

.auth-copy-hint {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.88rem;
}

.auth-alt {
  text-align: center;
  margin-top: 16px;
  font-size: 0.9em;
  color: var(--muted);
}

.auth-alt a {
  color: var(--sage-dark);
  font-weight: 700;
}

.auth-visual {
  min-height: 320px;
}

/* --- Responsive -------------------------------------------------------------- */

@media (max-width: 880px) {
  .home-card {
    grid-template-columns: 1fr;
    text-align: left;
  }

  .visual {
    padding-bottom: 16px;
  }
}

@media (max-width: 820px) {
  .auth-layout {
    grid-template-columns: 1fr;
  }

  .auth-visual {
    display: none;
  }
}

@media (max-width: 700px) {
  .card-halo {
    padding: 10px;
  }

  .home-card,
  .auth-panel {
    padding: 22px;
  }

  .home-cta {
    width: 100%;
  }

  .home-cta .solid-button,
  .home-cta .ghost-button {
    flex: 1;
  }
}

.ghost-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ghost-button:disabled:hover {
  background: var(--card-soft);
}

/* ===========================================================================
   Content — workspace pages (profile, connections, diary, search, locked)
   ========================================================================= */

/* Reset + design tokens live in styles/base.css (imported before this file). */

/* Public chrome + hero + auth panels live in styles/public.css. */

h2 {
  max-width: none;
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1.12;
  font-weight: 800;
}

label {
  display: grid;
  gap: 7px;
  color: var(--sage-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid rgba(var(--sage-dark-rgb), 0.2);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

input:focus {
  border-color: rgba(var(--blue-rgb), 0.7);
  box-shadow: 0 0 0 3px rgba(var(--blue-rgb), 0.16);
}

.form-button,
.google-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
}

.form-button {
  margin-top: 4px;
  color: var(--btn-ink);
  background: var(--btn-bg);
  box-shadow: 0 14px 26px rgba(var(--shadow-rgb), 0.18);
}

.form-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.google-button {
  width: 100%;
  color: var(--ink);
  background: var(--surface);
  border-color: rgba(var(--sage-dark-rgb), 0.2);
}

.google-button:hover {
  border-color: rgba(var(--sage-rgb), 0.42);
  background: rgba(var(--sage-rgb), 0.06);
}

.google-mark {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #4285f4;
  font-size: 0.8rem;
  font-weight: 900;
}

.form-status {
  margin-top: 14px;
  color: var(--sage-dark);
  font-size: 0.9rem;
  font-weight: 750;
}

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.divider::before,
.divider::after {
  content: "";
  height: 1px;
  background: rgba(var(--sage-dark-rgb), 0.16);
}

/* Trial banner + workspace chrome (top bars, drawer) live in styles/chrome.css. */

/* ---------------------------------------------------------------------------
   Workspace: Profile section
--------------------------------------------------------------------------- */

.ws-profile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  max-width: 480px;
}

.ws-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--sage), var(--blue));
  color: var(--btn-ink);
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.ws-profile-name {
  max-width: none;
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.2;
}

.ws-profile-email {
  color: var(--muted);
  font-size: 0.95rem;
}

.ws-tier-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ws-tier-badge--trial {
  background: rgba(var(--blue-rgb), 0.12);
  color: var(--blue-ink);
}

.ws-tier-badge--paid {
  background: rgba(var(--sage-rgb), 0.14);
  color: var(--sage-dark);
}

.ws-tier-badge--admin {
  background: rgba(var(--mustard-rgb), 0.16);
  color: var(--mustard-ink);
}

.ws-tier-badge--none {
  background: rgba(100, 100, 100, 0.1);
  color: var(--muted);
}

/* ---------------------------------------------------------------------------
   Workspace: content areas
--------------------------------------------------------------------------- */

.ws-content-area {
  max-width: 720px;
}

.ws-content-area h2 {
  max-width: none;
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 12px;
}

/* ---------------------------------------------------------------------------
   Connections section
--------------------------------------------------------------------------- */

.conn-page {
  max-width: 580px;
}

.conn-intro {
  color: var(--muted);
  font-size: 0.92rem;
  margin-top: 6px;
  margin-bottom: 28px;
}

.conn-service-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 24px;
  box-shadow: 0 1px 4px rgba(var(--shadow-rgb), 0.06);
}

.conn-service-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.conn-service-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.conn-service-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(var(--sage-rgb), 0.1);
  color: var(--sage-dark);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.conn-service-name {
  display: block;
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.2;
}

.conn-service-sub {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

.conn-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  flex-shrink: 0;
}

.conn-badge--on {
  background: rgba(var(--sage-rgb), 0.12);
  color: var(--sage-dark);
}

.conn-badge--off {
  background: rgba(100, 100, 100, 0.08);
  color: var(--muted);
}

.conn-badge--expired {
  background: rgba(var(--mustard-rgb), 0.14);
  color: var(--mustard-ink);
}

.conn-expired-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 20px;
  padding: 11px 14px;
  border-radius: 8px;
  background: rgba(var(--mustard-rgb), 0.08);
  border: 1px solid rgba(var(--mustard-rgb), 0.25);
  color: var(--mustard-ink);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.4;
}

.conn-expired-notice svg {
  flex-shrink: 0;
  margin-top: 1px;
}

.conn-body-text {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 18px;
}

.conn-body-text strong {
  color: var(--ink);
  font-weight: 700;
}

.conn-form {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.conn-connected-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.conn-verify-result {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 10px 13px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.4;
}

.conn-verify-result svg {
  flex-shrink: 0;
  margin-top: 1px;
}

.conn-verify-result--ok {
  background: rgba(var(--sage-rgb), 0.08);
  border: 1px solid rgba(var(--sage-rgb), 0.2);
  color: var(--sage-dark);
}

.conn-verify-result--fail {
  background: rgba(var(--terracotta-rgb), 0.08);
  border: 1px solid rgba(var(--terracotta-rgb), 0.2);
  color: var(--terracotta-ink);
}

.conn-mode-form {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.conn-security-note {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 9px 12px;
  border-radius: 7px;
  background: rgba(var(--sage-rgb), 0.07);
  border: 1px solid rgba(var(--sage-rgb), 0.15);
  color: var(--sage-dark);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.4;
}

.conn-security-note svg {
  flex-shrink: 0;
  margin-top: 1px;
}

.conn-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.conn-field span {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.01em;
}

.conn-field input,
.conn-field textarea {
  padding: 8px 11px;
  border: 1.5px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.88rem;
  font-family: inherit;
  transition: border-color 0.12s;
  width: 100%;
}

.conn-field input:focus,
.conn-field textarea:focus {
  outline: none;
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(var(--sage-rgb), 0.1);
}

.conn-token-area {
  resize: vertical;
  min-height: 90px;
  font-family: ui-monospace, 'SF Mono', monospace;
  font-size: 0.75rem !important;
  line-height: 1.6;
}

.conn-hint {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.55;
}

.conn-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.conn-save-btn {
  display: inline-flex;
  padding: 0 22px;
  min-width: 130px;
  justify-content: center;
}

.conn-verify-btn {
  display: inline-flex;
  padding: 0 20px;
  min-width: 130px;
  justify-content: center;
  height: 40px;
  border-radius: 8px;
  border: 1.5px solid var(--sage);
  background: transparent;
  color: var(--sage-dark);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s;
  align-items: center;
}

.conn-verify-btn:hover:not(:disabled) {
  background: rgba(var(--sage-rgb), 0.08);
}

.conn-verify-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.conn-disconnect-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0 4px;
  transition: color 0.12s;
}

.conn-disconnect-btn:hover:not(:disabled) {
  color: var(--terracotta);
}

.conn-disconnect-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.conn-save-ok {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--sage-dark);
}

.conn-save-err {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--terracotta);
}

/* ---------------------------------------------------------------------------
   Calendar section
--------------------------------------------------------------------------- */

.ws-locked {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 340px;
  text-align: center;
  color: var(--muted);
  max-width: 420px;
  margin: 8vh auto 0;
  padding: 38px 30px;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.ws-locked h2 {
  max-width: none;
  font-size: 1.2rem;
  color: var(--ink);
}

.ws-locked p {
  font-size: 0.95rem;
}

/* ===========================================================================
   Diary (meal plan) — week / month / list / history + side panel
   =========================================================================== */

.diary-shell {
  display: flex;
  gap: 0;
  align-items: flex-start;
  /* bleed into app-main padding */
  margin: calc(-1 * var(--main-pad-y)) calc(-1 * var(--main-pad-x));
}

.diary-main {
  flex: 1;
  min-width: 0;
  max-width: 1240px;
  margin-inline: auto;
  padding: var(--main-pad-y) var(--main-pad-x);
}

.diary-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.diary-head h2 { margin: 0; }

.diary-viewtabs {
  display: inline-flex;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}

.diary-viewtab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.12s, color 0.12s;
}

.diary-viewtab:hover { color: var(--ink); }

.diary-viewtab.active {
  background: var(--surface);
  color: var(--sage-dark);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.diary-notice {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 12px 16px;
  border-radius: 9px;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 14px;
}

.diary-notice svg { flex-shrink: 0; margin-top: 1px; }

.diary-notice--warn {
  background: rgba(var(--mustard-rgb), 0.1);
  border: 1px solid rgba(var(--mustard-rgb), 0.28);
  color: var(--mustard-ink);
}

/* --- Toolbar: navigation + period totals --- */

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

.diary-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.diary-nav-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  display: grid;
  place-items: center;
  transition: border-color 0.12s, color 0.12s;
}

.diary-nav-btn:hover { border-color: var(--sage); color: var(--sage-dark); }

.diary-nav-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
  min-width: 132px;
  text-align: center;
}

.diary-today-btn {
  margin-left: 4px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--sage-dark);
  transition: border-color 0.12s, background 0.12s;
}

.diary-today-btn:hover { border-color: var(--sage); background: var(--paper); }

.diary-totals {
  display: flex;
  align-items: center;
  gap: 10px;
}

.diary-totals-label {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.diary-totals-pills { display: flex; gap: 6px; flex-wrap: wrap; }

.diary-total {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--line);
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--ink);
}

.diary-total-kcal {
  background: rgba(var(--blue-rgb), 0.10);
  border-color: rgba(var(--blue-rgb), 0.28);
  color: var(--m-kcal);
}

.diary-total::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 3px;
  background: var(--muted);
}

.diary-total-kcal::before { background: var(--m-kcal); }

.diary-total--p::before { background: var(--m-protein); }

.diary-total--f::before { background: var(--m-fat); }

.diary-total--c::before { background: var(--m-carbs); }

.search-sentinel { height: 1px; }

.search-loading-more { justify-content: center; padding: 16px 0; }

.diary-totals-empty { color: var(--line); font-weight: 700; }

.diary-loading { display: grid; place-items: center; padding: 60px 0; color: var(--sage); }

/* --- Week grid --- */

.diary-week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.diary-day {
  min-height: 190px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.diary-day--today { border-color: var(--sage); box-shadow: 0 0 0 1px var(--sage); }

.diary-day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 8px 10px 7px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.diary-day--today .diary-day-head { background: var(--btn-bg); border-bottom-color: var(--sage-dark); }

.diary-day-name {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.diary-day--today .diary-day-name { color: var(--btn-ink); opacity: 0.82; }

.diary-day-num { font-size: 1rem; font-weight: 800; color: var(--ink); }

.diary-day--today .diary-day-num { color: var(--btn-ink); }

.diary-day-body {
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.diary-day-foot {
  padding: 6px 10px;
  border-top: 1px dashed var(--line);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--terracotta);
  text-align: right;
  min-height: 14px;
}

.diary-empty { color: var(--line); font-size: 0.95rem; margin: auto; }

/* --- Recipe chip --- */

.diary-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px;
  border: 1px solid rgba(var(--sage-rgb), 0.14);
  border-radius: 9px;
  background: rgba(var(--sage-rgb), 0.05);
  text-align: left;
  width: 100%;
  transition: border-color 0.12s, background 0.12s, transform 0.08s;
}

.diary-chip:hover {
  border-color: var(--sage);
  background: rgba(var(--sage-rgb), 0.1);
}

.diary-chip:active { transform: scale(0.99); }

.diary-chip-thumb {
  width: 40px;
  height: 40px;
  border-radius: 7px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--paper);
  display: grid;
  place-items: center;
}

.diary-chip-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.diary-chip-thumb--ph { color: var(--line); }

.diary-chip-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.diary-chip-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.diary-chip-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
}

.diary-chip-meta span { display: inline-flex; align-items: center; gap: 3px; }

.diary-chip--compact { padding: 0; border: none; background: none; width: auto; }

.diary-chip--compact:hover { background: none; }

.diary-chip--compact .diary-chip-thumb { width: 26px; height: 26px; border-radius: 6px; }

.diary-chip--compact .diary-chip-thumb { box-shadow: 0 0 0 1.5px var(--surface); }

/* --- Month grid --- */

.diary-month-dow {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 6px;
}

.diary-month-dow span {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-align: center;
}

.diary-month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.diary-mcell {
  min-height: 92px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 6px 7px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.diary-mcell--out { background: var(--paper); opacity: 0.55; }

.diary-mcell--today { border-color: var(--sage); box-shadow: 0 0 0 1px var(--sage); }

.diary-mcell-head { display: flex; align-items: center; justify-content: space-between; }

.diary-mcell-num { font-size: 0.82rem; font-weight: 800; color: var(--ink); }

.diary-mcell-kcal {
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--terracotta);
  background: var(--terracotta-soft);
  padding: 1px 6px;
  border-radius: 999px;
}

.diary-mcell-thumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }

.diary-mcell-more {
  font-size: 0.66rem;
  font-weight: 800;
  color: var(--muted);
  align-self: center;
}

/* --- List / agenda --- */

.diary-list { display: flex; flex-direction: column; gap: 18px; max-width: 720px; }

.diary-list-day { }

.diary-list-dayhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.diary-list-date { font-size: 0.92rem; font-weight: 800; color: var(--ink); }

.diary-list-date--today { color: var(--sage-dark); }

.diary-list-recipes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.diary-empty-block { color: var(--muted); font-size: 0.9rem; padding: 24px 0; }

/* --- History --- */

.diary-history { max-width: 640px; }

.diary-search-row { display: flex; gap: 10px; align-items: center; }

.diary-search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 14px;
  height: 44px;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--muted);
}

.diary-search:focus-within { border-color: var(--sage); }

.diary-search input { flex: 1; border: none; outline: none; background: none; font-size: 0.92rem; color: var(--ink); }

.diary-sync-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 44px;
  padding: 0 14px;
  border-radius: 11px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--sage-dark);
  flex-shrink: 0;
  transition: border-color 0.12s, background 0.12s;
}

.diary-sync-btn:hover:not(:disabled) { border-color: var(--sage); background: var(--paper); }

.diary-sync-btn:disabled { opacity: 0.6; }

.diary-search-hint { font-size: 0.8rem; color: var(--muted); margin: 10px 2px 16px; }

.diary-search-hint strong { color: var(--sage-dark); font-weight: 700; }

.diary-link-btn {
  border: none;
  background: none;
  color: var(--sage);
  font-weight: 700;
  font-size: 0.8rem;
  text-decoration: underline;
  padding: 0;
}

.diary-results { display: flex; flex-direction: column; gap: 8px; }

.diary-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  text-align: left;
  transition: border-color 0.12s, background 0.12s;
}

.diary-result:hover { border-color: var(--sage); background: var(--paper); }

.diary-result .diary-chip-thumb { width: 46px; height: 46px; }

.diary-result-body { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.diary-result-name { font-size: 0.9rem; font-weight: 700; color: var(--ink); }

.diary-result-when { font-size: 0.74rem; color: var(--muted); }

.diary-result-kcal {
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--terracotta);
  flex-shrink: 0;
}

/* --- Side panel placement inside the diary and search shells --- */

.diary-shell .recipe-panel,
.search-shell .recipe-panel {
  position: sticky;
  top: var(--topbar-h);
  align-self: stretch;
  max-height: calc(100vh - var(--topbar-h));
}

/* --- Panel additions (also used by the Assistant) --- */

.recipe-panel-banner {
  width: 100%;
  height: 168px;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 14px;
  background: var(--paper);
}

.recipe-panel-banner img { width: 100%; height: 100%; object-fit: cover; display: block; }

.recipe-ingredient.has-icon {
  display: flex;
  align-items: center;
  gap: 9px;
}

.recipe-ingredient.has-icon::before { display: none; }

.recipe-ingredient-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface);
}

.recipe-missing-note {
  padding: 12px 14px;
  border-radius: 9px;
  background: var(--paper);
  border: 1px solid var(--line);
  margin-bottom: 14px;
}

.recipe-missing-note p { font-size: 0.82rem; color: var(--muted); margin: 0 0 8px; line-height: 1.4; }

.recipe-loadfull-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-size: 0.82rem;
  font-weight: 700;
}

.recipe-loadfull-btn:disabled { opacity: 0.7; }

@media (max-width: 900px) {
  .diary-shell,
  .search-shell {
    flex-direction: column;
    /* WebKit sizes flex-start children to max-content — stretch instead */
    align-items: stretch;
    margin: calc(-1 * var(--main-pad-y)) calc(-1 * var(--main-pad-x));
  }
  .search-main,
  .diary-main { width: 100%; max-width: none; }
  .diary-shell .recipe-panel,
  .search-shell .recipe-panel {
    position: relative;
    top: 0;
    width: 100%;
    max-height: none;
    border-left: none;
    border-top: 1px solid var(--line);
  }
  .diary-week-grid { grid-template-columns: repeat(7, minmax(96px, 1fr)); overflow-x: auto; }
}

/* ---------------------------------------------------------------------------
   Profile page
--------------------------------------------------------------------------- */

.profile-page { width: 100%; max-width: 860px; margin-inline: auto; display: flex; flex-direction: column; gap: 18px; }

.profile-loading, .profile-error { color: var(--muted); display: flex; align-items: center; gap: 8px; }

.profile-error { color: var(--red); }

/* Header card */

.profile-header {
  display: flex; align-items: center; gap: 18px;
  background: linear-gradient(135deg, rgba(var(--sage-rgb),0.10), rgba(var(--blue-rgb),0.08));
  border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px;
}

.profile-avatar-wrap { position: relative; flex-shrink: 0; }

.profile-avatar {
  position: relative; width: 84px; height: 84px; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; background: linear-gradient(135deg, var(--sage), var(--blue));
  color: var(--btn-ink); box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}

.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }

.profile-avatar-initials { font-size: 1.7rem; font-weight: 800; }

.profile-avatar-busy { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,0.35); color: #fff; }

.profile-avatar-edit {
  position: absolute; right: -2px; bottom: -2px; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--btn-bg); color: var(--btn-ink); border: 2px solid var(--surface);
}

.profile-avatar-edit:hover { background: var(--sage); }

.profile-avatar-edit:disabled { opacity: 0.6; cursor: default; }

.profile-header-id { flex: 1; min-width: 0; }

.profile-header-name { font-size: 1.5rem; font-weight: 800; line-height: 1.2; }

.profile-header-email { color: var(--muted); font-size: 0.9rem; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }

.profile-header-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 10px; }

.profile-avatar-remove {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  background: none; border: none; color: var(--muted); font-size: 0.78rem; font-weight: 600;
}

.profile-avatar-remove:hover { color: var(--red); }

.profile-logout {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); font-size: 0.82rem; font-weight: 600; cursor: pointer;
}

.profile-logout:hover { border-color: var(--sage); color: var(--sage-dark); }

/* Tabs */

.profile-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }

.profile-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 16px; cursor: pointer; background: none; border: none;
  color: var(--muted); font-size: 0.9rem; font-weight: 700;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}

.profile-tab:hover { color: var(--sage-dark); }

.profile-tab.is-active { color: var(--sage-dark); border-bottom-color: var(--sage); }

.profile-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 20px;
}

.profile-body-layout {
  display: grid; grid-template-columns: 1fr 300px; gap: 24px; align-items: start;
}

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

.profile-field { display: flex; flex-direction: column; gap: 5px; }

.profile-field--wide { grid-column: 1 / -1; }

.profile-field > span { font-size: 0.78rem; font-weight: 700; color: var(--muted); }

.profile-field input, .profile-field select {
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--paper); color: var(--ink); font-size: 0.9rem;
}

.profile-field input:disabled { color: var(--muted); cursor: not-allowed; }

.profile-field input:focus, .profile-field select:focus { outline: none; border-color: var(--sage); }

/* Targets panel + macro donut */

.profile-targets-panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 16px;
}

.profile-targets-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.8rem; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 12px;
}

.macro-donut-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }

.macro-donut { width: 150px; height: 150px; }

.macro-donut-kcal { font-size: 1.45rem; font-weight: 800; fill: var(--ink); }

.macro-donut-unit { font-size: 0.62rem; font-weight: 700; fill: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.macro-legend { width: 100%; display: flex; flex-direction: column; gap: 8px; }

.macro-legend-row { display: flex; align-items: center; gap: 8px; font-size: 0.86rem; }

.macro-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

.macro-legend-label { flex: 1; font-weight: 600; color: var(--ink); }

.macro-legend-val { font-weight: 700; color: var(--ink); }

.macro-legend-pct { width: 38px; text-align: right; color: var(--muted); font-weight: 600; }

.profile-hint { color: var(--muted); font-size: 0.86rem; line-height: 1.5; }

.profile-prefgroup { margin-top: 18px; }

.profile-prefgroup:first-of-type { margin-top: 0; }

.profile-preflabel {
  display: block; font-size: 0.78rem; font-weight: 700; color: var(--muted); margin-bottom: 8px;
}

.profile-chips { display: flex; flex-wrap: wrap; gap: 7px; }

.profile-chip {
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper);
  color: var(--ink); font-size: 0.82rem; font-weight: 600; cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.profile-chip:hover { border-color: var(--sage); }

.profile-chip.is-on { background: var(--sage); border-color: var(--sage); color: var(--btn-ink); }

.profile-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 8px; }

.profile-tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 6px 5px 11px; border-radius: 999px;
  background: rgba(var(--sage-rgb), 0.12); color: var(--sage-dark);
  font-size: 0.82rem; font-weight: 600;
}

.profile-tag button {
  display: grid; place-items: center; cursor: pointer;
  border: none; background: none; color: var(--sage-dark); opacity: 0.7; padding: 0;
}

.profile-tag button:hover { opacity: 1; }

.profile-tag-add { display: flex; gap: 8px; }

.profile-tag-add input {
  flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--paper); font-size: 0.88rem;
}

.profile-tag-add input:focus { outline: none; border-color: var(--sage); }

.profile-tag-add button {
  padding: 8px 14px; border-radius: 8px; border: none;
  background: var(--btn-bg); color: var(--btn-ink); font-weight: 700; font-size: 0.84rem; cursor: pointer;
}

.profile-savebar {
  position: sticky; bottom: 0;
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  padding: 12px 0;
}

.profile-saved { display: inline-flex; align-items: center; gap: 5px; color: var(--sage-dark); font-weight: 700; font-size: 0.85rem; }

.profile-save-btn {
  padding: 10px 20px; border-radius: 9px; border: none;
  background: var(--btn-bg); color: var(--btn-ink); font-weight: 800; font-size: 0.88rem; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
}

.profile-save-btn:disabled { opacity: 0.7; cursor: default; }

@media (max-width: 760px) {
  .profile-body-layout { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .profile-grid { grid-template-columns: 1fr; }
  .profile-header { flex-wrap: wrap; }
}

/* ---------------------------------------------------------------------------
   Search page
--------------------------------------------------------------------------- */

.search-shell {
  display: flex; align-items: flex-start; gap: 0;
  /* bleed into app-main padding */
  margin: calc(-1 * var(--main-pad-y)) calc(-1 * var(--main-pad-x));
}

.search-main { flex: 1; min-width: 0; padding: var(--main-pad-y) var(--main-pad-x); }

.search-head { margin-bottom: 16px; }

.search-head h2 { font-size: 1.4rem; font-weight: 800; }

.search-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px; height: 46px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
}

.search-bar:focus-within { border-color: var(--sage); }

.search-bar-icon { color: var(--muted); flex-shrink: 0; }

.search-bar input { flex: 1; border: none; background: none; font-size: 0.98rem; color: var(--ink); }

.search-bar input:focus { outline: none; }

.search-bar-spin { color: var(--sage); }

.search-sticky {
  position: sticky;
  top: var(--topbar-h);
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 calc(-1 * var(--main-pad-x));
  padding: 10px var(--main-pad-x) 8px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

.search-sticky .search-toolbar,
.search-sticky .search-filters,
.search-sticky .search-meta { margin: 0; }

/* Filters panel (lives inside the sticky block) caps its height and
   scrolls internally so an open panel never swallows the viewport */

.search-sticky .search-filters {
  max-height: min(55vh, 430px);
  overflow-y: auto;
}

.filter-group--cats { width: 100%; }

.search-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.search-select {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); font-size: 0.86rem; font-weight: 600; cursor: pointer;
}

.search-select:focus { outline: none; border-color: var(--sage); }

.search-filter-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); font-size: 0.86rem; font-weight: 700;
}

.search-filter-toggle:hover { border-color: var(--sage); color: var(--sage-dark); }

.search-filter-toggle.is-on { background: var(--sage); border-color: var(--sage); color: var(--btn-ink); }

.search-filters {
  display: flex; flex-wrap: wrap; gap: 14px;
  margin-top: 12px; padding: 14px 16px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
}

.search-filters label { display: flex; flex-direction: column; gap: 5px; }

.search-filters label span { font-size: 0.76rem; font-weight: 700; color: var(--muted); }

.search-filters input {
  width: 130px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); font-size: 0.88rem;
}

.search-filters input:focus { outline: none; border-color: var(--sage); }

/* Category chip row — horizontally scrollable, sprite-icon chips */

/* Category chips wrap to the page width (no horizontal scroll) */

.cat-row {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px;
}

.cat-chip {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  padding: 6px 12px 6px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font-size: 0.82rem; font-weight: 600; white-space: nowrap;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.cat-chip:hover { border-color: var(--sage); }

.cat-chip.is-on { background: var(--sage); border-color: var(--sage); color: var(--btn-ink); }

/* Stroke-based line icons in a 48-unit space (svg carries viewBox="0 0 48 48"). */

.cat-chip-icon { width: 17px; height: 17px; flex: 0 0 auto; color: var(--sage-dark); }

.cat-chip.is-on .cat-chip-icon { color: var(--btn-ink); }

.cat-chip-icon path { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* Filter chip groups (time, difficulty) inside the filters panel */

.filter-group { display: flex; flex-direction: column; gap: 6px; }

.filter-group-label { font-size: 0.76rem; font-weight: 700; color: var(--muted); }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }

.fchip {
  cursor: pointer; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font-size: 0.82rem; font-weight: 600;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.fchip:hover { border-color: var(--sage); }

.fchip.is-on { background: var(--sage); border-color: var(--sage); color: var(--btn-ink); }

.search-pill--diff { text-transform: capitalize; }

.search-meta { margin: 16px 0 10px; color: var(--muted); font-size: 0.84rem; font-weight: 600; }

.search-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: 12px; }

.search-card {
  display: flex; flex-direction: column; gap: 10px; text-align: left; cursor: pointer;
  padding: 14px 15px; border-radius: 11px;
  background: var(--surface); border: 1px solid var(--line);
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s;
}

.search-card:hover { border-color: var(--sage); box-shadow: 0 3px 12px rgba(0,0,0,0.06); }

.search-card:active { transform: scale(0.995); }

.search-card.is-active { border-color: var(--sage); box-shadow: 0 0 0 1px var(--sage); }

/* Image-backed card: recipe photo fills the tile, dark gradient keeps text legible */

.search-card.has-image {
  position: relative; min-height: 168px; justify-content: flex-end;
  border: none; overflow: hidden; color: #fff;
}

.search-card-bg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; z-index: 0;
}

.search-card.has-image::after {
  content: ''; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(to top, rgba(20,22,20,0.86) 0%, rgba(20,22,20,0.42) 48%, rgba(20,22,20,0.04) 100%);
}

.search-card.has-image .search-card-title,
.search-card.has-image .search-card-meta { position: relative; z-index: 2; }

.search-card.has-image .search-card-title { color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,0.55); }

.search-card.has-image .search-pill { background: rgba(0,0,0,0.42); color: #fff; backdrop-filter: blur(2px); }

.search-card.has-image .search-pill--meal { background: rgba(0,0,0,0.42); color: #fff; }

.search-card.has-image:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.18); }

.search-card.has-image.is-active { box-shadow: 0 0 0 2px var(--sage); }

.search-card-title { font-weight: 700; font-size: 0.95rem; line-height: 1.3; color: var(--ink); }

.search-card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }

.search-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  background: var(--paper); color: var(--muted);
  font-size: 0.74rem; font-weight: 700;
}

.search-pill--meal { background: rgba(var(--sage-rgb), 0.14); color: var(--sage-dark); text-transform: capitalize; }

.search-empty { display: flex; align-items: center; gap: 8px; color: var(--muted); padding: 28px 0; }

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

/* ===========================================================================
   Workspace home dashboard — metric cards in the health palette
   ========================================================================= */

.dash-page {
  width: 100%;
  max-width: 1080px;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.dash-head {
  display: grid;
  gap: 10px;
  justify-items: start;
}

.dash-kicker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--sage-dark);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.dash-title {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 3.4vw, 2.4rem);
  font-weight: 700;
  line-height: 1.05;
  color: var(--ink);
}

.dash-stripe {
  width: 180px;
  height: 5px;
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.dash-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 22px;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.dash-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dash-card-head h3 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--ink);
}

.dash-head-icon { color: var(--sage); }

.dash-head-icon--kcal { color: var(--m-kcal); }

.dash-preview-pill {
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--mustard-soft);
  background: var(--mustard-soft);
  color: var(--mustard-ink);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.dash-hint {
  margin-top: auto;
  color: var(--muted);
  font-size: 0.82rem;
}

/* This-week energy bars */

.dash-bars {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  min-height: 150px;
  padding: 6px 4px 0;
}

.dash-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  height: 100%;
}

.dash-bar-track {
  flex: 1;
  width: min(100%, 26px);
  display: flex;
  align-items: flex-end;
  border-radius: 7px;
  background: var(--row);
  overflow: hidden;
}

.dash-bar-fill {
  width: 100%;
  border-radius: 7px 7px 0 0;
  background: linear-gradient(180deg, var(--m-kcal), color-mix(in srgb, var(--m-kcal) 70%, var(--paper)));
  background: var(--m-kcal);
  opacity: 0.85;
}

.dash-bar-day {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

/* Today / empty state */

.dash-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 14px;
  padding: 10px 2px;
  color: var(--muted);
  font-size: 0.92rem;
}

.dash-cta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 9px 16px;
  border: none;
  border-radius: 9px;
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-size: 0.86rem;
  font-weight: 800;
}

.dash-cta:hover { background: var(--sage); }

/* Quick actions */

.dash-actions {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 9px;
}

.dash-action {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 700;
  text-align: left;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.dash-action:hover {
  border-color: var(--sage);
  box-shadow: 0 3px 12px rgba(var(--shadow-rgb), 0.10);
}

.dash-action-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  flex-shrink: 0;
}

.dash-action-icon--search { background: var(--sage-soft); color: var(--m-protein); }

.dash-action-icon--diary { background: var(--mustard-soft); color: var(--mustard-ink); }

.dash-action-icon--assistant { background: var(--terracotta-soft); color: var(--m-fat); }

@media (max-width: 880px) {
  .dash-grid { grid-template-columns: 1fr; }
}

/* Connections rendered as a Profile tab */

.profile-conn-locked {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 36px 24px;
  text-align: center;
  color: var(--muted);
}

.profile-conn-locked h3 {
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 800;
}

/* Search: Cards / List view toggle + compact list rows */

.search-viewtabs {
  display: inline-flex;
  margin-left: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.search-viewtab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.12s, color 0.12s;
}

.search-viewtab:hover { color: var(--ink); }

.search-viewtab.active {
  background: var(--surface);
  color: var(--sage-dark);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.search-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.search-rowitem {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  padding: 8px 12px 8px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.search-rowitem:hover { border-color: var(--sage); }

.search-rowitem.is-active { border-color: var(--sage); box-shadow: 0 0 0 1px var(--sage); }

.search-row-thumb {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 8px;
  overflow: hidden;
  background: var(--row);
  color: var(--muted);
}

.search-row-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.search-row-title {
  flex: 1;
  min-width: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-row-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .search-row-meta .search-pill:nth-child(n+3) { display: none; }
  .search-viewtab span { display: none; }
}

/* ===========================================================================
   Assistant — chat layout, markdown, conversation sidebar, recipe cards
   ========================================================================= */

/* ---------------------------------------------------------------------------
   Assistant section
--------------------------------------------------------------------------- */

/* Full-panel layout — fills workspace-main completely */

.asst-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Narrow inner column keeps text readable; centers on wide screens */

.asst-inner {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 40px;
}

@media (max-width: 760px) {
  .asst-inner { padding: 0 16px; }
}

.asst-header {
  flex-shrink: 0;
  padding: 28px 0 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0;
}

.asst-header h2 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.asst-header p {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 12px;
}

.asst-chat {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 0 8px;
  min-height: 0;
}

/* Welcome state */

.asst-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex: 1;
  padding: 56px 16px 32px;
  text-align: center;
}

.asst-welcome-badge {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: var(--btn-ink);
  background: linear-gradient(135deg, var(--sage), var(--btn-bg));
  box-shadow: 0 8px 22px rgba(var(--shadow-rgb), 0.28);
}

.asst-welcome-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.asst-wave {
  display: inline-block;
  animation: asst-wave 1.6s ease-in-out 2;
  transform-origin: 70% 70%;
}

@keyframes asst-wave {
  0%, 60%, 100% { transform: rotate(0deg); }
  15%, 45% { transform: rotate(16deg); }
  30% { transform: rotate(-8deg); }
}

.asst-welcome-icon {
  color: var(--muted);
  opacity: 0.4;
}

.asst-welcome-text {
  font-size: 0.96rem;
  font-weight: 500;
  line-height: 1.6;
  color: var(--muted);
  max-width: 440px;
}

.asst-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 600px;
}

.asst-suggestion {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}

.asst-suggestion:hover {
  border-color: var(--sage);
  color: var(--sage-dark);
  background: rgba(var(--sage-rgb), 0.05);
}

/* Messages — turn layout */

.asst-turn {
  display: flex;
  animation: asst-turn-in 0.18s ease;
}

@keyframes asst-turn-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.asst-turn--user { justify-content: flex-end; }

.asst-turn--assistant {
  justify-content: flex-start;
  gap: 11px;
}

/* Column wrapper: activity + bubble + recipe cards stacked */

.asst-turn-col {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  max-width: calc(100% - 48px);
}

.asst-bubble {
  max-width: 100%;
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.65;
  word-break: break-word;
}

.asst-turn--user .asst-bubble--user { max-width: min(78%, 560px); }

.asst-bubble--user {
  background: var(--btn-bg);
  color: var(--btn-ink);
  border-bottom-right-radius: 5px;
  /* plain text — preserve user's line breaks */
  white-space: pre-wrap;
}

.asst-bubble--assistant {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  border-bottom-left-radius: 5px;
  box-shadow: 0 1px 2px rgba(var(--ink-rgb), 0.03);
  /* rendered markdown — let block elements control their own whitespace */
  white-space: normal;
}

.asst-bubble--thinking {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
}

.asst-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: asst-bounce 1.2s ease-in-out infinite;
}

.asst-dot:nth-child(2) { animation-delay: 0.2s; }

.asst-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes asst-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

.asst-error {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 13px;
  border-radius: 8px;
  background: rgba(var(--terracotta-rgb), 0.08);
  border: 1px solid rgba(var(--terracotta-rgb), 0.2);
  color: var(--terracotta-ink);
  font-size: 0.85rem;
  font-weight: 600;
}

/* Input bar — pinned to bottom of inner column */

.asst-footer {
  flex-shrink: 0;
  padding: 12px 0 20px;
  border-top: 1px solid var(--line);
}

.asst-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 7px 7px 7px 8px;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 4px 18px rgba(var(--ink-rgb), 0.06);
  transition: border-color 0.12s, box-shadow 0.12s;
}

.asst-input-row:focus-within {
  border-color: var(--sage);
  box-shadow: 0 4px 18px rgba(var(--ink-rgb), 0.06), 0 0 0 3px rgba(var(--sage-rgb), 0.1);
}

.asst-input {
  flex: 1;
  min-height: 32px;
  max-height: 160px;
  padding: 8px 6px 8px 8px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.92rem;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  overflow-y: auto;
  field-sizing: content;
}

.asst-input:focus { outline: none; }

.asst-input:disabled { opacity: 0.6; background: transparent; }

.asst-send {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  border: none;
  background: var(--btn-bg);
  color: var(--btn-ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, opacity 0.12s;
}

.asst-send:hover:not(:disabled) { background: var(--sage); }

.asst-send:disabled { opacity: 0.35; cursor: default; }

.asst-hint {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--muted);
}

/* Tool activity strip */

.asst-activity {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.asst-activity-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(var(--sage-rgb), 0.07);
  border: 1px solid rgba(var(--sage-rgb), 0.15);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--sage-dark);
  width: fit-content;
}

.asst-activity-item--done {
  background: rgba(var(--sage-rgb), 0.04);
  border-color: var(--line);
  color: var(--muted);
}

.asst-activity-icon { font-size: 0.85rem; line-height: 1; }

.asst-activity-text { flex: 1; }

.asst-activity-spinner {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(var(--sage-rgb), 0.2);
  border-top-color: var(--sage);
  animation: asst-spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes asst-spin { to { transform: rotate(360deg); } }

/* Streaming cursor */

.asst-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--sage);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: asst-blink 0.8s step-end infinite;
}

@keyframes asst-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* Markdown inside assistant bubbles (rendered by Streamdown) */

.asst-md { display: block; }

.asst-md > :first-child { margin-top: 0; }

.asst-md > :last-child { margin-bottom: 0; }

.asst-md-pre {
  margin: 0.5em 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--row);
  border: 1px solid var(--line);
  overflow-x: auto;
  font-size: 0.82em;
  line-height: 1.5;
}

.asst-md-pre .asst-md-code { background: none; padding: 0; }

.asst-md-p { margin-bottom: 0.5em; }

.asst-md-p:last-child { margin-bottom: 0; }

.asst-md-h {
  font-size: 0.95rem;
  font-weight: 800;
  margin: 0.75em 0 0.3em;
  color: var(--ink);
}

.asst-md-h3 {
  font-size: 0.88rem;
  font-weight: 700;
  margin: 0.6em 0 0.25em;
  color: var(--ink);
}

.asst-md-ul,
.asst-md-ol {
  padding-left: 1.2em;
  margin: 0.3em 0 0.5em;
}

.asst-md-li { margin-bottom: 0.25em; }

.asst-md-code {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(var(--sage-rgb), 0.08);
  font-family: ui-monospace, monospace;
  font-size: 0.82em;
}

.asst-md-hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 0.75em 0;
}

.asst-md-table-wrap {
  overflow-x: auto;
  margin: 0.5em 0;
}

.asst-md-table {
  border-collapse: collapse;
  font-size: 0.85rem;
  min-width: 100%;
}

.asst-md-th,
.asst-md-td {
  padding: 6px 12px;
  border: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.asst-md-th {
  background: rgba(var(--sage-rgb), 0.07);
  font-weight: 700;
  color: var(--ink);
}

.asst-md-table tbody tr:hover {
  background: rgba(var(--sage-rgb), 0.03);
}

.asst-bubble--assistant a {
  color: var(--sage-dark);
  text-decoration: underline;
  text-decoration-color: rgba(var(--sage-rgb), 0.4);
  text-underline-offset: 2px;
}

.asst-bubble--assistant a:hover {
  text-decoration-color: var(--sage-dark);
}

/* ===========================================================================
   Assistant v2 — full-featured layout with conversation sidebar + recipe panel
=========================================================================== */

/* Window-in-window (quiniela qnl-page style): the assistant lives in a
   height-capped glass card inside the normally scrolling page, so it works
   on narrow screens without taking over the whole viewport. */

.asst-page-v2 {
  position: relative;
  display: flex;
  width: 100%;
  max-width: 1400px;
  margin-inline: auto;
  height: calc(100dvh - var(--topbar-h) - 2 * var(--main-pad-y));
  min-height: 440px;
  max-height: 860px;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  background: var(--card-solid);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

/* ---------------------------------------------------------------------------
   Conversation sidebar
--------------------------------------------------------------------------- */

.conv-sidebar {
  width: 230px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 12px 8px;
  gap: 8px;
  overflow: hidden;
}

.conv-new-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 10px;
  background: var(--btn-bg);
  color: var(--btn-ink);
  border: none;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

.conv-new-btn:hover { background: var(--sage); }

.conv-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.conv-loading {
  display: flex;
  justify-content: center;
  padding: 16px 0;
  color: var(--muted);
}

.conv-empty {
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  padding: 16px 8px;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 8px 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.12s;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
}

.conv-item:hover { background: var(--line); }

.conv-item.active { background: var(--line); }

.conv-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.conv-item-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.conv-item-time {
  font-size: 0.7rem;
  color: var(--muted);
}

.conv-item-delete {
  opacity: 0;
  padding: 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: opacity 0.12s, color 0.12s;
  flex-shrink: 0;
}

.conv-item:hover .conv-item-delete { opacity: 1; }

.conv-item-delete:hover { color: var(--terracotta); background: var(--terracotta-soft); }

/* ---------------------------------------------------------------------------
   Main chat area
--------------------------------------------------------------------------- */

.asst-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: flex 0.25s ease;
}

.chat-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

/* Assistant avatar to the left of assistant turns */

.asst-avatar {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--sage), var(--sage-dark));
  color: var(--btn-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  box-shadow: 0 2px 6px rgba(var(--shadow-rgb), 0.2);
}

.chat-footer {
  flex-shrink: 0;
  padding: 10px 24px 20px;
  background: transparent;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

/* Footer row: hint on the left, usage meter on the right */

.asst-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* Usage limit banner above the composer */

.asst-limit-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 9px 13px;
  border-radius: 9px;
  background: rgba(var(--terracotta-rgb), 0.08);
  border: 1px solid rgba(var(--terracotta-rgb), 0.25);
  color: var(--terracotta-ink);
  font-size: 0.83rem;
  font-weight: 600;
}

/* Usage meter (token quotas) */

.usage-meter {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  color: var(--muted);
}

.usage-meter-icon { color: var(--muted); flex-shrink: 0; }

.usage-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: default;
}

.usage-bar-label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.usage-bar-track {
  width: 54px;
  height: 5px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.usage-bar-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--sage);
  transition: width 0.3s ease, background 0.2s;
}

.usage-bar-num { font-variant-numeric: tabular-nums; color: var(--muted); }

.usage-bar--high .usage-bar-fill { background: var(--mustard); }

.usage-bar--over .usage-bar-fill { background: var(--terracotta); }

.usage-bar--over .usage-bar-num { color: var(--terracotta); font-weight: 700; }

/* Stop button (while streaming) */

.asst-send--stop {
  background: var(--terracotta);
}

.asst-send--stop:hover { background: var(--terracotta); }

.asst-input-row--blocked { opacity: 0.7; }

/* ---------------------------------------------------------------------------
   Thinking steps (replaces old ToolActivity)
--------------------------------------------------------------------------- */

.thinking-steps {
  margin-bottom: 2px;
}

.thinking-lead { flex-shrink: 0; color: var(--muted); }

.thinking-steps--running .thinking-lead,
.thinking-steps--running .thinking-label { color: var(--sage-dark); }

.thinking-steps--running .thinking-label {
  background: linear-gradient(90deg, var(--muted) 30%, var(--sage) 50%, var(--muted) 70%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: thinking-shimmer 1.6s linear infinite;
}

@keyframes thinking-shimmer {
  to { background-position: -200% center; }
}

.thinking-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 6px 4px 4px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
  text-align: left;
}

.thinking-toggle:hover { background: var(--line); color: var(--ink); }

.thinking-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
  transition: background 0.2s;
}

.thinking-dot--active {
  background: var(--sage);
  animation: thinking-pulse 1.2s ease-in-out infinite;
}

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

.thinking-label { flex-shrink: 0; }

.thinking-count {
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.75;
}

.thinking-chevron {
  flex-shrink: 0;
  transition: transform 0.2s;
}

.thinking-chevron.open { transform: rotate(180deg); }

.thinking-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.thinking-reasoning {
  white-space: pre-wrap;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--muted);
  padding: 9px 11px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 2px solid var(--sage);
  border-radius: 8px;
  max-height: 280px;
  overflow-y: auto;
}

/* Tool step (interleaved with reasoning) */

.thinking-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--ink);
  padding: 7px 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.thinking-step-icon { flex-shrink: 0; color: var(--muted); }

.thinking-step-icon.done { color: var(--sage); }

.thinking-step-name { font-weight: 600; }

.thinking-step-summary {
  color: var(--muted);
  font-weight: 500;
}

.thinking-step-summary::before {
  content: '·';
  margin-right: 6px;
  color: var(--line);
}

/* Collapsed summary: a tidy row of tool chips */

.thinking-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.thinking-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(var(--sage-rgb), 0.08);
  border: 1px solid rgba(var(--sage-rgb), 0.16);
  color: var(--sage-dark);
  font-size: 0.72rem;
  font-weight: 600;
}

.thinking-chip svg { color: var(--sage); }

/* ---------------------------------------------------------------------------
   Recipe panel (side panel / artifact)
--------------------------------------------------------------------------- */

.recipe-panel {
  width: 372px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
  animation: panel-slide-in 0.2s ease;
}

.recipe-panel-scroll {
  flex: 1;
  overflow-y: auto;
}

@keyframes panel-slide-in {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.recipe-panel-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.recipe-panel-title-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.recipe-panel-icon {
  color: var(--sage);
  flex-shrink: 0;
  margin-top: 2px;
}

.recipe-panel-title {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
}

.recipe-panel-close {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px;
  color: var(--muted);
  border-radius: 5px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}

.recipe-panel-close:hover { background: var(--line); color: var(--ink); }

.recipe-panel-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 16px;
}

.recipe-meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}

.recipe-meta-diff {
  color: var(--sage-dark);
  border-color: var(--sage);
  background: rgba(var(--sage-rgb), 0.08);
}

.recipe-panel-nutrition {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 0 16px 12px;
}

.recipe-nutr-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: 8px;
  text-align: center;
}

.recipe-nutr-kcal { background: rgba(var(--blue-rgb), 0.10); }

.recipe-nutr-p    { background: rgba(var(--sage-rgb), 0.10); }

.recipe-nutr-f    { background: var(--terracotta-soft); }

.recipe-nutr-c    { background: var(--mustard-soft); }

.recipe-nutr-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}

.recipe-nutr-label {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.recipe-nutr-kcal svg { color: var(--m-kcal); margin-bottom: 2px; }

.recipe-weight-note {
  grid-column: 1 / -1;
  font-size: 0.7rem;
  color: var(--muted);
  padding: 0 4px;
}

.recipe-section {
  padding: 0 16px 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.recipe-section + .recipe-section { border-top: 1px solid var(--line); }

.recipe-section-title {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--sage-dark);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.recipe-ingredients {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.recipe-ingredient {
  font-size: 0.83rem;
  color: var(--ink);
  padding: 5px 8px;
  background: var(--paper);
  border-radius: 5px;
  line-height: 1.3;
}

.recipe-ingredient::before {
  content: '· ';
  color: var(--sage);
}

.recipe-steps { list-style: none; display: flex; flex-direction: column; gap: 10px; }

.recipe-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.83rem;
  color: var(--ink);
  line-height: 1.4;
}

.recipe-step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.recipe-panel-link {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 16px 16px;
  padding: 10px 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--sage-dark);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.12s, border-color 0.12s;
}

.recipe-panel-link:hover { background: rgba(var(--sage-rgb), 0.08); border-color: var(--sage); }

/* "Get preparation steps" — primary live-fetch action above the Cookidoo link */

.recipe-getsteps { margin: 8px 16px 0; }

.recipe-getsteps-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: none;
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.12s;
}

.recipe-getsteps-btn:hover { opacity: 0.92; }

.recipe-getsteps-btn:disabled { opacity: 0.7; cursor: default; }

.recipe-getsteps-error {
  margin: 8px 0 0;
  font-size: 0.78rem;
  color: var(--red);
}

/* ---------------------------------------------------------------------------
   Recipe card list (inline in chat — clickable to open panel)
--------------------------------------------------------------------------- */

.recipe-card-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  max-width: 540px;
}

.recipe-card {
  display: flex;
  align-items: stretch;
  gap: 11px;
  padding: 9px 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
  width: 100%;
}

.recipe-card-thumb {
  width: 58px;
  height: 58px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--paper);
  display: grid;
  place-items: center;
}

.recipe-card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.recipe-card-thumb--ph { color: var(--line); }

.recipe-card-main {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  flex: 1;
}

.recipe-card:hover {
  border-color: var(--sage);
  background: rgba(var(--sage-rgb), 0.08);
  box-shadow: 0 1px 6px rgba(var(--sage-rgb), 0.12);
}

.recipe-card--active {
  border-color: var(--sage);
  background: rgba(var(--sage-rgb), 0.08);
  box-shadow: inset 3px 0 0 var(--sage-dark);
}

.recipe-card-title {
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.recipe-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--muted);
}

.recipe-card-meta > span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.recipe-card-cta {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--sage-dark);
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 2px;
}

/* ---------------------------------------------------------------------------
   Cursor animations for new component classes
--------------------------------------------------------------------------- */

.asst-cursor-blink {
  display: inline-block;
  width: 8px;
  height: 1em;
  background: var(--sage);
  border-radius: 1px;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: asst-blink 0.8s step-end infinite;
}

/* Spinning utility */

.spinning {
  animation: spin 0.7s linear infinite;
}

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

/* Narrow screens: window compacts, the conversation sidebar yields to the
   chat, and the recipe panel overlays inside the window. Kept last so these
   rules win over the base definitions above. */

@media (max-width: 760px) {
  .asst-page-v2 {
    border-radius: 12px;
    min-height: 380px;
  }

  .conv-sidebar {
    display: none;
  }

  /* The recipe panel overlays the chat inside the window on narrow screens */
  .asst-page-v2 .recipe-panel {
    position: absolute;
    inset: 0 0 0 auto;
    width: min(100%, 372px);
    z-index: 5;
    box-shadow: -12px 0 30px rgba(var(--shadow-rgb), 0.25);
  }
}

/* Window bar + conversation overlay (narrow screens) */

.asst-window-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.asst-window-kicker {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sage-dark);
}

.asst-icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.asst-icon-btn:hover {
  background: rgba(var(--sage-rgb), 0.08);
}

.asst-conv-overlay {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: none;
  pointer-events: none;
}

.asst-conv-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 18, 16, 0.45);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.asst-conv-overlay-panel {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(85%, 300px);
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  box-shadow: 14px 0 36px rgba(var(--shadow-rgb), 0.30);
}

.asst-conv-overlay .conv-sidebar {
  display: flex;
  width: 100%;
  height: 100%;
  border-right: 1px solid var(--line);
}

.asst-conv-close {
  position: absolute;
  top: 8px;
  right: 8px;
}

.asst-conv-overlay.open {
  pointer-events: auto;
}

.asst-conv-overlay.open .asst-conv-overlay-backdrop {
  opacity: 1;
}

.asst-conv-overlay.open .asst-conv-overlay-panel {
  transform: translateX(0);
}

@media (max-width: 760px) {
  .asst-window-bar {
    display: flex;
  }

  .asst-conv-overlay {
    display: block;
  }

  /* Leave room for the floating close button above the new-conversation btn */
  .asst-conv-overlay .conv-new-btn {
    width: calc(100% - 44px);
  }
}

/* ===========================================================================
   Theme — dark-mode component fixups that can't be expressed via tokens.
   Most components flip automatically through the dual token sets in
   base.css (including the rgba(var(--*-rgb), a) alpha composites).
   ========================================================================= */

:root[data-theme="dark"] ::selection {
  background: rgba(223, 142, 102, 0.35);
}

/* Photo-backed recipe cards: dim slightly so white text keeps contrast and
   the cards don't glow against the dark paper. */

:root[data-theme="dark"] .search-card-bg,
:root[data-theme="dark"] .recipe-panel-banner img,
:root[data-theme="dark"] .recipe-thumb img {
  filter: brightness(0.85) saturate(0.95);
}

/* Subtle paper-tint rows read too dark over the dark gradient backdrop. */

:root[data-theme="dark"] .diary-viewtab.active {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* Chrome gets slightly deeper in dark mode (tokens in base.css); the
   navbar shadow needs to follow. */

:root[data-theme="dark"] .app-navbar {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}
