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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: radial-gradient(circle at top right, var(--brand-soft) 0%, transparent 38%), var(--bg);
  color: var(--text-primary);
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
  line-height: 1.5;
  transition: background-color 220ms ease, color 220ms ease;
}

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

/* iOS Safari data detectors can inject decorated links into content blocks. */
a[x-apple-data-detectors],
a[x-apple-data-detectors]:hover,
a[x-apple-data-detectors]:focus,
a[x-apple-data-detectors]:active {
  color: inherit !important;
  text-decoration: none !important;
  font: inherit !important;
}

:where(a, button, summary, [role="button"], input[type="button"], input[type="submit"]) {
  -webkit-tap-highlight-color: transparent;
}

/* Prevent accidental text selection on interactive UI elements (mobile) */
:where(button, summary, [role="button"], input[type="button"], input[type="submit"]),
.ui-button,
.meal-card,
.kbju-sheet__panel,
.kbju-field,
.modal-sheet__panel,
.analysis-products__name-row button,
.analysis-products__field-label,
.analysis-macros,
.analysis-result-card__header,
.analysis-copy-btn {
  user-select: none;
}

.app-shell {
  padding-bottom: 3rem;
  transition: opacity 180ms ease, transform 180ms ease, filter 180ms ease;
}

@media (max-width: 54rem) {
  .app-shell--has-tabbar {
    padding-bottom: calc(3.6rem + env(safe-area-inset-bottom, 0px) + 1rem);
  }
}

.native-app-page .app-shell--has-tabbar {
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
}

body.turbo-page--leaving .app-shell {
  opacity: 0.86;
  transform: scale(0.99);
  filter: blur(0.25px);
}

body.turbo-page--entering .app-shell {
  animation: app-shell-enter 220ms ease both;
}

.ui-container {
  width: min(100% - 2rem, 72rem);
  margin-inline: auto;
}

.navbar {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
  background: color-mix(in oklab, var(--bg) 96%, transparent);
  border-bottom: 1px solid var(--surface-border);
}

.navbar__inner {
  min-height: 4rem;
  padding: 0.7rem 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem;
}

.navbar__brand {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.navbar__inner--compact {
  min-height: 3.35rem;
  padding: 0.55rem 0;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.navbar__app-icon,
.navbar__profile-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.75rem;
  border: 1px solid color-mix(in oklab, var(--surface-border) 68%, transparent);
  background: color-mix(in oklab, var(--bg-elevated) 82%, transparent);
  color: color-mix(in oklab, var(--text-primary) 86%, var(--brand) 14%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
  transition: transform 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.navbar__app-icon img {
  width: 1.75rem;
  height: 1.75rem;
  display: block;
  border-radius: 0.35rem;
}

.navbar__profile-icon svg {
  width: 1.4rem;
  height: 1.4rem;
  display: block;
}

.navbar__app-icon:hover,
.navbar__profile-icon:hover {
  transform: translateY(-1px);
  border-color: color-mix(in oklab, var(--surface-border) 52%, var(--brand) 48%);
  background: color-mix(in oklab, var(--bg) 70%, var(--brand) 30%);
}

.navbar__profile-icon--active {
  border-color: color-mix(in oklab, var(--brand) 58%, var(--surface-border) 42%);
  background: color-mix(in oklab, var(--brand) 14%, var(--bg-elevated) 86%);
}

.navbar__app-icon:focus-visible,
.navbar__profile-icon:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.navbar__compact-links {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-width: 0;
}

.navbar__compact-link {
  border: 1px solid color-mix(in oklab, var(--surface-border) 68%, transparent);
  border-radius: 999px;
  padding: 0.38rem 0.72rem;
  font-size: 0.88rem;
  font-weight: 620;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.navbar__compact-link--active {
  color: var(--text-primary);
  border-color: color-mix(in oklab, var(--brand) 55%, var(--surface-border) 45%);
  background: color-mix(in oklab, var(--brand) 14%, var(--bg-elevated) 86%);
}

.navbar__compact-link:hover,
.navbar__compact-link:focus-visible {
  color: var(--text-primary);
  border-color: color-mix(in oklab, var(--brand) 42%, var(--surface-border) 58%);
}

.navbar__compact-desktop {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.navbar__compact-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.navbar__inner--compact .navbar__profile-icon {
  margin-left: auto;
}

/* ── Bottom Tab Bar (mobile, authenticated) ── */

.tabbar {
  display: none;
}

@media (max-width: 54rem) {
  .tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    height: 3.6rem;
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: rgba(var(--bg-elevated-rgb), 0.72);
    background: color-mix(in oklab, var(--bg-elevated) 72%, transparent);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border-top: 1px solid color-mix(in oklab, var(--surface-border) 50%, transparent);
  }
}

/* Tabbar hidden in native apps — managed by native bottom navigation */
.native-app-page .tabbar { display: none !important; }

/* Hide web navbar on native — native chrome replaces it.
   CSS rule ensures no flash during Turbo preview (JS patch runs late). */
.native-app-page .navbar {
  display: none !important;
}

/* .turbo-progress-bar is a direct child of <html>, not <body>,
   so use :has() to reach it from the body class.
   JS in application.js also disables it via Turbo.config for belt-and-suspenders. */
html:has(body.native-app-page) > .turbo-progress-bar {
  display: none !important;
}

.native-app-page .app-shell {
  padding-top: 1.2rem;
}

.native-app-page .meal-fab,
.native-app-page .fab-speed-dial {
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}

.native-app-page .meal-form__cropper {
  bottom: var(--native-bottom-nav-height, 0px);
}

.native-app-page .meal-form__cropper-dialog {
  max-height: var(--cropper-dialog-max-height, 100%);
}

.native-app-page .meal-page {
  padding-bottom: calc(var(--native-bottom-nav-height, 0px) + 1rem);
}

.native-app-page .meal-page--entries {
  padding-top: 0;
  padding-bottom: calc(var(--native-bottom-nav-height, 0px) + 5.8rem + env(safe-area-inset-bottom, 0px));
}

.tabbar__tab {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: none;
  font: inherit;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.18rem;
  padding: 0.35rem 0;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 120ms ease;
  text-decoration: none;
}

.tabbar__tab--active {
  color: var(--brand);
}

.tabbar__icon {
  width: 1.35rem;
  height: 1.35rem;
  flex-shrink: 0;
}

.tabbar__label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
}

.navbar__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.navbar__link {
  white-space: nowrap;
}

.navbar__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.navbar__locales {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.navbar__locale {
  border: 1px solid var(--surface-border);
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.22rem 0.5rem;
  transition: background-color 120ms ease, color 120ms ease;
}

.navbar__locale:hover,
.navbar__locale:focus-visible {
  color: var(--text-primary);
}

.navbar__locale--active {
  background: var(--bg-muted);
  color: var(--text-primary);
}

.navbar__link:hover,
.navbar__link:focus-visible {
  color: var(--text-primary);
}

@media (max-width: 54rem) {
  .navbar__inner {
    row-gap: 0.6rem;
  }

  .navbar__links {
    flex-basis: 100%;
    order: 3;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.1rem;
  }

  .navbar__links::-webkit-scrollbar {
    display: none;
  }

  .navbar__link {
    flex: 0 0 auto;
  }

  .navbar__actions {
    order: 2;
    gap: 0.45rem;
  }

  .navbar__inner--compact {
    min-height: 3.15rem;
  }

  .navbar__inner--compact .navbar__profile-icon,
  .navbar__inner--compact .navbar__compact-desktop {
    display: none;
  }

  .meal-page__header .ui-button {
    min-height: 2.55rem;
    padding-inline: 0.88rem;
  }
}

@media (max-width: 26rem) {
  .meal-page__header .ui-button {
    width: 100%;
    justify-content: center;
  }
}

.theme-toggle {
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid var(--surface-border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-radius: 999px;
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  font: inherit;
  line-height: 0;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
}

.theme-toggle__icon {
  width: 1.05rem;
  height: 1.05rem;
  display: none;
  place-items: center;
  grid-area: 1 / 1;
  pointer-events: none;
}

.theme-toggle::-moz-focus-inner {
  border: 0;
  padding: 0;
}

.theme-toggle__icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

html[data-theme="dark"] .theme-toggle__icon--sun {
  display: grid;
}

html[data-theme="light"] .theme-toggle__icon--moon {
  display: grid;
}

.ui-button {
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.ui-button:focus-visible,
.theme-toggle:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.ui-button:hover {
  transform: translateY(-1px);
}

.ui-button--sm {
  padding: 0.42rem 0.82rem;
  font-size: 0.84rem;
}

.ui-button--md {
  padding: 0.56rem 1rem;
  font-size: 0.92rem;
}

.ui-button--lg {
  padding: 0.74rem 1.2rem;
  font-size: 0.98rem;
}

.ui-button--primary {
  background: var(--brand);
  color: var(--text-inverse);
  box-shadow: var(--shadow-sm);
}

.ui-button--primary:hover {
  background: var(--brand-strong);
}

.ui-button--secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--surface-border);
}

.ui-button--ghost {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--surface-border);
}

.ui-button--danger {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
  box-shadow: var(--shadow-sm);
}

.ui-button--danger:hover {
  background: #dc2626;
  border-color: #dc2626;
}

.ui-button--danger-ghost {
  background: transparent;
  color: var(--color-error);
  border-color: var(--color-error);
}

.ui-button--danger-ghost:hover {
  background: color-mix(in srgb, var(--color-error) 8%, transparent);
  border-color: var(--color-error);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ui-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.18rem 0.5rem;
  font-size: 0.7rem;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid color-mix(in oklab, var(--surface-border) 68%, transparent);
  background: color-mix(in oklab, var(--bg) 86%, transparent);
  color: var(--text-secondary);
  white-space: nowrap;
}

.ui-badge--soon {
  border-color: color-mix(in oklab, var(--brand) 40%, var(--surface-border) 60%);
  background: color-mix(in oklab, var(--brand) 10%, var(--bg-elevated));
  color: color-mix(in oklab, var(--text-primary) 86%, var(--brand) 14%);
}

.ui-loader {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text-secondary);
}

.ui-loader--inline {
  vertical-align: middle;
}

.ui-loader--framed {
  padding: 0.45rem 0.6rem;
  border-radius: 0.8rem;
  border: 1px solid color-mix(in oklab, var(--surface-border) 70%, transparent);
  background: color-mix(in oklab, var(--bg) 88%, transparent);
}

.ui-loader--xs {
  --ui-loader-dot: 0.34rem;
  --ui-loader-gap: 0.22rem;
}

.ui-loader--sm {
  --ui-loader-dot: 0.42rem;
  --ui-loader-gap: 0.3rem;
}

.ui-loader--md {
  --ui-loader-dot: 0.52rem;
  --ui-loader-gap: 0.34rem;
}

.ui-loader--lg {
  --ui-loader-dot: 0.62rem;
  --ui-loader-gap: 0.38rem;
}

.ui-loader__label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ui-loader--labeled {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ui-loader--labeled .ui-loader__label {
  position: static;
  width: auto;
  height: auto;
  padding: 0;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  border: 0;
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

.ui-loader__dots {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-loader-gap, 0.3rem);
}

.ui-loader__dot {
  width: var(--ui-loader-dot, 0.42rem);
  height: var(--ui-loader-dot, 0.42rem);
  border-radius: 999px;
  background: color-mix(in oklab, var(--text-secondary) 78%, var(--brand) 22%);
  opacity: 0.35;
  transform: translateY(0);
  animation: analysis-dot 900ms ease-in-out infinite;
}

.ui-loader__dot:nth-child(2) {
  animation-delay: 120ms;
}

.ui-loader__dot:nth-child(3) {
  animation-delay: 240ms;
}

.flash {
  position: fixed;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9000;
  width: min(calc(100% - 2rem), 28rem);
  margin: 0;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--surface-border);
  border-left: 3px solid var(--flash-accent);
  border-radius: 0.875rem;
  font-size: 0.9rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: flash-enter 260ms cubic-bezier(0.22, 1, 0.36, 1) both;
  touch-action: pan-y;
}

@media (max-width: 54rem) {
  .app-shell--has-tabbar .flash {
    bottom: calc(3.6rem + env(safe-area-inset-bottom, 0px) + 0.75rem);
  }
}

.native-app-page .flash {
  bottom: calc(env(safe-area-inset-bottom, 0px) + 0.75rem);
}

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

@media (prefers-reduced-motion: reduce) {
  @keyframes flash-enter {
    from { opacity: 0; transform: translateX(-50%); }
    to { opacity: 1; transform: translateX(-50%); }
  }
}

.flash--alert {
  --flash-accent: var(--color-error, #e11d48);
  background: color-mix(in oklab, #e11d48 12%, var(--bg-elevated));
}

.flash--notice {
  --flash-accent: var(--color-success, #16a34a);
  background: color-mix(in oklab, #16a34a 10%, var(--bg-elevated));
}

.flash__icon {
  flex: 0 0 auto;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--flash-accent);
}

.flash__text {
  flex: 1 1 auto;
}

.flash__close {
  flex: 0 0 auto;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  min-width: 2.75rem;
  min-height: 2.75rem;
  display: inline-grid;
  place-items: center;
  margin-left: 0.25rem;
  opacity: 0.7;
  transition: opacity 120ms ease;
}

.flash__close:hover {
  opacity: 1;
}

.auth-page {
  padding: 2rem 0;
}

.native-modal-page .auth-page {
  padding: 0.8rem 0 1rem;
}

.auth-page__container {
  width: min(100% - 2rem, 28rem);
  margin-inline: auto;
}

.auth-page__logo {
  text-align: center;
  margin-bottom: 1.2rem;
}

.auth-page__logo-img {
  border-radius: 1rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.auth-page__footer {
  text-align: center;
  margin-top: 1rem;
}

.auth-page__privacy-link {
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-decoration: none;
}

.auth-page__privacy-link:hover {
  text-decoration: underline;
}

.auth-card {
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border);
  border-radius: 1rem;
  box-shadow: var(--shadow-sm);
  padding: 1rem;
}

.auth-card__title {
  margin: 0 0 0.9rem;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}

.auth-form {
  display: grid;
  gap: 0.75rem;
}

.auth-field {
  display: block;
}

.auth-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.auth-input {
  width: 100%;
  border: 1px solid var(--surface-border);
  background: var(--bg);
  color: var(--text-primary);
  border-radius: 0.75rem;
  padding: 0.65rem 0.75rem;
  font: inherit;
}

.auth-input::placeholder {
  color: var(--text-secondary);
}

.auth-input:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.auth-input--has-toggle {
  padding-right: 2.75rem;
}

.auth-field__password-wrap {
  position: relative;
}

.auth-field__toggle {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 120ms ease;
}

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

.auth-field__toggle:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.auth-field__toggle-icon {
  width: 1.15rem;
  height: 1.15rem;
}

.auth-field__toggle-icon.is-hidden {
  display: none !important;
}

.auth-hint {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.auth-field__warning {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: #d97706;
  line-height: 1.3;
  animation: auth-warning-enter 250ms ease both;
}

@keyframes auth-warning-enter {
  from {
    opacity: 0;
    transform: translateY(-0.25rem);
  }
}

@keyframes auth-warning-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.auth-field__warning--shake {
  animation: auth-warning-shake 400ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .auth-field__warning,
  .auth-field__warning--shake {
    animation: none;
  }
}

.auth-field__error {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: #ef4444;
  line-height: 1.3;
}

.auth-input[aria-invalid="true"] {
  border-color: #ef4444;
}

.auth-actions {
  margin-top: 0.1rem;
}

.auth-actions .ui-button {
  width: 100%;
}

.auth-links {
  margin-top: 0.7rem;
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.meal-page {
  padding: 2rem 0;
}

.meal-page:not(.meal-page--entries) {
  overflow-x: clip;
}

.native-modal-page .meal-page {
  padding: 0.8rem 0 1rem;
}

.meal-page--entries {
  padding-top: 0.2rem;
  padding-bottom: 5rem;
}

.meal-page__container {
  display: grid;
  gap: 1.15rem;
}

.meal-page__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.meal-page__header .meal-card__title {
  flex: 1 1 12rem;
  min-width: 0;
}

.meal-page__actions {
  margin-top: 0.8rem;
}

/* Empty state (meal entries, etc.) */
.empty-state__body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2rem 1rem;
  gap: 0.5rem;
  animation: empty-state-in 400ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes empty-state-in {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.empty-state__icon {
  width: 4rem;
  height: 4rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  animation: empty-state-float 3.5s ease-in-out infinite;
}

@keyframes empty-state-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.empty-state__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.empty-state__hint {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.4;
  max-width: 28rem;
}

.meal-fab {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: calc(1rem + env(safe-area-inset-bottom));
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--brand) 70%, var(--surface-border) 30%);
  background:
    linear-gradient(
      110deg,
      color-mix(in oklab, var(--brand) 76%, var(--brand-strong) 24%) 0%,
      color-mix(in oklab, var(--brand) 82%, white 18%) 36%,
      color-mix(in oklab, var(--brand-strong) 84%, var(--brand) 16%) 70%,
      color-mix(in oklab, var(--brand) 76%, var(--brand-strong) 24%) 100%
    );
  background-size: 220% 100%;
  color: var(--text-inverse);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  text-decoration: none;
  box-shadow:
    0 14px 30px color-mix(in oklab, var(--brand) 32%, transparent),
    0 0 18px color-mix(in oklab, var(--brand) 18%, transparent),
    0 0 0 1px color-mix(in oklab, var(--brand) 65%, transparent) inset,
    0 0 10px color-mix(in oklab, white 12%, transparent) inset;
  z-index: 32;
  isolation: isolate;
  transition: transform 180ms ease, filter 180ms ease, box-shadow 180ms ease;
  animation:
    fab-entrance 400ms cubic-bezier(0.34, 1.56, 0.64, 1) 300ms both,
    fab-pulse 2.4s ease-in-out 800ms infinite;
}

@keyframes fab-entrance {
  from { opacity: 0; transform: scale(0.6) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.meal-fab__icon {
  width: 1.34rem;
  height: 1.34rem;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 1px 4px rgba(8, 15, 32, 0.28));
  flex-shrink: 0;
}

.meal-fab__label {
  display: none;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 1px 3px rgba(8, 15, 32, 0.22));
}

@media (min-width: 640px) {
  .meal-fab {
    width: auto;
    height: auto;
    padding: 0.75rem 1.5rem;
  }

  .meal-fab__label {
    display: inline;
  }
}

.meal-fab:hover,
.meal-fab:focus-visible {
  transform: translateY(-2px) scale(1.03);
  filter: brightness(1.03);
  box-shadow:
    0 18px 34px color-mix(in oklab, var(--brand) 36%, transparent),
    0 0 20px color-mix(in oklab, var(--brand) 24%, transparent),
    0 0 0 1px color-mix(in oklab, var(--brand) 72%, transparent) inset;
}

.meal-fab:focus-visible {
  outline: 2px solid color-mix(in oklab, var(--brand) 55%, white 45%);
  outline-offset: 3px;
}

/* ── Sync-pending banner (native apps only) ─────────────────────── */
.sync-pending-banner {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border);
  border-radius: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.native-app-page .sync-pending-banner[data-visible="true"] {
  display: flex;
}

.sync-pending-banner__icon {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.sync-pending-banner__text {
  line-height: 1.3;
}

.native-app-page .sync-pending-banner[data-sync-state="syncing"] {
  color: var(--brand);
  border-color: color-mix(in oklab, var(--brand) 30%, var(--surface-border));
}

.native-app-page .sync-pending-banner[data-sync-state="syncing"] .sync-pending-banner__icon {
  color: var(--brand);
  animation: sync-spin 1s linear infinite;
}

.native-app-page .sync-pending-banner[data-sync-state="success"] {
  color: var(--text-success, #2e7d32);
  border-color: color-mix(in oklab, var(--text-success, #2e7d32) 30%, var(--surface-border));
}

.native-app-page .sync-pending-banner[data-sync-state="success"] .sync-pending-banner__icon {
  color: var(--text-success, #2e7d32);
}

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

@media (max-width: 54rem) {
  .meal-page--entries .meal-page__header > .ui-button {
    display: none !important;
  }

  .meal-page--entries {
    padding-bottom: calc(5.8rem + 3.6rem + env(safe-area-inset-bottom));
  }

  .meal-fab {
    display: inline-flex !important;
    bottom: calc(3.6rem + 1rem + env(safe-area-inset-bottom));
  }

}

.meal-day-group {
  display: grid;
  gap: 0.6rem;
  animation: day-group-in 260ms ease both;
}

.meal-day-group__title {
  margin: 0;
  padding-inline: 0.2rem;
  color: color-mix(in oklab, var(--text-secondary) 78%, var(--text-primary) 22%);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.meal-load-more {
  margin-top: 1rem;
  padding: 0.75rem 0 0.25rem;
  display: grid;
  justify-items: center;
  gap: 0.65rem;
}

.meal-load-more .ui-loader {
  color: var(--text-secondary);
}

.meal-load-more__link {
  font-size: 0.88rem;
  color: var(--text-secondary);
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, var(--text-secondary) 60%, transparent);
  text-underline-offset: 0.2em;
  opacity: 0.85;
}

.meal-load-more__link:hover {
  color: var(--text-primary);
  text-decoration-color: color-mix(in oklab, var(--text-primary) 70%, transparent);
  opacity: 1;
}

.meal-card {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border);
  border-radius: 1.15rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
  animation: meal-card-in 240ms ease both;
}

@media (hover: hover) and (pointer: fine) {
  .meal-card:hover {
    transform: translateY(-2px);
    border-color: color-mix(in oklab, var(--surface-border) 62%, var(--brand) 38%);
    box-shadow:
      0 8px 24px color-mix(in oklab, var(--text-primary) 8%, transparent),
      0 2px 8px color-mix(in oklab, var(--text-primary) 5%, transparent);
  }

  .meal-card.report-adherence:hover {
    transform: none;
  }
}

.meal-card--media {
  padding: 0.52rem;
  background: color-mix(in oklab, var(--bg-elevated) 88%, white 12%);
}

.meal-card--media .card-menu {
  top: 0.34rem;
  right: 0.34rem;
}

.card-menu {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  /* Must stay above analysis reanalysis overlay (glass layer). */
  z-index: 30;
}

.card-menu__trigger {
  list-style: none;
  width: var(--tap-target-min);
  height: var(--tap-target-min);
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--surface-border) 70%, transparent);
  background: color-mix(in oklab, var(--bg-elevated) 76%, transparent);
  color: color-mix(in oklab, var(--text-primary) 86%, var(--brand) 14%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.card-menu__trigger::-webkit-details-marker {
  display: none;
}

.card-menu__trigger svg {
  width: 1.35rem;
  height: 1.35rem;
}

.card-menu__trigger:hover {
  background: color-mix(in oklab, var(--bg-elevated) 66%, var(--brand) 10%);
  border-color: color-mix(in oklab, var(--surface-border) 55%, var(--brand) 45%);
  transform: translateY(-1px);
}

.card-menu__trigger:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.card-menu[open] .card-menu__trigger {
  transform: rotate(90deg);
}

.card-menu__panel {
  position: absolute;
  top: 2.9rem;
  right: 0;
  min-width: 12.5rem;
  padding: 0.35rem;
  border-radius: 0.9rem;
  border: 1px solid color-mix(in oklab, var(--surface-border) 70%, transparent);
  background: color-mix(in oklab, var(--bg-elevated) 92%, var(--bg) 8%);
  box-shadow: 0 18px 44px rgba(8, 12, 22, 0.28);
  transform-origin: top right;
  animation: menu-pop 160ms ease both;
}

.card-menu__form {
  margin: 0;
}

.card-menu__item {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  padding: 0.55rem 0.6rem;
  border-radius: 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  transition: background-color 120ms ease, transform 120ms ease;
}

.card-menu__item svg {
  width: 1.05rem;
  height: 1.05rem;
  opacity: 0.9;
}

.card-menu__item:hover {
  background: color-mix(in oklab, var(--bg) 78%, var(--brand) 22%);
  transform: translateX(-1px);
}

.card-menu__item:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.card-menu__item--danger {
  color: color-mix(in oklab, #ef4444 80%, var(--text-primary));
}

.card-menu__item--danger:hover {
  background: color-mix(in oklab, var(--bg) 78%, #ef4444 22%);
}

@keyframes menu-pop {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes app-shell-enter {
  from {
    opacity: 0;
    transform: scale(0.99);
    filter: blur(0.3px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: blur(0);
  }
}

/* --- Meal Gallery Grid (1+2 layout) --- */

.meal-gallery {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: var(--space-1);
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border-radius: var(--radius-md);
  /* Safari clip fix */
  -webkit-mask-image: -webkit-radial-gradient(white, black);
  transform: translateZ(0);
}

/* Healthiness glow — pseudo-element overlay so it renders on top of photos */
.meal-card--media[style*="--meal-glow"] .meal-gallery {
  position: relative;
}

.meal-card--media[style*="--meal-glow"] .meal-gallery::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 10px 2px var(--meal-glow);
  opacity: 0.7;
  pointer-events: none;
  z-index: 1;
}

@media (prefers-reduced-motion: no-preference) {
  .meal-card--media[style*="--meal-glow"] .meal-gallery::after {
    animation: meal-glow-pulse 3s ease-in-out infinite;
  }
}

@keyframes meal-glow-pulse {
  0%, 100% { box-shadow: inset 0 0 10px 2px var(--meal-glow); }
  50%      { box-shadow: inset 0 0 14px 3px var(--meal-glow); }
}

.meal-gallery__cell {
  overflow: hidden;
  min-height: 0;
}

.meal-gallery__cell:first-child {
  grid-row: 1 / 3;
}

.meal-gallery__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}

/* Single photo: full width, no grid columns */
.meal-gallery--single {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

.meal-gallery--single .meal-gallery__cell:first-child {
  grid-row: auto;
}

/* Pair: two photos side by side, right one full height */
.meal-gallery--pair {
  grid-template-rows: 1fr;
}

.meal-gallery--pair .meal-gallery__cell:first-child {
  grid-row: auto;
}

.img-skeleton {
  /* Avoid `color-mix()` so the skeleton works in older Safari versions too. */
  background: linear-gradient(110deg, var(--bg-muted) 0%, var(--bg-elevated) 35%, var(--bg-muted) 70%);
  background-size: 220% 100%;
}

.img-skeleton.is-loading {
  animation: skeleton-shimmer 1200ms ease-in-out infinite;
}

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

@keyframes fab-pulse {
  0%, 100% {
    box-shadow:
      0 14px 30px color-mix(in oklab, var(--brand) 32%, transparent),
      0 0 18px color-mix(in oklab, var(--brand) 18%, transparent),
      0 0 0 1px color-mix(in oklab, var(--brand) 65%, transparent) inset,
      0 0 10px color-mix(in oklab, white 12%, transparent) inset;
  }
  50% {
    box-shadow:
      0 16px 36px color-mix(in oklab, var(--brand) 42%, transparent),
      0 0 24px color-mix(in oklab, var(--brand) 28%, transparent),
      0 0 0 1px color-mix(in oklab, var(--brand) 75%, transparent) inset,
      0 0 14px color-mix(in oklab, white 18%, transparent) inset;
  }
}



.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  animation: lightbox-in 200ms ease;
  overscroll-behavior: none;
  touch-action: none;
}

.lightbox__img {
  max-width: 94vw;
  max-height: 94vh;
  object-fit: contain;
  border-radius: 0.5rem;
}

.lightbox__close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  display: inline-grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 101;
}

.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  min-width: 2.75rem;
  min-height: 2.75rem;
  display: inline-grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.45);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  z-index: 101;
  transition: background 120ms ease;
}

.lightbox__nav:hover {
  background: rgba(0, 0, 0, 0.7);
}

.lightbox__nav--prev {
  left: 0.75rem;
}

.lightbox__nav--next {
  right: 0.75rem;
}

.lightbox__close:focus-visible,
.lightbox__nav:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 2px;
}

@keyframes lightbox-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.meal-card__body {
  padding: 0.85rem 0.6rem 1rem;
}

.meal-card--media .meal-card__body {
  padding: 0.62rem 0.08rem 0.22rem;
}

.meal-card__title {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.meal-card--editor {
  width: 100%;
  max-width: 54rem;
  margin-inline: auto;
  position: relative;
  padding: 1rem;
  border-radius: 1.3rem;
  border-color: color-mix(in oklab, var(--surface-border) 60%, var(--brand) 40%);
  background: linear-gradient(
    158deg,
    color-mix(in oklab, var(--brand-soft) 26%, var(--bg-elevated)) 0%,
    var(--bg-elevated) 38%
  );
  box-shadow: 0 18px 52px rgba(8, 12, 22, 0.28);
}

.meal-card--editor::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    130deg,
    color-mix(in oklab, var(--brand) 80%, white),
    color-mix(in oklab, var(--brand-strong) 75%, white),
    color-mix(in oklab, var(--brand) 58%, transparent)
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.meal-card--editor .meal-card__title {
  margin-bottom: 0.72rem;
  font-size: clamp(1.35rem, 2.45vw, 1.68rem);
  line-height: 1.1;
}

.meal-card--editor .flash {
  /* now position: fixed overlay — no margin override needed */
}

.meal-entry__meta {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
}

.meal-entry__note {
  margin: 0.34rem 0 0;
  color: color-mix(in oklab, var(--text-primary) 90%, var(--text-secondary) 10%);
  line-height: 1.45;
}

.meal-card--media .meal-entry__note {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.meal-card--media .meal-entry__note--full {
  display: block;
  -webkit-line-clamp: unset;
  -webkit-box-orient: unset;
  overflow: visible;
}

.meal-entry__actions {
  margin-top: 0.6rem;
}

.meal-form {
  display: grid;
  gap: 0.68rem;
  min-width: 0;
}

.meal-form__field {
  display: grid;
  gap: 0.34rem;
  min-width: 0;
}

.meal-form__field--error .meal-form__input {
  border-color: var(--color-error, #ef4444);
}

.meal-form__error {
  margin: 0;
  font-size: 0.82rem;
  color: var(--color-error, #ef4444);
}

.meal-form__label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* Chip group & chips (preset selectors). */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-full);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 0.88rem;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
  user-select: none;
}

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

.chip--active {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--text-inverse);
  animation: chip-select 200ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes chip-select {
  0% { transform: scale(0.94); }
  60% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

.chip--active:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  color: var(--text-inverse);
}

/* Tag picker (allergens, etc.) */
.tag-picker {
  position: relative;
}

.tag-picker__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
}

.tag-picker__tags:empty {
  margin-bottom: 0;
}

.tag-picker__tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-full);
  background: color-mix(in oklab, var(--brand) 14%, var(--bg-elevated));
  color: var(--text-primary);
  font-size: 0.84rem;
  line-height: 1.3;
}

.tag-picker__tag-remove {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 120ms ease;
}

.tag-picker__tag-remove:hover {
  opacity: 1;
  color: var(--color-error);
}

.tag-picker__input {
  min-height: 2.5rem;
}

.tag-picker__input-row {
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
}

.tag-picker__input-row .tag-picker__input {
  flex: 1;
  min-width: 0;
}

.tag-picker__add-btn {
  flex-shrink: 0;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--brand);
  background: color-mix(in oklab, var(--brand) 10%, var(--bg-elevated));
  color: var(--brand);
  border-radius: 0.9rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 120ms ease, color 120ms ease;
}

.tag-picker__add-btn:hover {
  background: color-mix(in oklab, var(--brand) 18%, var(--bg-elevated));
}

.tag-picker__add-btn:active {
  background: color-mix(in oklab, var(--brand) 26%, var(--bg-elevated));
}

.tag-picker__add-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.tag-picker__dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 20;
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-sm);
  padding: 0.3rem;
  margin-top: 0.2rem;
}

.tag-picker__option {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 0.45rem 0.65rem;
  border-radius: 0.5rem;
  color: var(--text-primary);
  font-size: 0.88rem;
  cursor: pointer;
  transition: background-color 100ms ease;
}

.tag-picker__option:hover {
  background: color-mix(in oklab, var(--brand) 10%, var(--bg-elevated));
}

.meal-form__input {
  width: 100%;
  border: 1px solid var(--surface-border);
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  color: var(--text-primary);
  border-radius: 0.9rem;
  padding: 0.72rem 0.85rem;
  min-height: 3rem;
  font: inherit;
  transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.meal-form__input::placeholder {
  color: color-mix(in oklab, var(--text-secondary) 78%, transparent);
}

.meal-form__input:focus-visible {
  outline: none;
  border-color: var(--brand);
  background: var(--bg);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand) 20%, transparent);
}

.meal-form textarea.meal-form__input {
  min-height: 4.5rem;
  resize: vertical;
}

.meal-form__upload {
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
  width: auto;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  transition: none;
  overflow: visible;
}

.meal-form__upload:focus-within {
  box-shadow: none;
}

.meal-form__upload-trigger {
  flex: 0 0 auto;
  width: 1.95rem;
  height: 1.95rem;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--surface-border) 45%, var(--brand) 55%);
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: var(--text-inverse);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
  box-shadow: none;
}

.meal-form__upload-trigger:hover {
  transform: translateY(-1px);
  filter: saturate(1.06);
}

.meal-form__upload-trigger:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.meal-form__upload-trigger-plus {
  display: inline-block;
  font-size: 1.16rem;
  font-weight: 700;
  line-height: 1;
  transform: translateY(-1px);
}

.meal-form__upload-summary {
  flex: 0 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.95rem;
  max-width: min(11rem, 100%);
  min-width: 0;
  padding: 0 0.62rem;
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid color-mix(in oklab, var(--surface-border) 70%, transparent);
  border-radius: 999px;
  background: color-mix(in oklab, var(--bg) 90%, transparent);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meal-form__upload-summary--uploading {
  color: var(--text-primary);
}

.meal-form__upload-summary--error {
  color: #ef4444;
  border-color: color-mix(in oklab, #ef4444 55%, var(--surface-border) 45%);
  background: color-mix(in oklab, #ef4444 12%, var(--bg) 88%);
}

.meal-form__upload-summary--hidden {
  display: none;
}

.meal-form__preview-grid {
  margin-top: 0.05rem;
  display: none;
}

.meal-form__preview-grid--active {
  display: grid;
  gap: var(--space-1);
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 3 / 2;
  /* Safari clip fix */
  -webkit-mask-image: -webkit-radial-gradient(white, black);
  transform: translateZ(0);
}

.meal-form__preview-grid--single {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

.meal-form__preview-grid--pair {
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr;
}

.meal-form__preview-grid--triple {
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.meal-form__preview-grid--triple .meal-form__preview-item:first-child {
  grid-row: 1 / 3;
}

.meal-form__preview-item {
  margin: 0;
  position: relative;
  overflow: hidden;
  min-height: 0;
  min-width: 0;
  background: var(--bg-muted);
  animation: meal-preview-in 220ms ease both;
  cursor: default;
}

.meal-form__preview-grid--reorderable .meal-form__preview-item {
  cursor: grab;
  animation: meal-preview-jiggle 210ms ease-in-out infinite alternate;
  transform-origin: 50% 50%;
  will-change: transform;
}

.meal-form__preview-grid--reorderable .meal-form__preview-item:nth-child(even) {
  animation-delay: -105ms;
}

.meal-form__preview-grid--reorderable .meal-form__preview-item:active {
  cursor: grabbing;
}

.meal-form__preview-item--dragging {
  animation: none !important;
  transform: scale(1.06) rotate(-1.5deg);
  box-shadow: 0 8px 20px color-mix(in oklab, black 32%, transparent), 0 2px 8px color-mix(in oklab, black 20%, transparent);
  z-index: 10;
  opacity: 1;
  cursor: grabbing;
  transition: transform 140ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 140ms ease;
}

.meal-form__preview-item--pointer-dragging {
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 16px 40px color-mix(in oklab, black 38%, transparent), 0 4px 12px color-mix(in oklab, black 24%, transparent);
  transition: box-shadow 100ms ease;
}

.meal-form__preview-item--drop-target {
  outline: 2px solid color-mix(in oklab, var(--brand) 72%, transparent);
  outline-offset: -2px;
  background: color-mix(in oklab, var(--brand) 10%, var(--bg-muted) 90%);
  transition: outline 80ms ease, background 80ms ease;
}

.meal-form__preview-item--settling {
  animation: preview-settle 280ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.meal-form__preview-grid--reorderable .meal-form__preview-item:not(.meal-form__preview-item--dragging) {
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

.meal-form__preview-item--main {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--brand) 45%, transparent);
}

/* Smaller edit/remove buttons in triple layout's right column */
.meal-form__preview-grid--triple .meal-form__preview-item:not(:first-child) .meal-form__preview-edit {
  width: 1.35rem;
  height: 1.35rem;
}

.meal-form__preview-grid--triple .meal-form__preview-item:not(:first-child) .meal-form__preview-edit svg {
  width: 0.9rem;
  height: 0.9rem;
}

.meal-form__preview-grid--triple .meal-form__preview-item:not(:first-child) .meal-form__preview-remove {
  width: 1.3rem;
  height: 1.3rem;
}

.meal-form__preview-grid--triple .meal-form__preview-item:not(:first-child) .meal-form__preview-remove svg {
  width: 0.9rem;
  height: 0.9rem;
}

.meal-form__preview-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.meal-form__preview-main-badge {
  position: absolute;
  right: 0.42rem;
  top: 0.42rem;
  width: 1.45rem;
  height: 1.45rem;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  border-radius: 999px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  background: rgba(8, 12, 22, 0.56);
  color: #a8b0be;
  box-shadow: 0 2px 6px rgba(8, 12, 22, 0.28);
  pointer-events: none;
}

.meal-form__preview-edit {
  position: absolute;
  left: 0.24rem;
  bottom: 0.24rem;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--brand) 28%, var(--surface-border) 72%);
  background: color-mix(in oklab, var(--brand) 18%, var(--bg-elevated) 82%);
  color: color-mix(in oklab, var(--text-secondary) 70%, var(--brand) 30%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, transform 120ms ease;
}

.meal-form__preview-edit::before {
  content: "";
  position: absolute;
  inset: -0.5rem;
  border-radius: 999px;
}

.meal-form__preview-edit svg {
  width: 1.1rem;
  height: 1.1rem;
}

.meal-form__preview-edit:hover {
  transform: translateY(-1px);
  color: var(--text-primary);
  background: color-mix(in oklab, var(--bg-elevated) 56%, var(--brand) 44%);
}

.meal-form__preview-edit:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.meal-form__preview-remove {
  position: absolute;
  left: 0.24rem;
  top: 0.24rem;
  width: 1.52rem;
  height: 1.52rem;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--surface-border) 68%, transparent);
  background: color-mix(in oklab, var(--bg-elevated) 74%, black 26%);
  color: color-mix(in oklab, var(--text-secondary) 82%, white 18%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, transform 120ms ease;
}

.meal-form__preview-remove svg {
  width: 0.9rem;
  height: 0.9rem;
}

.meal-form__preview-remove:hover {
  transform: translateY(-1px);
  background: color-mix(in oklab, #ef4444 24%, var(--bg-elevated) 76%);
  color: color-mix(in oklab, #ef4444 86%, white 14%);
}

.meal-form__preview-remove:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.meal-form__preview-help {
  margin: 0.05rem 0 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  display: none;
}

.meal-form__preview-grid--reorderable + .meal-form__preview-help {
  display: block;
}

.meal-form__file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.meal-form__cropper-open {
  overflow: hidden;
}

.meal-form__cropper {
  position: fixed;
  inset: 0;
  z-index: 150;
  padding: clamp(0.35rem, 1.8vh, 0.7rem);
  display: grid;
  place-items: center;
}

.meal-form__cropper[hidden] {
  display: none;
}

.meal-form__cropper-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: color-mix(in oklab, var(--bg) 18%, black);
  backdrop-filter: blur(2px);
  cursor: default;
}

.meal-form__cropper-dialog {
  position: relative;
  width: min(38rem, 100%);
  height: 100%;
  max-height: var(--cropper-dialog-max-height, 100%);
  border-radius: 1rem;
  border: 1px solid color-mix(in oklab, var(--surface-border) 68%, transparent);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: clamp(0.58rem, 1.8vh, 0.86rem);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: 0 18px 44px color-mix(in oklab, black 35%, transparent);
  overflow: hidden;
}

.meal-form__cropper-header {
  display: grid;
  gap: 0.12rem;
}

.meal-form__cropper-step {
  margin: 0;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.meal-form__cropper-title {
  margin: 0;
  font-size: clamp(0.94rem, 1.3vw, 1rem);
  letter-spacing: -0.01em;
}

.meal-form__cropper-hint {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--text-secondary);
}

.meal-form__cropper-stage {
  flex: 1 1 auto;
  min-height: 11rem;
  max-height: none;
  display: grid;
  place-items: center;
  border-radius: 0.92rem;
  border: 1px solid color-mix(in oklab, var(--surface-border) 65%, transparent);
  background: color-mix(in oklab, var(--bg) 74%, black 26%);
  padding: 0.28rem;
  overflow: hidden;
}

.meal-form__cropper-viewport {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  border-radius: 0.82rem;
  overflow: hidden;
  border: 1px solid color-mix(in oklab, var(--surface-border) 70%, transparent);
  background:
    linear-gradient(45deg, color-mix(in oklab, var(--surface-border) 34%, transparent) 25%, transparent 25%),
    linear-gradient(-45deg, color-mix(in oklab, var(--surface-border) 34%, transparent) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, color-mix(in oklab, var(--surface-border) 34%, transparent) 75%),
    linear-gradient(-45deg, transparent 75%, color-mix(in oklab, var(--surface-border) 34%, transparent) 75%),
    color-mix(in oklab, var(--bg) 88%, transparent);
  background-size: 0.85rem 0.85rem;
  background-position: 0 0, 0 0.5rem, 0.5rem -0.5rem, -0.5rem 0;
  cursor: default;
  touch-action: none;
}

.meal-form__cropper-image {
  display: block;
  max-width: 100%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
}

.meal-form__crop-box {
  position: absolute;
  border: 2px solid color-mix(in oklab, white 82%, var(--brand) 18%);
  border-radius: 0.35rem;
  box-shadow: 0 0 0 999vmax color-mix(in oklab, black 52%, transparent);
  cursor: move;
  min-width: 3rem;
  min-height: 3rem;
}

.meal-form__crop-box[hidden] {
  display: none;
}

.meal-form__crop-box::before,
.meal-form__crop-box::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.meal-form__crop-box::before {
  border-left: 1px dashed color-mix(in oklab, white 50%, transparent);
  border-right: 1px dashed color-mix(in oklab, white 50%, transparent);
  left: 33.33%;
  right: 33.33%;
}

.meal-form__crop-box::after {
  border-top: 1px dashed color-mix(in oklab, white 50%, transparent);
  border-bottom: 1px dashed color-mix(in oklab, white 50%, transparent);
  top: 33.33%;
  bottom: 33.33%;
}

.meal-form__crop-handle {
  position: absolute;
  width: 1.65rem;
  height: 1.65rem;
  background: transparent;
  touch-action: none;
}

.meal-form__crop-handle--nw {
  left: -0.34rem;
  top: -0.34rem;
  border-left: 6px solid white;
  border-top: 6px solid white;
  cursor: nwse-resize;
}

.meal-form__crop-handle--ne {
  right: -0.34rem;
  top: -0.34rem;
  border-right: 6px solid white;
  border-top: 6px solid white;
  cursor: nesw-resize;
}

.meal-form__crop-handle--sw {
  left: -0.34rem;
  bottom: -0.34rem;
  border-left: 6px solid white;
  border-bottom: 6px solid white;
  cursor: nesw-resize;
}

.meal-form__crop-handle--se {
  right: -0.34rem;
  bottom: -0.34rem;
  border-right: 6px solid white;
  border-bottom: 6px solid white;
  cursor: nwse-resize;
}

.meal-form__cropper-actions {
  display: grid;
  gap: 0.34rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  flex: 0 0 auto;
  margin-top: auto;
  padding-top: 0.28rem;
  padding-bottom: max(0.28rem, env(safe-area-inset-bottom, 0px));
}

.meal-form__cropper-btn {
  min-height: 2.42rem;
  border-radius: 0.72rem;
  border: 1px solid color-mix(in oklab, var(--surface-border) 78%, transparent);
  background: color-mix(in oklab, var(--bg) 90%, transparent);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.93rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  padding: 0.34rem 0.55rem;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.meal-form__cropper-btn--icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.meal-form__cropper-btn--icon svg {
  width: 0.95rem;
  height: 0.95rem;
}

.meal-form__cropper-btn:hover {
  transform: translateY(-1px);
  background: color-mix(in oklab, var(--bg) 74%, var(--brand) 26%);
}

.meal-form__cropper-btn:disabled {
  opacity: 0.62;
  cursor: progress;
  transform: none;
}

.meal-form__cropper-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.meal-form__cropper-btn--primary {
  grid-column: 1 / -1;
  border-color: color-mix(in oklab, var(--brand) 72%, var(--brand-strong) 28%);
  background: linear-gradient(95deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: var(--text-inverse);
}

.meal-form__cropper-btn[data-file-picker-target="cropSkipAllButton"] {
  grid-column: 1 / -1;
}

.meal-form__cropper-btn--primary:hover {
  background: linear-gradient(
    95deg,
    color-mix(in oklab, var(--brand) 82%, white),
    color-mix(in oklab, var(--brand-strong) 88%, white)
  );
}

.meal-card--editor .meal-form__actions {
  margin-top: 0.15rem;
}

.meal-card--editor .meal-form__actions .ui-button {
  min-height: 3.15rem;
  font-size: 1.02rem;
  border: 0;
  color: var(--text-inverse);
  background: linear-gradient(95deg, var(--brand) 0%, var(--brand-strong) 100%);
  box-shadow: 0 10px 24px color-mix(in oklab, var(--brand) 36%, transparent);
}

.meal-card--editor .meal-form__actions .ui-button:hover {
  background: linear-gradient(
    95deg,
    color-mix(in oklab, var(--brand) 80%, white),
    color-mix(in oklab, var(--brand-strong) 88%, white)
  );
}

.meal-form--uploading .meal-form__upload-trigger {
  opacity: 0.65;
}

.meal-form--uploading .meal-form__actions .ui-button {
  opacity: 1;
}

.meal-form--uploading .meal-form__actions .ui-button:disabled {
  background: linear-gradient(
    95deg,
    color-mix(in oklab, var(--surface-border) 70%, var(--bg-elevated) 30%),
    color-mix(in oklab, var(--surface-border) 84%, var(--bg-elevated) 16%)
  );
  color: color-mix(in oklab, var(--text-secondary) 82%, white 18%);
  box-shadow: none;
  border: 1px solid color-mix(in oklab, var(--surface-border) 88%, transparent);
  cursor: not-allowed;
  transform: none;
}

.meal-form--uploading .meal-form__actions .ui-button:disabled:hover {
  background: linear-gradient(
    95deg,
    color-mix(in oklab, var(--surface-border) 70%, var(--bg-elevated) 30%),
    color-mix(in oklab, var(--surface-border) 84%, var(--bg-elevated) 16%)
  );
}

.meal-form__actions .ui-button {
  width: 100%;
}

.profile-sign-out {
  margin-top: 1.5rem;
  text-align: center;
}

/* Onboarding mode: hide nav chrome so user completes the wizard */
.onboarding-mode .navbar,
.onboarding-mode .tabbar {
  display: none !important;
}

.onboarding-mode .app-shell--has-tabbar {
  padding-bottom: 0;
}

.onboarding-header {
  text-align: center;
  margin-bottom: 1rem;
}

.onboarding-header__step {
  margin: 0 0 0.25rem;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand);
}

.profile-settings {
  margin-top: 1.5rem;
}

.profile-settings__title {
  margin: 0 0 1rem;
  font-size: 1rem;
}

.profile-settings__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
}

.profile-settings__row + .profile-settings__row {
  border-top: 1px solid var(--surface-border);
}

.profile-settings__row--nested {
  padding-left: 1.25rem;
  border-left: 2px solid var(--surface-border);
}

.profile-settings__label {
  font-size: 0.93rem;
  color: var(--text-primary);
}

.profile-settings__theme {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.profile-settings__theme-name {
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.navbar__locales--profile {
  gap: 0.25rem;
}

/* ---- UI Toggle (pill switch) ---- */
.ui-toggle {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

.ui-toggle__input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0, 0, 0, 0);
  overflow: hidden;
}

.ui-toggle__track {
  display: block;
  width: 2.5rem;
  height: 1.375rem;
  border-radius: 999px;
  background: var(--bg-muted, #ccc);
  transition: background 0.2s ease;
  position: relative;
}

.ui-toggle__thumb {
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  width: 1.075rem;
  height: 1.075rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease;
}

.ui-toggle__input:checked + .ui-toggle__track {
  background: var(--brand);
}

.ui-toggle__input:checked + .ui-toggle__track .ui-toggle__thumb {
  transform: translateX(1.125rem);
}

.ui-toggle__input:focus-visible + .ui-toggle__track {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.profile-settings__hint {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin: 0.15rem 0 0;
  line-height: 1.3;
}

.profile-settings__row > form {
  width: 100%;
}

.profile-settings__toggle-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.profile-settings__toggle-text {
  flex: 1;
  min-width: 0;
}

.profile-actions {
  margin-top: 1.5rem;
}

.profile-actions__title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.profile-actions__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
}

.profile-actions__danger-zone {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--surface-border);
}

.profile-actions__danger-hint {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin: 0 0 var(--space-4);
  line-height: 1.4;
}

/* Full-width delete button on mobile; auto-size on desktop. */
.profile-actions__danger-zone .ui-button {
  width: 100%;
}

@media (min-width: 40rem) {
  .profile-actions__danger-zone .ui-button {
    width: auto;
  }
}

@media (max-width: 40rem) {
  .meal-form__cropper {
    padding: 0.35rem;
  }

  .meal-form__cropper-dialog {
    width: 100%;
    height: 100%;
    max-height: var(--cropper-dialog-max-height, 100%);
    border-radius: 0.9rem;
    padding: 0.58rem;
    gap: 0.42rem;
  }

  .meal-form__cropper-header {
    gap: 0.08rem;
  }

  .meal-form__cropper-step {
    font-size: 0.64rem;
  }

  .meal-form__cropper-title {
    font-size: 0.92rem;
  }

  .meal-form__cropper-hint {
    display: none;
  }

  .meal-form__cropper-stage {
    min-height: 10rem;
    max-height: none;
    padding: 0.2rem;
  }

  .meal-form__cropper-btn {
    min-height: 2.48rem;
    font-size: 0.88rem;
  }

  .meal-form__crop-handle {
    width: 1.78rem;
    height: 1.78rem;
  }

  .meal-card--editor {
    padding: 0.95rem;
    border-radius: 1.15rem;
  }
}

@keyframes meal-preview-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes meal-preview-jiggle {
  from {
    transform: translateY(-0.35px) rotate(-1.25deg);
  }
  to {
    transform: translateY(0.35px) rotate(1.25deg);
  }
}

@keyframes preview-settle {
  from {
    transform: scale(1.04) rotate(-0.8deg);
    box-shadow: 0 10px 28px color-mix(in oklab, black 28%, transparent);
  }
  to {
    transform: scale(1) rotate(0deg);
    box-shadow: none;
  }
}

@keyframes day-group-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes meal-card-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.995);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hero {
  padding: 3.5rem 0 2.2rem;
}

.hero__inner {
  max-width: 48rem;
  animation: reveal-up 360ms ease both;
}

.hero__eyebrow,
.feature-card__eyebrow,
.report-preview__eyebrow {
  margin: 0;
  color: var(--brand);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.hero__title {
  margin: 0.75rem 0 0;
  font-size: clamp(2rem, 6vw, 3.3rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.hero__description {
  margin: 1rem 0 0;
  color: var(--text-secondary);
  max-width: 42rem;
}

.hero__actions {
  margin-top: 1.35rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.section {
  padding: 2rem 0;
  animation: reveal-up 420ms ease both;
}

.section:nth-of-type(2) {
  animation-delay: 70ms;
}

.section:nth-of-type(3) {
  animation-delay: 110ms;
}

.section:nth-of-type(4) {
  animation-delay: 150ms;
}

.section--muted {
  background: color-mix(in oklab, var(--bg-muted) 62%, transparent);
  border-top: 1px solid var(--surface-border);
  border-bottom: 1px solid var(--surface-border);
}

.section__title {
  margin: 0;
  font-size: clamp(1.45rem, 4.2vw, 2rem);
  letter-spacing: -0.02em;
}

.section__title--with-badge {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.feature-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

.feature-card {
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border);
  border-radius: 1rem;
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}

.feature-card__title {
  margin: 0.25rem 0 0;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.feature-card__description {
  margin: 0.5rem 0 0;
  color: var(--text-secondary);
}

.step-list {
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.8rem;
}

.step-list__item {
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border);
  border-radius: 0.85rem;
  padding: 0.9rem;
}

.step-list__title {
  margin: 0;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.step-list__text {
  margin: 0.3rem 0 0;
  color: var(--text-secondary);
}

.report-preview {
  display: grid;
  gap: 1rem;
  align-items: end;
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border);
  border-radius: 1rem;
  padding: 1rem;
}

.report-preview__text {
  margin: 0.55rem 0 0;
  color: var(--text-secondary);
}

@media (min-width: 40rem) {
  .navbar__inner {
    gap: 1rem;
  }

  .feature-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .step-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .report-preview {
    grid-template-columns: 1fr auto;
    padding: 1.4rem;
  }

  .meal-page__container {
    max-width: 36rem;
    margin-inline: auto;
  }

  .auth-page {
    padding: 3.2rem 0;
  }

  .auth-card {
    padding: 1.4rem;
  }
}

@media (min-width: 64rem) {
  .hero {
    padding-top: 4.6rem;
  }

  .feature-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .section {
    padding: 2.6rem 0;
  }
}

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

  /* Keep drag affordance visible for multi-photo reordering in create-entry form. */
  .meal-form__preview-grid--reorderable .meal-form__preview-item {
    animation: meal-preview-jiggle 210ms ease-in-out infinite alternate !important;
  }

  .meal-form__preview-grid--reorderable .meal-form__preview-item:nth-child(even) {
    animation-delay: -105ms !important;
  }

  /* Disable drag/settle animations in reduced-motion mode */
  .meal-form__preview-item--dragging {
    transform: none !important;
    box-shadow: 0 4px 12px color-mix(in oklab, black 20%, transparent) !important;
    transition: none !important;
  }

  .meal-form__preview-item--settling {
    animation: none !important;
  }

  .empty-state__icon {
    animation: none !important;
  }
}

.telegram-remove {
  opacity: 0;
  transform: translateX(18px) scale(0.98);
  filter: blur(0.25px);
  transition: opacity 180ms ease, transform 180ms ease, filter 180ms ease;
}

.turbo-replace-out {
  opacity: 0;
  transform: translateY(8px) scale(0.985);
  filter: blur(0.25px);
  transition: opacity 180ms ease, transform 180ms ease, filter 180ms ease;
}

.analysis-overlay.telegram-remove {
  transform: translateY(10px) scale(0.98);
  pointer-events: none;
}

.meal-analysis__list {
  display: flex;
  gap: 0.8rem;
  overflow-x: auto;
  padding-bottom: 0.4rem;
  scroll-snap-type: x mandatory;
}

.meal-analysis__item {
  min-width: 16.5rem;
  scroll-snap-align: start;
  flex: 0 0 auto;
  transition: transform 180ms ease, opacity 180ms ease;
}

.meal-analysis__stack {
  position: relative;
  display: grid;
}

.meal-analysis__stack > .meal-analysis__item {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
}

.meal-analysis__item--baseline {
  transition: filter 220ms ease, opacity 220ms ease, transform 220ms ease;
}

.meal-analysis__stack--overlay-open .meal-analysis__item--baseline {
  filter: blur(3px) saturate(0.92);
  opacity: 0.68;
  transform: scale(0.995);
}

.analysis-overlay {
  position: relative;
  z-index: 3;
  opacity: 0;
  transform: translateY(10px) scale(0.985);
  transition: opacity 220ms ease, transform 220ms ease;
}

.analysis-overlay--shown {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.analysis-overlay__panel {
  border-radius: 1.25rem;
  padding: 0.65rem;
  border: 1px solid color-mix(in oklab, var(--surface-border) 62%, transparent);
  background: linear-gradient(
    150deg,
    color-mix(in oklab, var(--bg-elevated) 52%, transparent) 0%,
    color-mix(in oklab, var(--bg) 46%, transparent) 55%,
    color-mix(in oklab, var(--bg-elevated) 54%, transparent) 100%
  );
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  backdrop-filter: blur(14px) saturate(1.15);
  box-shadow: 0 22px 58px rgba(8, 12, 22, 0.35);
}

.analysis-overlay__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.analysis-overlay__title {
  font-size: 0.82rem;
  font-weight: 680;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: color-mix(in oklab, var(--text-secondary) 78%, var(--brand) 22%);
}

.analysis-overlay__actions {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  flex: 0 0 auto;
}

.analysis-overlay__action {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.82rem;
  border: 1px solid color-mix(in oklab, var(--surface-border) 62%, transparent);
  background: color-mix(in oklab, var(--bg-elevated) 75%, transparent);
  color: color-mix(in oklab, var(--text-primary) 82%, var(--brand) 18%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease, background-color 120ms ease, opacity 120ms ease;
}

.analysis-overlay__action svg {
  width: 1.1rem;
  height: 1.1rem;
}

.analysis-overlay__action:hover {
  transform: translateY(-1px);
  filter: saturate(1.05);
}

.analysis-overlay__action:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}

.analysis-overlay__action[disabled] {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.analysis-overlay--ready .analysis-overlay__action--ok {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: var(--text-inverse);
  border-color: color-mix(in oklab, var(--brand) 78%, var(--surface-border) 22%);
  box-shadow: 0 12px 26px color-mix(in oklab, var(--brand) 32%, transparent);
}

.analysis-overlay__action--cancel {
  color: color-mix(in oklab, var(--text-secondary) 82%, transparent);
}

.analysis-overlay .analysis-result-card {
  background: color-mix(in oklab, var(--bg-elevated) 40%, transparent);
  box-shadow: 0 10px 22px rgba(8, 12, 22, 0.12);
}

.analysis-body--enter {
  animation: analysis-body-in 240ms ease both;
}

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

/* When there's only one analysis card, it should fill the available width instead of
   sitting as a small "carousel" item. */
.meal-analysis__list > .meal-analysis__item:only-child {
  flex: 1 1 auto;
  min-width: 0;
}

.meal-analysis__cta {
  margin-top: 0.55rem;
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.meal-analysis__pending {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.8rem 0.2rem;
}

.meal-analysis__timeout[hidden] {
  display: none;
}

.meal-analysis__timeout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
}

.meal-analysis__timeout-text {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.meal-analysis__offline-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  border-radius: 0.65rem;
  background: color-mix(in oklab, var(--color-warning) 12%, var(--bg-elevated));
  color: color-mix(in oklab, var(--color-warning) 85%, var(--text-primary));
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.3;
}

.meal-analysis__offline-badge[hidden] {
  display: none;
}

.meal-analysis__offline-icon {
  flex-shrink: 0;
  opacity: 0.85;
}

.analysis-dev-provider {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.55rem;
  padding: 0.2rem 0.48rem;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--surface-border) 60%, transparent);
  background: color-mix(in oklab, var(--bg-muted) 72%, var(--bg-elevated) 28%);
  color: color-mix(in oklab, var(--text-secondary) 78%, var(--text-primary) 22%);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.analysis-dev-provider__icon {
  width: 0.82rem;
  height: 0.82rem;
  flex: 0 0 auto;
}

.analysis-dev-provider__label {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.analysis-dev-provider--gigachat {
  color: color-mix(in oklab, #0f766e 82%, var(--text-primary) 18%);
}

.analysis-dev-provider--deepseek {
  color: color-mix(in oklab, #0f52ba 82%, var(--text-primary) 18%);
}

.analysis-dev-provider--openrouter {
  color: color-mix(in oklab, #b45309 82%, var(--text-primary) 18%);
}

.analysis-result-card {
  border: 1px solid color-mix(in oklab, var(--surface-border) 62%, transparent);
  background: color-mix(in oklab, var(--bg-elevated) 90%, white 10%);
  border-radius: 0.98rem;
  padding: 0.76rem 0.8rem;
  box-shadow: 0 6px 16px color-mix(in oklab, var(--brand) 8%, transparent);
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.analysis-result-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.analysis-result-card__title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: color-mix(in oklab, var(--text-secondary) 78%, var(--brand) 22%);
  text-transform: uppercase;
}

.analysis-result-card__title-row {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
}

.analysis-result-card__manual-kbju {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.9rem;
  height: 0.9rem;
  color: color-mix(in oklab, var(--text-secondary) 68%, transparent);
  opacity: 0.58;
}

.analysis-result-card__manual-kbju svg {
  width: 0.76rem;
  height: 0.76rem;
}

/* Copy analysis to clipboard button */
.analysis-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: color-mix(in oklab, var(--text-secondary) 58%, transparent);
  cursor: pointer;
  transition: color 120ms ease, background-color 120ms ease;
  touch-action: manipulation;
  flex-shrink: 0;
}

.analysis-copy-btn:hover {
  color: var(--brand);
  background: color-mix(in oklab, var(--brand) 8%, transparent);
}

.analysis-copy-btn:active {
  color: var(--brand);
  background: color-mix(in oklab, var(--brand) 14%, transparent);
}

.analysis-copy-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.analysis-copy-btn svg {
  width: 0.82rem;
  height: 0.82rem;
}

.analysis-copy-btn--copied {
  color: #059669;
  transition: color 200ms ease;
}

.analysis-products__manual-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.9rem;
  height: 0.9rem;
  color: color-mix(in oklab, var(--text-secondary) 68%, transparent);
  opacity: 0.58;
  margin-left: 0.25rem;
  vertical-align: middle;
}

.analysis-products__manual-edit svg {
  width: 0.76rem;
  height: 0.76rem;
}

.analysis-result-card__kcal {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.6rem;
}

.analysis-result-card__kcal-icon {
  width: 1.15rem;
  height: 1.15rem;
  color: color-mix(in oklab, var(--brand) 85%, var(--text-primary) 15%);
}

.analysis-result-card__kcal-text {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.analysis-result-card__kcal-value {
  font-size: 1.82rem;
  line-height: 1;
  font-weight: 680;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.analysis-result-card__kcal-unit {
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--text-secondary);
}

.analysis-macro-bar {
  display: flex;
  height: 0.6rem;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid color-mix(in oklab, var(--surface-border) 70%, transparent);
  background: color-mix(in oklab, var(--bg-muted) 75%, var(--bg-elevated) 25%);
  animation: macro-bar-glow 2.4s ease-in-out 700ms infinite;
}

@keyframes macro-bar-glow {
  0%, 100% {
    box-shadow: none;
    filter: brightness(1);
  }
  50% {
    box-shadow:
      0 0 6px color-mix(in oklab, var(--macro-carbs) 30%, transparent),
      0 0 12px color-mix(in oklab, var(--macro-fat) 18%, transparent);
    filter: brightness(1.06);
  }
}

.analysis-macro-bar__seg {
  flex: var(--grow, 0) 0 0;
  min-width: 0;
  transform-origin: left center;
  animation: macro-bar-fill 600ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes macro-bar-fill {
  from { transform: scaleX(0); opacity: 0; }
  to { transform: scaleX(1); opacity: 1; }
}

.analysis-macro-bar--empty .analysis-macro-bar__seg {
  flex: 1 0 0;
  opacity: 0.12;
}

.analysis-macro-bar__seg--carbs {
  background: var(--macro-carbs);
  animation-delay: 80ms;
}

.analysis-macro-bar__seg--fat {
  background: var(--macro-fat);
  animation-delay: 160ms;
}

.analysis-macro-bar__seg--protein {
  background: var(--macro-protein);
  animation-delay: 240ms;
}

.analysis-macros {
  margin-top: 0.65rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.analysis-macros__item {
  min-width: 0;
}

.analysis-macros__label {
  font-size: 0.86rem;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  line-height: 1.1;
}

.analysis-macros__dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: color-mix(in oklab, var(--surface-border) 60%, transparent);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--bg) 70%, transparent);
  flex: 0 0 auto;
}

.analysis-macros__value {
  margin-top: 0.25rem;
  font-size: 1.12rem;
  font-weight: 650;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.analysis-macros__item--carbs .analysis-macros__dot {
  background: var(--macro-carbs);
}

.analysis-macros__item--fat .analysis-macros__dot {
  background: var(--macro-fat);
}

.analysis-macros__item--protein .analysis-macros__dot {
  background: var(--macro-protein);
}

@media (max-width: 460px) {
  .meal-card--media .analysis-result-card {
    border-radius: 0.95rem;
    padding: 0.68rem 0.72rem;
  }

  .meal-card--media .analysis-result-card__header {
    margin-bottom: 0.4rem;
  }

  .meal-card--media .analysis-result-card__title {
    font-size: 0.78rem;
    font-weight: 600;
  }

  .meal-card--media .analysis-result-card__kcal {
    gap: 0.35rem;
    margin: 0 0 0.46rem;
  }

  .meal-card--media .analysis-result-card__kcal-icon {
    width: 1rem;
    height: 1rem;
  }

  .meal-card--media .analysis-result-card__kcal-value {
    font-size: 1.62rem;
    font-weight: 680;
  }

  .meal-card--media .analysis-result-card__kcal-unit {
    font-size: 0.82rem;
    font-weight: 600;
  }

  .meal-card--media .analysis-macro-bar {
    height: 0.46rem;
  }

  .meal-card--media .analysis-macros {
    margin-top: 0.46rem;
    gap: 0.5rem;
  }

  .meal-card--media .analysis-macros__label {
    font-size: 0.78rem;
    font-weight: 520;
    gap: 0.3rem;
  }

  .meal-card--media .analysis-macros__dot {
    width: 0.46rem;
    height: 0.46rem;
  }

  .meal-card--media .analysis-macros__value {
    margin-top: 0.14rem;
    font-size: 0.92rem;
    font-weight: 650;
  }

  .meal-card--media .analysis-products {
    margin-top: 0.46rem;
    padding-top: 0.42rem;
  }

  .meal-card--media .analysis-products__summary {
    gap: 0.4rem;
    font-size: 0.84rem;
  }

  .meal-card--media .analysis-products__summary-icon {
    width: 1rem;
    height: 1rem;
  }
}

@media (max-width: 380px) {
  .meal-card--media .analysis-result-card {
    padding: 0.62rem 0.66rem;
  }

  .meal-card--media .analysis-result-card__kcal-value {
    font-size: 1.48rem;
    font-weight: 660;
  }

  .meal-card--media .analysis-macros__value {
    font-size: 0.88rem;
    font-weight: 620;
  }
}

.analysis-products__empty {
  margin: 0.65rem 0 0;
  padding-top: 0.65rem;
  border-top: 1px dashed color-mix(in oklab, var(--surface-border) 65%, var(--brand) 35%);
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.analysis-products__empty-label {
  font-weight: 650;
  color: var(--text-primary);
}

.analysis-products {
  margin-top: 0.52rem;
  padding-top: 0.45rem;
  border-top: 1px dashed color-mix(in oklab, var(--surface-border) 65%, var(--brand) 35%);
}

.analysis-products__summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.55rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 650;
  user-select: none;
  text-decoration: none;
}

.analysis-products__summary::-webkit-details-marker {
  display: none;
}

.analysis-products__summary::marker {
  content: "";
}

.analysis-products__summary:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 4px;
  border-radius: 0.75rem;
}

.analysis-products__summary-label {
  color: color-mix(in oklab, var(--text-primary) 80%, var(--brand) 20%);
}

.analysis-products__summary-icon {
  width: 1.2rem;
  height: 1.2rem;
  color: color-mix(in oklab, var(--text-secondary) 72%, var(--brand) 28%);
  transition: transform 160ms ease, color 160ms ease;
  flex: 0 0 auto;
  transform: rotate(-90deg);
}

.analysis-products[open] .analysis-products__summary-icon {
  transform: rotate(0deg);
  color: color-mix(in oklab, var(--brand) 72%, var(--text-secondary) 28%);
}

.analysis-products__panel {
  margin-top: 0;
  background: color-mix(in oklab, var(--bg) 86%, transparent);
  border: 1px solid color-mix(in oklab, var(--surface-border) 62%, transparent);
  border-radius: 0.95rem;
  padding: 0.6rem 0.65rem;
  transition: border-color 180ms ease, background-color 180ms ease;
}

.analysis-products[open] .analysis-products__panel {
  margin-top: 0.55rem;
  animation: analysis-products-expand 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.analysis-products__panel-head {
  float: right;
  margin: 0 0 0.3rem 0.45rem;
}

.analysis-products__line {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.analysis-products__line-label {
  font-weight: 650;
  color: var(--text-primary);
}

.analysis-products__list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.analysis-products__item + .analysis-products__item {
  margin-top: 0.25rem;
}

.analysis-products__name {
  color: var(--text-primary);
}

.analysis-products__meta {
  color: color-mix(in oklab, var(--text-secondary) 78%, transparent);
}

.analysis-products__tail {
  white-space: nowrap;
}

.analysis-products__hint {
  margin: 0.42rem 0 0;
  color: color-mix(in oklab, var(--text-secondary) 60%, transparent);
  font-size: 0.74rem;
  line-height: 1.3;
  opacity: 0.82;
}

.analysis-confidence {
  position: relative;
  display: inline-flex;
  vertical-align: middle;
  margin-left: 0.34rem;
}

.analysis-confidence__trigger {
  cursor: pointer;
  list-style: none;
  border: none;
  background: transparent;
  padding: 0;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.analysis-confidence__trigger::-webkit-details-marker {
  display: none;
}

.analysis-confidence__trigger::marker {
  content: "";
}

.analysis-confidence__trigger:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 999px;
}

.analysis-confidence__ring {
  display: block;
  flex-shrink: 0;
}

.analysis-confidence__ring-track {
  fill: none;
  stroke: rgba(148, 163, 184, 0.20);
  stroke-width: 1.5;
}

.analysis-confidence__ring-fill {
  fill: none;
  stroke: #94a3b8;
  stroke-width: 1.5;
  stroke-linecap: round;
  /* circumference = 2 * PI * 4.5 ≈ 28.27 */
  stroke-dasharray: 28.27;
  stroke-dashoffset: calc(28.27 * (1 - var(--confidence, 0)));
}

.analysis-confidence--warning .analysis-confidence__ring-fill {
  stroke: #f59e0b;
}

.analysis-confidence--warning .analysis-confidence__ring-track {
  stroke: rgba(245, 158, 11, 0.20);
}

.analysis-confidence__tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.48rem);
  transform: translateX(-50%) translateY(4px);
  opacity: 0;
  pointer-events: none;
  min-width: 11rem;
  max-width: 14rem;
  padding: 0.36rem 0.48rem;
  border-radius: 0.5rem;
  border: 1px solid color-mix(in oklab, var(--surface-border) 72%, transparent);
  background: color-mix(in oklab, var(--bg-elevated) 92%, transparent);
  color: var(--text-primary);
  font-size: 0.74rem;
  line-height: 1.3;
  text-align: center;
  box-shadow: 0 8px 24px color-mix(in oklab, var(--shadow) 40%, transparent);
  transition: opacity 140ms ease, transform 140ms ease;
  z-index: 20;
}

.analysis-confidence__tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(100% - 1px);
  width: 0.45rem;
  height: 0.45rem;
  background: inherit;
  border-right: 1px solid color-mix(in oklab, var(--surface-border) 72%, transparent);
  border-bottom: 1px solid color-mix(in oklab, var(--surface-border) 72%, transparent);
  transform: translateX(-50%) rotate(45deg);
}

.analysis-confidence:hover .analysis-confidence__tooltip,
.analysis-confidence[open] .analysis-confidence__tooltip,
.analysis-confidence:focus-within .analysis-confidence__tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.analysis-products__divider {
  clear: both;
  height: 1px;
  margin: 0.6rem 0;
  background: color-mix(in oklab, var(--surface-border) 70%, transparent);
}

.analysis-products__health {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.35;
}

.analysis-products__health-note {
  margin: 0.42rem 0 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.35;
}

.analysis-products__health-note--improve strong {
  color: var(--text-secondary);
}

.analysis-products__edit-toggle {
  width: 2.2rem;
  height: 2.2rem;
  min-width: var(--tap-target-min);
  min-height: var(--tap-target-min);
  border-radius: 0.55rem;
  border: 1px solid color-mix(in oklab, var(--surface-border) 62%, transparent);
  background: color-mix(in oklab, var(--bg-elevated) 82%, transparent);
  color: color-mix(in oklab, var(--text-primary) 80%, var(--brand) 20%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.analysis-products__edit-toggle svg {
  width: 0.95rem;
  height: 0.95rem;
}

.analysis-products__edit-toggle--active {
  background: color-mix(in oklab, var(--brand) 15%, var(--bg-elevated) 85%);
  border-color: color-mix(in oklab, var(--brand) 60%, var(--surface-border) 40%);
}

.analysis-products__edit-toggle:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.analysis-products__editor {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid color-mix(in oklab, var(--surface-border) 70%, transparent);
  opacity: 1;
  filter: blur(0);
  transform: translateY(0);
  transition: opacity 320ms ease, filter 320ms ease, transform 320ms ease;
}

.analysis-products__editor--closing {
  opacity: 0;
  filter: blur(4px);
  transform: translateY(-3px);
  pointer-events: none;
}

/* ── Ingredients editor ── */

.analysis-products__form-rows {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Each ingredient row: flex column, 2 children (name-row + fields) */
.analysis-products__form-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid color-mix(in oklab, var(--surface-border) 60%, transparent);
}

.analysis-products__form-row:last-of-type {
  border-bottom: none;
}

/* Name row: pill input + trailing delete button */
.analysis-products__name-row {
  position: relative;
  display: flex;
  align-items: center;
}

/* Name input — pill, full-width */
.analysis-products__input {
  width: 100%;
  height: var(--tap-target-min);
  padding: 0 var(--tap-target-min) 0 var(--space-3);
  border-radius: var(--radius-full);
  border: 1.5px solid var(--surface-border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  outline: none;
  transition: border-color 0.15s ease;
  box-sizing: border-box;
}

.analysis-products__input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 15%, transparent);
}

/* Delete button — absolute, trailing inside the name pill, always red-tinted */
.analysis-products__remove {
  position: absolute;
  right: 0;
  top: 0;
  width: var(--tap-target-min);
  height: var(--tap-target-min);
  flex-shrink: 0;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: color-mix(in oklab, var(--color-error) 50%, var(--text-secondary) 50%);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease;
}

.analysis-products__remove svg {
  width: 0.85rem;
  height: 0.85rem;
}

.analysis-products__remove:hover,
.analysis-products__remove:active {
  color: var(--color-error);
  background: color-mix(in srgb, var(--color-error) 10%, transparent);
}

.analysis-products__remove:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Armed state: first tap highlights row, second tap confirms delete */
.analysis-products__form-row--armed {
  background: color-mix(in srgb, var(--color-error) 6%, transparent);
  border-radius: var(--radius-md);
  margin-inline: calc(-1 * var(--space-2));
  padding-inline: var(--space-2);
}

.analysis-products__form-row--armed .analysis-products__remove {
  color: var(--color-error);
  background: color-mix(in srgb, var(--color-error) 14%, transparent);
  animation: remove-pulse 0.5s ease;
}

@keyframes remove-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Row enter/remove animations */
@keyframes ingredient-row-enter {
  from {
    opacity: 0;
    transform: scaleY(0.6) translateY(-8px);
  }
  to {
    opacity: 1;
    transform: scaleY(1) translateY(0);
  }
}

.analysis-products__form-row--entering {
  transform-origin: top center;
  animation: ingredient-row-enter 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes ingredient-row-remove {
  from {
    opacity: 1;
    transform: scaleY(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scaleY(0.5) translateY(-6px);
  }
}

.analysis-products__form-row--removing {
  transform-origin: top center;
  animation: ingredient-row-remove 200ms cubic-bezier(0.32, 0.72, 0, 1) both;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .analysis-products__form-row--entering,
  .analysis-products__form-row--removing {
    animation: none;
  }
}

/* Fields wrapper — side-by-side stepper pills */
.analysis-products__fields {
  display: flex;
  gap: var(--space-2);
}

.analysis-products__field-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.analysis-products__field-label {
  padding-right: var(--space-3);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  user-select: none;
  text-align: right;
}

/* Grams stepper — full-width pill, 3-column grid */
.analysis-products__grams {
  display: grid;
  grid-template-columns: var(--tap-target-min) 1fr var(--tap-target-min);
  align-items: center;
  width: 100%;
  height: var(--tap-target-min);
  border-radius: var(--radius-full);
  border: 1.5px solid var(--surface-border);
  background: var(--bg-elevated);
  overflow: hidden;
}

/* Stepper -/+ buttons */
.analysis-products__stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  color: var(--brand);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition: background 0.12s ease;
}

.analysis-products__stepper:first-child {
  border-right: 1px solid color-mix(in oklab, var(--surface-border) 70%, transparent);
}

.analysis-products__stepper:last-child {
  border-left: 1px solid color-mix(in oklab, var(--surface-border) 70%, transparent);
}

.analysis-products__stepper:active {
  background: color-mix(in srgb, var(--brand) 10%, transparent);
}

.analysis-products__stepper:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Grams number input — center cell, no border */
.analysis-products__input--grams {
  width: 100%;
  height: 100%;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  outline: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}

.analysis-products__input--grams:focus {
  border-color: transparent;
  box-shadow: none;
}

.analysis-products__input--grams::-webkit-outer-spin-button,
.analysis-products__input--grams::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Kcal stepper — identical structure to grams pill */
.analysis-products__kcal {
  display: grid;
  grid-template-columns: var(--tap-target-min) 1fr var(--tap-target-min);
  align-items: center;
  width: 100%;
  height: var(--tap-target-min);
  border-radius: var(--radius-full);
  border: 1.5px solid var(--surface-border);
  background: var(--bg-elevated);
  overflow: hidden;
}

/* Kcal number input — center cell, no border */
.analysis-products__input--kcal {
  width: 100%;
  height: 100%;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  outline: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}

.analysis-products__input--kcal:focus {
  border-color: transparent;
  box-shadow: none;
}

.analysis-products__input--kcal::-webkit-outer-spin-button,
.analysis-products__input--kcal::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Add row — text link below the rows list */
.analysis-products__add-row {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-top: var(--space-2);
  padding: var(--space-1) 0;
  background: none;
  border: none;
  color: var(--brand);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.analysis-products__add-row:hover {
  opacity: 0.75;
}

.analysis-products__add-row:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.analysis-products__add-row svg {
  width: 0.9rem;
  height: 0.9rem;
  flex-shrink: 0;
}

/* Action bar — 2 buttons only, never wraps */
.analysis-products__editor-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid color-mix(in oklab, var(--surface-border) 70%, transparent);
  margin-top: var(--space-2);
}

/* Cancel — auto width, ghost pill */
.analysis-products__action-cancel {
  flex: 0 0 auto;
  height: var(--tap-target-min);
  padding: 0 var(--space-3);
  border-radius: var(--radius-full);
  border: 1.5px solid var(--surface-border);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.analysis-products__action-cancel:hover {
  color: var(--text-primary);
  border-color: color-mix(in oklab, var(--surface-border) 140%, transparent);
}

.analysis-products__action-cancel:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Submit — full-width brand pill (matches kbju-sheet__save pattern) */
.analysis-products__action-submit {
  width: 100%;
  height: var(--tap-target-min);
  padding: 0 var(--space-3);
  border-radius: var(--radius-full);
  border: none;
  background: var(--brand);
  color: var(--text-inverse);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  transition: background 0.15s ease;
}

/* Override modal-sheet__actions alignment inside ingredients editor */
.analysis-products__form .modal-sheet__actions {
  justify-content: center;
}

.analysis-products__action-submit:hover {
  background: var(--brand-strong);
}

.analysis-products__action-submit:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.analysis-products__action-submit svg {
  width: 0.9rem;
  height: 0.9rem;
  flex-shrink: 0;
}

@media (hover: hover) and (pointer: fine) {
  .analysis-products__edit-toggle:hover {
    transform: translateY(-1px);
  }
}

@keyframes analysis-dot {
  0%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  45% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@keyframes analysis-products-expand {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.995);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes reveal-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.native-start {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 3rem);
  padding: 2rem 1.5rem;
  text-align: center;
  animation: reveal-up 400ms ease both;
}

.native-start__hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.native-start__icon {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 1rem;
  overflow: hidden;
  display: block;
  box-shadow: 0 12px 32px color-mix(in oklab, var(--brand) 30%, transparent);
  margin-bottom: 0.5rem;
}

.native-start__icon img,
.native-start__icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.native-start__tagline {
  margin: 0.25rem 0 0;
  color: var(--text-secondary);
  font-size: 1.12rem;
  font-weight: 640;
  max-width: 20rem;
  line-height: 1.4;
}

.native-start__guest-access {
  margin: 0.1rem 0 0;
  color: var(--text-secondary);
  font-size: 0.92rem;
  max-width: 24rem;
  line-height: 1.45;
}

.native-start__actions {
  margin-top: 2rem;
  display: grid;
  gap: 0.75rem;
  width: 100%;
  max-width: 20rem;
}

.native-start__actions .ui-button {
  width: 100%;
}

.native-start__settings {
  margin-top: 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.native-start__locales {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.native-start__locale {
  border: 1px solid var(--surface-border);
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.28rem 0.6rem;
  transition: background-color 120ms ease, color 120ms ease;
}

.native-start__locale:hover,
.native-start__locale:focus-visible {
  color: var(--text-primary);
}

.native-start__locale--active {
  background: var(--bg-muted);
  color: var(--text-primary);
}

.native-start__theme-toggle {
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid var(--surface-border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-radius: 999px;
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  font: inherit;
  line-height: 0;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.native-start__theme-icon {
  width: 1.05rem;
  height: 1.05rem;
  display: none;
  place-items: center;
  grid-area: 1 / 1;
  pointer-events: none;
}

.native-start__theme-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

html[data-theme="dark"] .native-start__theme-icon--sun {
  display: grid;
}

html[data-theme="light"] .native-start__theme-icon--moon {
  display: grid;
}

/* Administrate: lightweight local styling without external pipeline assets. */
.app-container {
  width: min(100% - 2rem, 82rem);
  margin: 1.25rem auto;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 1rem;
}

.navigation {
  position: sticky;
  top: 1rem;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.8rem;
  border: 1px solid var(--surface-border);
  border-radius: 0.9rem;
  background: color-mix(in oklab, var(--bg-elevated) 95%, var(--bg) 5%);
}

.navigation__link,
.button,
.button--nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border-radius: 0.6rem;
  border: 1px solid var(--surface-border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 0.5rem 0.7rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.navigation__link--active {
  border-color: color-mix(in oklab, var(--brand) 60%, var(--surface-border) 40%);
  background: color-mix(in oklab, var(--brand) 12%, var(--bg-elevated) 88%);
}

.button--danger {
  color: #b91c1c;
  border-color: color-mix(in oklab, #ef4444 60%, var(--surface-border) 40%);
}

.main-content {
  border: 1px solid var(--surface-border);
  border-radius: 0.9rem;
  background: var(--bg-elevated);
  min-width: 0;
}

.main-content__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--surface-border);
}

.main-content__page-title {
  margin: 0;
  font-size: 1.1rem;
}

.main-content__body {
  padding: 1rem 1.1rem;
}

.main-content__body--flush {
  padding: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: color-mix(in oklab, var(--bg) 88%, var(--bg-elevated) 12%);
  border-bottom: 1px solid var(--surface-border);
  padding: 0.6rem;
}

tbody td {
  border-bottom: 1px solid color-mix(in oklab, var(--surface-border) 70%, transparent);
  padding: 0.6rem;
  vertical-align: top;
}

tbody tr:hover {
  background: color-mix(in oklab, var(--bg) 84%, var(--brand) 16%);
}

.cell-label {
  padding-top: 0.15em;
}

.cell-label a {
  color: inherit;
  display: inline-block;
  width: 100%;
  transition: color 120ms ease;
}

.cell-label__sort-indicator {
  float: right;
  margin-left: 0.35rem;
}

.cell-label__sort-indicator svg {
  width: 0.82rem;
  height: 0.82rem;
  color: var(--text-secondary);
  transition: transform 120ms ease, color 120ms ease;
}

.cell-label:hover a {
  color: var(--brand);
}

.cell-label:hover .cell-label__sort-indicator svg {
  color: var(--brand);
}

.cell-label--asc,
.cell-label--desc {
  font-weight: 700;
}

.cell-label__sort-indicator--desc {
  transform: rotate(180deg);
}

.cell-label--action-button,
.cell-data--number,
.cell-label--number {
  width: 1rem;
  white-space: nowrap;
}

.cell-data--number,
.cell-label--number {
  text-align: right;
}

.action-show {
  color: inherit;
  text-decoration: none;
}

.attribute-label {
  font-weight: 700;
  margin-top: 0.85rem;
}

.attribute-data {
  margin: 0.2rem 0 0.55rem;
  color: var(--text-secondary);
}

.search {
  margin-left: auto;
  margin-right: 1rem;
  max-width: 18rem;
  position: relative;
  width: 100%;
}

.search__input {
  border-radius: 999px;
  width: 100%;
  border: 1px solid var(--surface-border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 0.45rem 2.25rem 0.45rem 2.25rem;
}

.search__eyeglass-icon {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  width: 1rem;
  height: 1rem;
  transform: translateY(-50%);
  color: var(--text-secondary);
}

.search__clear-link {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  width: 1rem;
  height: 1rem;
  transform: translateY(-50%);
}

.search__clear-icon {
  width: 1rem;
  height: 1rem;
  color: var(--text-secondary);
}

.search__clear-icon:hover {
  color: var(--brand);
}

@media (hover: none) and (pointer: coarse) {
  :where(
    .ui-button,
    .meal-fab,
    .fab-speed-dial__trigger,
    .fab-speed-dial__item,
    .navbar__app-icon,
    .navbar__profile-icon,
    .navbar__settings-trigger,
    .navbar__settings-theme,
    .tabbar__tab,
    .navbar__compact-link,
    .navbar__locale,
    .card-menu__trigger,
    .card-menu__item,
    .analysis-overlay__action,
    .analysis-products__edit-toggle,
    .analysis-products__remove
  ) {
    transition:
      transform 140ms ease,
      background-color 140ms ease,
      border-color 140ms ease,
      color 140ms ease,
      box-shadow 140ms ease;
  }

  :where(
    .ui-button,
    .meal-fab,
    .fab-speed-dial__trigger,
    .fab-speed-dial__item,
    .navbar__app-icon,
    .navbar__profile-icon,
    .navbar__settings-trigger,
    .navbar__settings-theme,
    .card-menu__trigger,
    .analysis-overlay__action,
    .analysis-products__edit-toggle,
    .analysis-products__remove
  ):active {
    transform: translateY(-1px) scale(0.995);
  }

  :where(.card-menu__item):active {
    transform: translateX(-1px);
  }

  /* Prevent sticky hover repaint flashes on touch screens. */
  .ui-button:hover,
  .meal-fab:hover,
  .navbar__app-icon:hover,
  .navbar__profile-icon:hover,
  .navbar__settings-trigger:hover,
  .navbar__settings-theme:hover,
  .card-menu__trigger:hover,
  .card-menu__item:hover,
  .analysis-overlay__action:hover,
  .analysis-products__edit-toggle:hover,
  .analysis-products__remove:hover {
    transform: none;
  }

  .ui-button--primary:hover,
  .meal-page__create-button.ui-button--primary:hover {
    background: var(--brand);
  }

  .card-menu__item--danger:hover {
    background: transparent;
  }
}

.pagination {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  justify-content: flex-end;
  padding: 0.8rem 1rem;
}

.pagination a,
.pagination span {
  border: 1px solid var(--surface-border);
  border-radius: 0.45rem;
  padding: 0.25rem 0.45rem;
}

@media (max-width: 900px) {
  .app-container {
    grid-template-columns: 1fr;
  }

  .navigation {
    position: static;
  }
}

.reports-page .meal-page__container {
  max-width: 56rem;
}

.report-builder .meal-card__body {
  padding: 1rem;
}

.report-builder__form {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.72rem;
}

.report-builder__presets {
  margin-bottom: 0.2rem;
}

.report-builder__field {
  display: grid;
  gap: 0.35rem;
}

.report-builder__hint {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.86rem;
}

.report-builder__usage {
  margin: 0;
  font-size: 0.86rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.report-builder__usage--limit {
  color: var(--color-error, #d32f2f);
  font-weight: 600;
}

.report-builder__history-title {
  margin: 0;
  font-size: 1rem;
}

.report-builder__history-list {
  margin-top: 0.72rem;
  display: grid;
  gap: 0.45rem;
}

.report-builder__history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  padding: 0.58rem 0.62rem;
  border: 1px solid color-mix(in oklab, var(--surface-border) 70%, transparent);
  border-radius: 0.72rem;
  background: color-mix(in oklab, var(--bg) 86%, transparent);
}

.report-builder__history-main {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  color: inherit;
  text-decoration: none;
}

.report-builder__history-main:hover {
  color: var(--text-primary);
}

.report-builder__history-delete {
  flex-shrink: 0;
}

.report-builder__history-period {
  font-size: 0.9rem;
}

.report-details__period {
  margin: 0;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.report-details__metric {
  margin: 0.45rem 0 0;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.report-adherence .meal-card__body {
  padding: 0.52rem 0.62rem;
  display: grid;
  gap: 0.3rem;
}

.report-adherence {
  position: relative;
  overflow: visible;
  border-color: color-mix(in oklab, var(--adherence-color) 28%, var(--surface-border));
  box-shadow:
    var(--shadow-sm),
    0 0 1.2rem color-mix(in oklab, var(--adherence-color) 22%, transparent),
    0 0 2.4rem color-mix(in oklab, var(--adherence-color) 14%, transparent),
    0 0 4rem color-mix(in oklab, var(--adherence-color) 6%, transparent);
  transition: box-shadow 0.8s ease 0.5s, border-color 0.8s ease 0.5s;
}

.report-adherence__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.42rem;
}

.report-adherence__title {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.1;
}

.report-adherence__title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
}

.report-adherence__info {
  display: inline-grid;
  place-items: center;
  width: var(--tap-target-min);
  height: var(--tap-target-min);
  margin: calc(-1 * (var(--tap-target-min) - 0.8rem) / 2);
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  transition: color 140ms ease;
  flex-shrink: 0;
}

.report-adherence__info svg {
  width: 0.8rem;
  height: 0.8rem;
  display: block;
}

.report-adherence__info:hover {
  color: var(--brand);
}

.report-adherence__info:focus-visible {
  outline: 2px solid color-mix(in oklab, var(--brand) 65%, transparent 35%);
  outline-offset: 2px;
}

.report-adherence__score {
  color: var(--adherence-color);
  font-weight: 800;
  font-size: 0.86rem;
  line-height: 1.1;
  letter-spacing: 0.02em;
  text-shadow:
    0 0 0.5rem color-mix(in oklab, var(--adherence-color) 55%, transparent),
    0 0 1.2rem color-mix(in oklab, var(--adherence-color) 30%, transparent);
}

.report-adherence-dialog {
  width: min(100% - 1.2rem, 32rem);
  max-width: 32rem;
  border: 0;
  padding: 0;
  margin: auto;
  background: transparent;
  color: inherit;
}

.report-adherence-dialog::backdrop {
  background: rgba(15, 19, 27, 0.34);
  background: color-mix(in oklab, var(--bg) 34%, transparent);
  -webkit-backdrop-filter: blur(10px) saturate(1.08);
  backdrop-filter: blur(10px) saturate(1.08);
}

.report-adherence-modal__dialog {
  width: 100%;
  border-radius: 0.9rem;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border: 1px solid color-mix(in oklab, var(--surface-border) 68%, white 32%);
  background: var(--bg-elevated);
  box-shadow:
    0 20px 54px rgba(8, 12, 22, 0.34),
    0 0 1rem color-mix(in oklab, var(--adherence-color) 14%, transparent);
  padding: 0.78rem 0.84rem;
}

.report-adherence-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.44rem;
}

.report-adherence-modal__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.report-adherence-modal__close {
  width: 2rem;
  height: 2rem;
  border-radius: 0.66rem;
  border: 1px solid color-mix(in oklab, var(--surface-border) 64%, transparent);
  background: color-mix(in oklab, var(--bg) 84%, transparent);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.report-adherence-modal__close svg {
  width: 0.95rem;
  height: 0.95rem;
}

.report-adherence-modal__text {
  margin: 0.52rem 0 0;
  font-size: 0.86rem;
  line-height: 1.35;
  color: var(--text-secondary);
}

.report-adherence-modal__sources-title {
  margin: 0.64rem 0 0;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
}

.report-adherence-modal__sources {
  margin: 0.32rem 0 0;
  display: grid;
  gap: 0.24rem;
}

.report-adherence-modal__sources a {
  color: color-mix(in oklab, var(--brand) 74%, var(--text-primary) 26%);
  text-decoration-color: color-mix(in oklab, var(--brand) 44%, transparent);
  font-size: 0.8rem;
}

.report-adherence-modal__sources a:hover {
  text-decoration-color: currentColor;
}

.report-adherence-modal__hint {
  margin: 0.52rem 0 0;
  font-size: 0.76rem;
  color: var(--text-tertiary, var(--text-secondary));
  opacity: 0.7;
}

.report-adherence__bar {
  position: relative;
  height: 0.34rem;
  border-radius: 999px;
  overflow: visible;
  border: 1px solid color-mix(in oklab, var(--surface-border) 40%, transparent);
  background: linear-gradient(
    90deg,
    #BE123C 0%,
    #E11D48 12%,
    #F97316 30%,
    #FB923C 42%,
    #FDE047 58%,
    #FACC15 68%,
    #34D399 85%,
    #059669 100%
  );
  box-shadow:
    inset 0 0 0 1px color-mix(in oklab, var(--surface-border) 32%, transparent),
    0 0 0.6rem color-mix(in oklab, var(--adherence-color) 40%, transparent),
    0 0 1.4rem color-mix(in oklab, var(--adherence-color) 25%, transparent),
    0 0 2.8rem color-mix(in oklab, var(--adherence-color) 12%, transparent);
  isolation: isolate;
  animation: adherence-bar-glow 3.6s ease-in-out infinite;
}

@keyframes adherence-bar-glow {
  0%, 100% {
    box-shadow:
      inset 0 0 0 1px color-mix(in oklab, var(--surface-border) 32%, transparent),
      0 0 0.6rem color-mix(in oklab, var(--adherence-color) 40%, transparent),
      0 0 1.4rem color-mix(in oklab, var(--adherence-color) 25%, transparent),
      0 0 2.8rem color-mix(in oklab, var(--adherence-color) 12%, transparent);
    filter: brightness(1) saturate(1);
  }
  50% {
    box-shadow:
      inset 0 0 0 1px color-mix(in oklab, var(--surface-border) 20%, transparent),
      0 0 0.8rem color-mix(in oklab, var(--adherence-color) 55%, transparent),
      0 0 2rem color-mix(in oklab, var(--adherence-color) 38%, transparent),
      0 0 3.6rem color-mix(in oklab, var(--adherence-color) 18%, transparent);
    filter: brightness(1.08) saturate(1.12);
  }
}

/* PS3 XMB wave overlay — light streaks sweeping across the bar */
.report-adherence__bar::before {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: 1;
  border-radius: inherit;
  background:
    linear-gradient(105deg, transparent 18%, rgba(255,255,255,0.42) 38%, transparent 58%),
    linear-gradient(255deg, transparent 28%, rgba(255,255,255,0.22) 48%, transparent 68%);
  background-size: 220% 100%;
  animation: ps3-wave 6s ease-in-out infinite;
  pointer-events: none;
}

/* PS3 XMB glow overlay — drifting radial light spots */
.report-adherence__bar::after {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: 1;
  border-radius: inherit;
  background:
    radial-gradient(ellipse at 25% 50%, rgba(255,255,255,0.28) 0%, transparent 50%),
    radial-gradient(ellipse at 75% 50%, rgba(255,255,255,0.2) 0%, transparent 50%);
  background-size: 300% 200%;
  animation: ps3-glow 10s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes ps3-wave {
  0%   { background-position: 220% 0; }
  50%  { background-position: -60% 0; }
  100% { background-position: 220% 0; }
}

@keyframes ps3-glow {
  0%   { background-position: 0% 0%;   opacity: 0.4; }
  50%  { background-position: 100% 100%; opacity: 1; }
  100% { background-position: 0% 0%;   opacity: 0.4; }
}

.report-adherence__marker {
  position: absolute;
  left: clamp(0.46rem, var(--adherence-score-animated, var(--adherence-score)), calc(100% - 0.46rem));
  top: 50%;
  transform: translate(-50%, -50%);
  width: 1.4rem;
  height: 1.4rem;
  display: grid;
  place-items: center;
  pointer-events: none;
  transition: left 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.report-adherence__marker-halo {
  position: absolute;
  inset: -0.3rem;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--adherence-color) 82%, white 18%);
  box-shadow:
    0 0 0.8rem color-mix(in oklab, var(--adherence-color) 68%, transparent),
    0 0 2rem color-mix(in oklab, var(--adherence-color) 42%, transparent);
  animation: report-adherence-pulse 2.2s ease-out infinite;
}

.report-adherence__marker-core {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 999px;
  border: 2px solid color-mix(in oklab, white 92%, transparent);
  background: var(--adherence-color);
  box-shadow:
    0 0 0 2px color-mix(in oklab, white 90%, transparent),
    0 0 0.8rem color-mix(in oklab, var(--adherence-color) 85%, transparent),
    0 0 1.8rem color-mix(in oklab, var(--adherence-color) 55%, transparent),
    0 0 3.2rem color-mix(in oklab, var(--adherence-color) 28%, transparent);
}

.report-adherence__marker::after {
  display: none;
}

.report-adherence__meta {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.72rem;
  line-height: 1.2;
}

@keyframes report-adherence-pulse {
  0% {
    transform: scale(0.6);
    opacity: 0.9;
  }
  60% {
    transform: scale(1.8);
    opacity: 0;
  }
  100% {
    transform: scale(1.8);
    opacity: 0;
  }
}

/* Variant C: eruption burst on entry */
.report-adherence--erupted .report-adherence__marker-halo {
  animation:
    report-adherence-erupt 0.5s ease-out both,
    report-adherence-pulse 2.4s ease-out 0.5s infinite;
}

@keyframes report-adherence-erupt {
  0% {
    transform: scale(0.5);
    opacity: 1;
    box-shadow: 0 0 3rem color-mix(in oklab, var(--adherence-color) 85%, transparent);
  }
  50% {
    transform: scale(2.5);
    opacity: 0.6;
  }
  100% {
    transform: scale(0.6);
    opacity: 0.9;
  }
}

/* Score number eruption echo */
.report-adherence--erupted .report-adherence__score {
  animation: report-adherence-score-glow 0.6s ease-out 0.4s both;
}

@keyframes report-adherence-score-glow {
  0% {
    text-shadow: 0 0 2rem color-mix(in oklab, var(--adherence-color) 80%, transparent);
    transform: scale(1.15);
  }
  100% {
    text-shadow:
      0 0 0.5rem color-mix(in oklab, var(--adherence-color) 55%, transparent),
      0 0 1.2rem color-mix(in oklab, var(--adherence-color) 30%, transparent);
    transform: scale(1);
  }
}

/* Daily calorie counter — compact inline widget above adherence bar */
.daily-calories {
  display: inline-flex;
  align-items: baseline;
  gap: 0;
  padding: 0.25rem 0;
}

.daily-calories__consumed {
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1;
  transition: color 0.3s ease;
}

.daily-calories__target {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-secondary);
  opacity: 0.65;
}

.daily-calories__unit {
  font-size: 0.625rem;
  font-weight: 400;
  color: var(--text-secondary);
  opacity: 0.50;
  margin-left: 0.15em;
}

/* Inline compact adherence bar */
.report-adherence--inline {
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
  padding: 0.1rem 0;
  display: grid;
  gap: 0.45rem;
}

.report-adherence--inline__row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.3rem;
}

.report-adherence--inline .report-adherence__score {
  font-size: 0.82rem;
}

.report-timeline .meal-card__body {
  padding: 0.82rem;
}

.report-timeline__list {
  display: grid;
  gap: 0.48rem;
  max-height: min(68vh, 33rem);
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding-right: 0.2rem;
}

.report-timeline__item {
  display: grid;
  grid-template-columns: 4.8rem minmax(0, 1fr);
  gap: 0.42rem;
  position: relative;
}

.report-timeline__item::before {
  content: "";
  position: absolute;
  left: 4.6rem;
  top: 0.2rem;
  bottom: -0.2rem;
  width: 1px;
  background: color-mix(in oklab, var(--surface-border) 75%, transparent);
}

.report-timeline__mark {
  padding-right: 0.2rem;
  text-align: right;
}

.report-timeline__date {
  margin: 0;
  font-size: 0.81rem;
  line-height: 1.2;
  font-weight: 700;
  color: var(--text-primary);
}

.report-timeline__time {
  margin: 0.08rem 0 0;
  font-size: 0.74rem;
  line-height: 1.15;
  font-weight: 500;
  color: var(--text-secondary);
}

.report-timeline__card {
  display: grid;
  grid-template-columns: 2.85rem minmax(0, 1fr);
  gap: 0.48rem;
  align-items: center;
  border: 1px solid color-mix(in oklab, var(--surface-border) 70%, transparent);
  border-radius: 0.82rem;
  padding: 0.34rem 0.4rem;
  min-height: 4.1rem;
  background: color-mix(in oklab, var(--bg) 86%, transparent);
}

.report-timeline__card-link {
  color: inherit;
  text-decoration: none;
  transition: border-color 120ms ease, background-color 120ms ease, transform 120ms ease;
}

.report-timeline__card-link:hover {
  border-color: color-mix(in oklab, var(--brand) 42%, var(--surface-border) 58%);
  background: color-mix(in oklab, var(--bg) 72%, var(--brand) 28%);
}

.report-timeline__card-media {
  width: 2.85rem;
  height: 2.85rem;
  border-radius: 0.72rem;
  overflow: hidden;
  background: color-mix(in oklab, var(--bg-muted) 72%, transparent);
}

.report-timeline__photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.report-timeline__ingredients {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.25;
  word-break: break-word;
}

.report-timeline__metrics {
  margin: 0.12rem 0 0;
  color: var(--text-secondary);
  font-size: 0.76rem;
}

.report-summary .meal-card__body {
  padding: 0.92rem;
}

.report-summary__title {
  margin: 0;
  font-size: 1rem;
}

.report-summary .ui-loader {
  display: flex;
  justify-content: center;
  margin-top: 0.5rem;
}

.report-summary__line {
  margin: 0.52rem 0 0;
}

.report-share .meal-card__body {
  padding: 0.85rem;
}

.report-share__actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.report-share-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.report-share-modal__backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in oklab, var(--bg) 40%, black 60%);
  border: 0;
}

.report-share-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 24rem);
  border-radius: 1rem;
  border: 1px solid color-mix(in oklab, var(--surface-border) 66%, transparent);
  background: var(--bg-elevated);
  padding: 0.92rem;
  box-shadow: 0 18px 54px rgba(8, 12, 22, 0.35);
}

.report-share-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
}

.report-share-modal__title {
  margin: 0;
  font-size: 1rem;
}

.report-share-modal__close {
  min-width: var(--tap-target-min);
  min-height: var(--tap-target-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.72rem;
  border: 1px solid color-mix(in oklab, var(--surface-border) 66%, transparent);
  background: color-mix(in oklab, var(--bg) 86%, transparent);
  color: var(--text-primary);
}

.report-share-modal__close svg {
  width: 1rem;
  height: 1rem;
}

.report-share-modal__close:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.report-share-modal__hint {
  margin: 0.62rem 0 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.report-share-modal__qr-wrap {
  margin-top: 0.68rem;
  display: flex;
  justify-content: center;
}

.report-share-modal__qr-card {
  width: min(100%, 14.4rem);
  padding: 0.36rem;
  border-radius: 1.1rem;
  background:
    linear-gradient(
      138deg,
      color-mix(in oklab, var(--brand) 68%, white 32%) 0%,
      color-mix(in oklab, var(--brand) 74%, var(--brand-strong) 26%) 44%,
      color-mix(in oklab, var(--brand-strong) 88%, var(--brand) 12%) 100%
    );
  box-shadow:
    0 14px 30px color-mix(in oklab, var(--brand) 24%, transparent),
    0 0 0 1px color-mix(in oklab, var(--brand) 38%, transparent) inset;
}

.report-share-modal__qr-ring {
  position: relative;
  border-radius: 0.9rem;
  padding: 0.45rem;
  background: #fff;
  display: grid;
  place-items: center;
}

.report-share-modal__qr {
  width: 100%;
  max-width: 14rem;
  aspect-ratio: 1;
  border-radius: 0;
  border: 1px solid color-mix(in oklab, var(--surface-border) 78%, transparent);
  background: #fff;
  display: block;
  overflow: hidden;
}

.report-share-modal__qr svg {
  width: 100%;
  height: 100%;
  display: block;
}

.report-share-modal__link-row {
  margin-top: 0.42rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2.6rem;
  gap: 0.42rem;
}

.report-share-modal__copy {
  border-radius: 0.72rem;
  border: 1px solid color-mix(in oklab, var(--surface-border) 62%, transparent);
  background: color-mix(in oklab, var(--bg) 84%, transparent);
  color: var(--text-primary);
}

.report-share-modal__copy svg {
  width: 1rem;
  height: 1rem;
}

.report-share-modal__copied {
  margin: 0.48rem 0 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  min-height: 1.15rem;
}

.report-meal-modal {
  position: fixed;
  inset: 0;
  z-index: 48;
  display: grid;
  place-items: center;
  padding: 0.9rem;
}

.report-meal-modal__backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: color-mix(in oklab, var(--bg) 34%, black 66%);
}

.report-meal-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 36rem);
  max-height: min(90vh, 46rem);
  overflow: auto;
  overscroll-behavior-y: contain;
  border-radius: 1rem;
  border: 1px solid color-mix(in oklab, var(--surface-border) 62%, transparent);
  background: color-mix(in oklab, var(--bg-elevated) 92%, var(--bg) 8%);
  box-shadow: 0 18px 54px rgba(8, 12, 22, 0.4);
  padding: 0.72rem;
}

.report-meal-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.52rem;
  margin-bottom: 0.56rem;
}

.report-meal-modal__title {
  margin: 0;
  font-size: 0.96rem;
}

.report-meal-modal__close {
  min-width: var(--tap-target-min);
  min-height: var(--tap-target-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.7rem;
  border: 1px solid color-mix(in oklab, var(--surface-border) 62%, transparent);
  background: color-mix(in oklab, var(--bg) 86%, transparent);
  color: var(--text-primary);
}

.report-meal-modal__close svg {
  width: 1rem;
  height: 1rem;
}

.report-meal-modal__close:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.report-meal-modal__card {
  margin: 0;
}

.report-analysis-readonly__macros {
  margin: 0.42rem 0 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

@media (min-width: 40rem) {
  .report-timeline__item {
    grid-template-columns: 8.7rem minmax(0, 1fr);
  }

  .report-timeline__item::before {
    left: 8.5rem;
  }

  .report-timeline__time {
    font-size: 0.8rem;
  }
}

/* ───────── Admin Dashboard ───────── */

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.admin-header__title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.admin-grid--sm {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.admin-card {
  padding: 1rem;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg, 0.75rem);
  background: var(--bg-elevated);
}

.admin-card--success {
  background: color-mix(in oklab, #16a34a 8%, var(--bg-elevated));
}

.admin-card--danger {
  background: color-mix(in oklab, #dc2626 6%, var(--bg-elevated));
}

.admin-card--warning {
  background: color-mix(in oklab, #d97706 8%, var(--bg-elevated));
}

.admin-card__label {
  margin: 0;
  color: var(--text-secondary);
}

.admin-card__label--sm {
  font-size: 0.85rem;
}

.admin-card__value {
  margin: 0.25rem 0 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.admin-card__value--lg {
  font-size: 1.75rem;
}

.admin-card__value--success {
  color: #16a34a;
}

.admin-card__value--danger {
  color: #dc2626;
}

.admin-card__value--warning {
  color: #d97706;
}

.admin-links {
  margin-top: 1.25rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.admin-section-title {
  margin: 1.5rem 0 0.75rem;
  font-size: 1.15rem;
  font-weight: 600;
}

.admin-section-subtitle {
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.admin-meta {
  margin: 1rem 0 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ----------------------------------------------------------------
   KBJU Edit — bottom sheet
   ---------------------------------------------------------------- */

.analysis-result-card__edit-kbju {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: color 120ms ease, background-color 120ms ease;
}

.analysis-result-card__edit-kbju:hover {
  color: var(--brand);
  background: color-mix(in oklab, var(--brand) 8%, transparent);
}

.analysis-result-card__edit-kbju svg {
  width: 1rem;
  height: 1rem;
}

body.kbju-sheet-open,
body.modal-open {
  overflow: hidden;
}

/* Native app: no body scroll lock — the native bottom-sheet fragment
   manages its own scrolling and gesture dismissal. */
body.native-app-page.kbju-sheet-open,
body.native-app-page.modal-open {
  overflow: auto;
}

/* Sheet overlay */
.kbju-sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  visibility: hidden;
  pointer-events: none;
}

.kbju-sheet--open {
  visibility: visible;
  pointer-events: auto;
}

.kbju-sheet--closing {
  visibility: visible;
  pointer-events: none;
}

/* Backdrop */
.kbju-sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 260ms ease;
}

.kbju-sheet--open .kbju-sheet__backdrop {
  opacity: 1;
}

.kbju-sheet--closing .kbju-sheet__backdrop {
  opacity: 0;
}

/* Panel */
.kbju-sheet__panel {
  position: relative;
  z-index: 1;
  width: min(100%, 28rem);
  max-height: 88vh;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-elevated);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -8px 40px rgba(8, 12, 22, 0.22);
  padding: 0.5rem 1.2rem calc(1.2rem + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%);
  transition: transform 300ms cubic-bezier(0.32, 0.72, 0, 1);
}

.kbju-sheet--open .kbju-sheet__panel {
  transform: translateY(0);
}

.kbju-sheet--closing .kbju-sheet__panel {
  transform: translateY(100%);
  transition: transform 260ms cubic-bezier(0.32, 0.72, 0, 1);
}

/* Native app: KBJU sheet opens inside Hotwire Native bottom-sheet fragment,
   so we strip the CSS overlay/backdrop/animation and show content directly. */
.native-app-page .kbju-sheet {
  position: static;
  visibility: visible;
  pointer-events: auto;
  display: block;
}

.native-app-page .kbju-sheet__backdrop {
  display: none;
}

.native-app-page .kbju-sheet__panel {
  transform: none;
  transition: none;
  max-height: none;
  box-shadow: none;
  border-radius: 0;
  width: 100%;
}

.native-app-page .kbju-sheet__handle {
  display: none;
}

.native-app-page .kbju-sheet__close {
  display: none;
}

/* Handle (grab bar) */
.kbju-sheet__handle {
  width: 2.4rem;
  height: 0.25rem;
  border-radius: var(--radius-full);
  background: var(--surface-border);
  margin: 0 auto 0.65rem;
}

/* Header */
.kbju-sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.kbju-sheet__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.kbju-sheet__close {
  width: var(--tap-target-min);
  height: var(--tap-target-min);
  border-radius: var(--radius-sm);
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 120ms ease, background-color 120ms ease;
}

.kbju-sheet__close:hover {
  color: var(--text-primary);
  background: color-mix(in oklab, var(--surface-border) 40%, transparent);
}

.kbju-sheet__close:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.kbju-sheet__close svg {
  width: 1.1rem;
  height: 1.1rem;
}

/* Form layout */
.kbju-sheet__form {
  display: grid;
  gap: 0.85rem;
}

/* Field */
.kbju-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.kbju-field__label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-left: 0.25rem;
}

.kbju-field__control {
  display: grid;
  grid-template-columns: 3rem 1fr 3rem;
  align-items: center;
  border: 1.5px solid var(--surface-border);
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  overflow: hidden;
  transition: border-color 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

/* Dirty state: brand border + faint background wash */
.kbju-field--dirty .kbju-field__control {
  border-color: var(--brand);
  background: color-mix(in oklab, var(--brand) 4%, var(--bg-elevated) 96%);
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--brand) 14%, transparent);
}

.kbju-field__stepper {
  min-height: var(--tap-target-min);
  border: 0;
  background: transparent;
  color: var(--brand);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: background-color 100ms ease;
}

.kbju-field__stepper:hover {
  background: color-mix(in oklab, var(--brand) 8%, transparent);
}

.kbju-field__stepper:active {
  background: color-mix(in oklab, var(--brand) 16%, transparent);
}

.kbju-field__input {
  min-width: 0;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 680;
  line-height: 1;
  color: var(--text-primary);
  padding: 0.5rem 0;
  font-family: inherit;
}

.kbju-field__input:focus {
  outline: 0;
}

/* "Was: X" caption */
.kbju-field__original {
  font-size: 0.76rem;
  color: var(--text-secondary);
  padding-left: 0.25rem;
}

/* Actions */
.kbju-sheet__actions {
  margin-top: 0.45rem;
}

.kbju-sheet__manual-note {
  margin: 0 0 0.5rem;
  color: color-mix(in oklab, var(--text-secondary) 62%, transparent);
  font-size: 0.74rem;
  line-height: 1.3;
  opacity: 0.82;
}

.kbju-sheet__save {
  width: 100%;
  justify-content: center;
}

.kbju-sheet__save:disabled {
  opacity: 1;
  pointer-events: none;
  background: var(--surface-border);
  color: var(--text-secondary);
  box-shadow: none;
  border-color: var(--surface-border);
}

/* Dismiss confirmation bar — hidden by default via HTML [hidden] attr */
.kbju-sheet__dismiss-bar[hidden] {
  display: none;
}

.kbju-sheet__dismiss-bar {
  margin-top: 0.65rem;
  padding: 0.55rem 0.72rem;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in oklab, var(--color-warning) 30%, var(--surface-border) 70%);
  background: color-mix(in oklab, var(--color-warning) 6%, var(--bg-elevated) 94%);
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
}

.kbju-sheet__dismiss-text {
  font-size: 0.84rem;
  color: var(--text-secondary);
}

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

.kbju-sheet__dismiss-close,
.kbju-sheet__dismiss-keep {
  border: 0;
  background: transparent;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0.45rem;
  border-radius: var(--radius-sm);
  transition: background-color 100ms ease;
}

.kbju-sheet__dismiss-close {
  color: var(--text-secondary);
}

.kbju-sheet__dismiss-close:hover {
  background: color-mix(in oklab, var(--surface-border) 40%, transparent);
}

.kbju-sheet__dismiss-keep {
  color: var(--brand);
}

.kbju-sheet__dismiss-keep:hover {
  background: color-mix(in oklab, var(--brand) 8%, transparent);
}

.kbju-sheet__dismiss-close:focus-visible,
.kbju-sheet__dismiss-keep:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* KBJU sheet: native app — adjust for safe area / bottom nav */
.native-app-page .kbju-sheet__panel {
  padding-bottom: calc(1.2rem + var(--native-bottom-nav-height, 0px) + env(safe-area-inset-bottom, 0px));
  /* max-height: none is already set above; don't re-impose a limit. */
}

/* ═══════════════════════════════════════════════════════════════════
   Generic modal sheet — reusable bottom-sheet pattern
   (mirrors .kbju-sheet but with generic class names)
   ═══════════════════════════════════════════════════════════════════ */
.modal-sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  visibility: hidden;
  pointer-events: none;
}

.modal-sheet--open {
  visibility: visible;
  pointer-events: auto;
}

.modal-sheet--closing {
  visibility: visible;
  pointer-events: none;
}

.modal-sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 260ms ease;
}

.modal-sheet--open .modal-sheet__backdrop {
  opacity: 1;
}

.modal-sheet--closing .modal-sheet__backdrop {
  opacity: 0;
}

.modal-sheet__panel {
  position: relative;
  z-index: 1;
  width: min(100%, 28rem);
  max-height: 88vh;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-elevated);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -8px 40px rgba(8, 12, 22, 0.22);
  padding: 0.5rem 1.2rem calc(1.2rem + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%);
  transition: transform 300ms cubic-bezier(0.32, 0.72, 0, 1);
}

.modal-sheet--open .modal-sheet__panel {
  transform: translateY(0);
}

.modal-sheet--closing .modal-sheet__panel {
  transform: translateY(100%);
  transition: transform 260ms cubic-bezier(0.32, 0.72, 0, 1);
}

.modal-sheet__handle {
  width: 2rem;
  height: 0.25rem;
  border-radius: 2px;
  background: var(--border-muted, rgba(128, 128, 128, 0.3));
  margin: 0.3rem auto 0.5rem;
}

.modal-sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0 0.6rem;
}

.modal-sheet__title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
}

.modal-sheet__close {
  appearance: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.3rem;
  border-radius: var(--radius-sm, 6px);
  color: var(--text-secondary);
  transition: background 150ms ease;
}

.modal-sheet__close:hover {
  background: var(--bg-hover, rgba(128, 128, 128, 0.12));
}

.modal-sheet__close:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.modal-sheet__close svg {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
}

.modal-sheet__form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.modal-sheet__actions {
  padding-top: 0.6rem;
  display: flex;
  justify-content: flex-end;
}

/* Native app: modal sheet opens inside Hotwire Native bottom-sheet fragment,
   so we strip the CSS overlay/backdrop/animation and show content directly.
   Mirrors the .kbju-sheet native overrides above. */
.native-app-page .modal-sheet {
  position: static;
  visibility: visible;
  pointer-events: auto;
  display: block;
}

.native-app-page .modal-sheet__backdrop {
  display: none;
}

.native-app-page .modal-sheet__panel {
  transform: none;
  transition: none;
  max-height: none;
  box-shadow: none;
  border-radius: 0;
  width: 100%;
  padding-bottom: calc(1.2rem + var(--native-bottom-nav-height, 0px) + env(safe-area-inset-bottom, 0px));
}

.native-app-page .modal-sheet__handle {
  display: none;
}

.native-app-page .modal-sheet__close {
  display: none;
}

/* Turbo Frame busy skeleton shimmer. */
turbo-frame[busy] {
  position: relative;
  min-height: 4rem;
}

turbo-frame[busy]:empty::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  background: linear-gradient(
    90deg,
    var(--bg-muted) 25%,
    color-mix(in oklab, var(--bg-muted) 70%, var(--bg-elevated) 30%) 50%,
    var(--bg-muted) 75%
  );
  background-size: 220% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  z-index: 1;
}


/* Privacy page */
.privacy-page {
  padding: var(--space-6) 0 var(--space-8);
  max-width: 42rem;
  margin: 0 auto;
}

.privacy-page__header {
  margin-bottom: var(--space-8);
  text-align: center;
}

.privacy-page__title {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 var(--space-2);
  color: var(--text-primary);
}

.privacy-page__effective {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 0;
}

.privacy-page__section {
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-4);
}

.privacy-page__section h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--surface-border);
  color: var(--text-primary);
}

.privacy-page__section p {
  margin: 0 0 var(--space-4);
  color: var(--text-secondary);
  line-height: 1.75;
  font-size: 0.9375rem;
}

.privacy-page__section p:last-child {
  margin-bottom: 0;
}

.privacy-page__section ul {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.privacy-page__section li {
  position: relative;
  margin-bottom: var(--space-3);
  padding-left: var(--space-5);
  line-height: 1.65;
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

.privacy-page__section li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--brand);
  opacity: 0.5;
}

.privacy-page__section li:last-child {
  margin-bottom: 0;
}

/* ── Quick Scan ──────────────────────────────────────────────────── */

.quick-scan__back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.92rem;
  margin-bottom: 1rem;
}

.quick-scan__back:hover {
  color: var(--brand);
}

.quick-scan__recommendation {
  border-top: 1px solid var(--surface-border);
  padding-top: 0.75rem;
}

.quick-scan__actions {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding-top: 0.25rem;
}

.quick-scan__not-food {
  text-align: center;
  padding: 2rem 0;
  color: var(--text-secondary);
}

.quick-scan__not-food p {
  margin: 0 0 1rem;
}

.quick-scan__error {
  text-align: center;
  padding: 2rem 0;
  color: var(--text-secondary);
}

.quick-scan__error p {
  margin: 0 0 1rem;
}

/* ── FAB Speed Dial ──────────────────────────────────────────────── */

.fab-speed-dial {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: calc(1rem + env(safe-area-inset-bottom));
  z-index: 32;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.fab-speed-dial__trigger {
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--brand) 70%, var(--surface-border) 30%);
  background:
    linear-gradient(
      110deg,
      color-mix(in oklab, var(--brand) 76%, var(--brand-strong) 24%) 0%,
      color-mix(in oklab, var(--brand) 82%, white 18%) 36%,
      color-mix(in oklab, var(--brand-strong) 84%, var(--brand) 16%) 70%,
      color-mix(in oklab, var(--brand) 76%, var(--brand-strong) 24%) 100%
    );
  background-size: 220% 100%;
  color: var(--text-inverse);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow:
    0 14px 30px color-mix(in oklab, var(--brand) 32%, transparent),
    0 0 18px color-mix(in oklab, var(--brand) 18%, transparent),
    0 0 0 1px color-mix(in oklab, var(--brand) 65%, transparent) inset,
    0 0 10px color-mix(in oklab, white 12%, transparent) inset;
  transition: transform 180ms ease, filter 180ms ease;
  animation:
    fab-entrance 400ms cubic-bezier(0.34, 1.56, 0.64, 1) 300ms both,
    fab-pulse 2.4s ease-in-out 800ms infinite;
}

.fab-speed-dial__trigger:hover,
.fab-speed-dial__trigger:focus-visible {
  transform: translateY(-2px) scale(1.03);
  filter: brightness(1.03);
}

.fab-speed-dial__trigger:focus-visible {
  outline: 2px solid color-mix(in oklab, var(--brand) 55%, white 45%);
  outline-offset: 3px;
}

.fab-speed-dial__trigger-icon {
  width: 1.34rem;
  height: 1.34rem;
  filter: drop-shadow(0 1px 4px rgba(8, 15, 32, 0.28));
  transition: transform 200ms ease;
}

.fab-speed-dial--open .fab-speed-dial__trigger-icon {
  transform: rotate(45deg);
}

.fab-speed-dial__menu {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-end;
  opacity: 0;
  transform: translateY(8px) scale(0.95);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.fab-speed-dial--open .fab-speed-dial__menu {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.fab-speed-dial__item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 4px 12px color-mix(in oklab, var(--text-primary) 8%, transparent);
  transition: background 120ms ease, transform 120ms ease;
}

.fab-speed-dial__item:hover {
  background: color-mix(in oklab, var(--brand) 8%, var(--bg-elevated));
  transform: translateX(-2px);
}

.fab-speed-dial__item-icon {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
}

.fab-speed-dial__file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.fab-speed-dial__form {
  display: contents;
}

@media (prefers-reduced-motion: reduce) {
  .fab-speed-dial__trigger {
    animation: none;
  }

  .fab-speed-dial__trigger-icon {
    transition: none;
  }

  .fab-speed-dial__menu {
    transition: none;
  }
}

@media (max-width: 54rem) {
  .fab-speed-dial {
    bottom: calc(3.6rem + 1.2rem + env(safe-area-inset-bottom));
  }
}
