:root {
  color-scheme: light dark;
  font-family:
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    sans-serif;
  line-height: 1.5;
  --bg: #0f1419;
  --card: #1a2332;
  --text: #e8eef7;
  --muted: #9fb0c7;
  --navy: #011944;
  --accent: #0073fd;
  --accent-hover: #2b8aff;
  --accent-teal: #01b6bd;
  --accent-green: #45df86;
  --header-bg: #eef1f4;
  --header-muted: #4a5a72;
  --border: #2b3a52;
  --ok: #45df86;
  --error: #ff7b72;
  --over: #ffb454;
  --under: #45df86;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #1b2a44, var(--bg));
  color: var(--text);
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 0.75rem 1rem 1.25rem;
}

.app-header {
  margin: 0 -0.35rem 0.85rem;
  padding: 0.65rem 0.75rem 0.7rem;
  background: var(--header-bg);
  border: 1px solid #d5dce8;
  border-radius: 14px;
}

.app-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.brand-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 8px;
}

.brand-link h1 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
}

.brand-self {
  color: var(--navy);
}

.brand-ctrl {
  color: var(--accent);
}

.subtitle {
  margin: 0.35rem 0 0;
  color: var(--header-muted);
  font-size: 0.8rem;
  line-height: 1.3;
}

.profile-menu {
  position: relative;
  flex-shrink: 0;
}

.profile-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  overflow: hidden;
}

.profile-menu-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.profile-menu-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile-menu-icon {
  display: block;
}

.profile-menu-panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  z-index: 20;
  min-width: 12rem;
  padding: 0.75rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.profile-menu-name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.profile-menu-email,
.profile-menu-status {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.profile-menu-panel .secondary {
  width: 100%;
  margin-top: 0.65rem;
}

.profile-menu-hint {
  margin: 0.45rem 0 0;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--muted);
}

.app-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.55rem;
  margin-bottom: 0;
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  font-size: 0.8rem;
}

.nav-link.active {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(0, 115, 253, 0.15);
}

.nav-menu {
  position: relative;
  flex-shrink: 0;
}

.nav-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
}

.nav-menu-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.app-header .nav-menu-btn,
.app-header .profile-menu-btn {
  background: #fff;
  border-color: #c5ced9;
  color: var(--navy);
}

.app-header .nav-menu-btn:hover,
.app-header .profile-menu-btn:hover {
  border-color: var(--accent);
  color: var(--navy);
}

.nav-menu-panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  z-index: 20;
  min-width: 10rem;
  padding: 0.4rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-menu-link {
  color: var(--muted);
  text-decoration: none;
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  font-size: 0.9rem;
}

.nav-menu-link:hover,
.nav-menu-link.active {
  color: var(--text);
  background: rgba(0, 115, 253, 0.15);
}

.muted {
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.85rem;
  margin-bottom: 0.75rem;
}

.hidden {
  display: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
}

#meal-form .field:last-child,
#meal-form-dialog .field:last-child {
  margin-bottom: 0;
}

input[type="date"]:not(.meal-pill-date) {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #111827;
  color: var(--text);
  padding: 0.65rem 0.75rem;
}

textarea,
input[type="file"] {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #111827;
  color: var(--text);
  padding: 0.65rem 0.75rem;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  color: white;
}

button.primary:hover {
  background: var(--accent-hover);
}

button.secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  margin-top: 0.5rem;
}

button.danger {
  background: var(--error);
  color: #1a0a0a;
  font-weight: 700;
  width: 100%;
  letter-spacing: 0.01em;
}

button.danger:hover:not(:disabled) {
  filter: brightness(1.08);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.status {
  min-height: 1.25rem;
  margin-top: 0.75rem;
  color: var(--muted);
}

.status.ok {
  color: var(--ok);
}

.status.error {
  color: var(--error);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.55rem;
  gap: 0.75rem;
}

.section-header h2 {
  margin: 0;
  font-size: 1rem;
}

.section-header .secondary {
  margin-top: 0;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

.pillar-grid {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.pillar-card {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem;
  background: #111827;
}

.pillar-card:hover {
  border-color: var(--accent);
}

.pillar-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.pillar-role {
  color: var(--muted);
  font-size: 0.8rem;
}

.home-week-loading {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 3rem;
}

.loading-spinner {
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.nutrient-chip-compare {
  font-size: 0.85rem;
  min-width: 0;
  text-align: left;
}

.nutrient-chip-compare.muted {
  color: var(--muted);
}

.goals-banner {
  display: block;
  margin: 0.75rem 0;
  padding: 0.55rem 0.7rem;
  border-left: 3px solid var(--over);
  background: rgba(255, 180, 84, 0.1);
  border-radius: 0 8px 8px 0;
  font-size: 0.9rem;
}

.goals-form select,
.goals-form input[type="number"],
.goals-form input[type="text"] {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #111827;
  color: var(--text);
  padding: 0.65rem 0.75rem;
}

.field-hint {
  color: var(--muted);
  font-size: 0.75rem;
}

.checkbox-field {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.checkbox-field input {
  width: auto;
}

.goals-preview {
  margin: 0.5rem 0 0.9rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #111827;
}

.goals-macros {
  margin: 0.75rem 0 1rem;
  padding: 0.75rem 0 0;
  border: none;
  border-top: 1px solid var(--border);
}

.goals-macros legend {
  padding: 0;
  font-weight: 600;
}

.goals-macro-batch {
  margin: 0.5rem 0 0.75rem;
}

.goals-macro-field {
  margin-bottom: 0.75rem;
}

.goals-macro-suggest {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
}

.bmi-badge {
  display: inline-block;
  margin-left: 0.25rem;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  text-transform: capitalize;
}

.bmi-underweight {
  color: var(--accent-teal);
}

.bmi-normal {
  color: var(--accent-green);
}

.bmi-overweight {
  color: var(--over);
}

.bmi-obese {
  color: var(--error);
}

button.inline-action,
.inline-action {
  margin-top: 0;
  margin-left: 0.35rem;
  padding: 0.25rem 0.55rem;
  font-size: 0.8rem;
}

.day-navigator {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.day-chrome {
  padding-top: 0.65rem;
  padding-bottom: 0.65rem;
}

.day-navigator .secondary {
  margin-top: 0;
  padding: 0.4rem 0.65rem;
}

.day-navigator-label {
  display: flex;
  flex-direction: column;
  min-width: 7rem;
  flex: 1;
}

.daily-summary-compact {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
}

.daily-summary-compact.is-expanded {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 640px) {
  .daily-summary-compact.is-expanded {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.summary-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  min-width: 0;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #111827;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

.summary-chip-label {
  color: var(--muted);
  font-size: 0.72rem;
}

.summary-chip-metrics {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.55rem;
  width: 100%;
}

.nutrient-value {
  display: inline-flex;
  align-items: baseline;
  gap: 0.2rem;
  font-variant-numeric: tabular-nums;
}

.summary-chip .nutrient-value {
  font-size: 0.92rem;
}

.nutrient-number {
  font-weight: 600;
  color: var(--text);
}

/* Judged % must beat .nutrient-number { color: var(--text) }. */
.delta.over .nutrient-number,
.delta.under .nutrient-number,
.delta.even .nutrient-number {
  color: inherit;
}

.nutrient-unit {
  font-size: 0.72em;
  font-weight: 500;
  color: var(--muted);
}

.delta {
  display: inline-flex;
  align-items: baseline;
  gap: 0.15rem;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 4.5rem;
}

.delta.over {
  color: var(--over);
}

.delta.under {
  color: var(--under);
}

.delta.even {
  color: var(--muted);
}

.summary-chip .delta {
  min-width: 0;
  text-align: left;
  font-size: 0.85rem;
}

.meals-table-wrap {
  overflow-x: auto;
}

.meals-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.meals-table th,
.meals-table td {
  text-align: left;
  padding: 0.55rem 0.35rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.meals-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
}

.meals-table-row:hover {
  background: rgba(0, 115, 253, 0.08);
}

.meals-table-link {
  color: inherit;
  text-decoration: none;
}

.meals-table-link:hover {
  color: var(--accent-hover);
}

.meals-table-desc {
  display: block;
  max-width: 10rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.text-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meals-table-thumb-col {
  width: 1.75rem;
}

.meals-table-thumb-placeholder {
  color: var(--muted);
  font-size: 0.85rem;
}

.meal-meta,
.meal-note {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
}

.clarifying-question {
  display: block;
  margin: 0.65rem 0 0;
  padding: 0.55rem 0.7rem;
  border-left: 3px solid var(--accent);
  background: rgba(0, 115, 253, 0.1);
  border-radius: 0 8px 8px 0;
  font-size: 0.9rem;
}

.refinement-history {
  margin: 0.5rem 0 0;
  padding-left: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.8rem;
}

.refinement-history-details {
  margin-top: 0.85rem;
}

.refinement-history-summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  user-select: none;
}

.refinement-history-details[open] .refinement-history-summary {
  margin-bottom: 0.35rem;
}

.refinement-history-item {
  margin-top: 0.55rem;
  padding: 0.45rem 0.65rem;
  border-left: 3px solid var(--border);
  background: rgba(15, 20, 25, 0.35);
  border-radius: 0 8px 8px 0;
}

.refinement-history-item:first-child {
  margin-top: 0;
}

.refinement-history-meta {
  display: block;
  font-size: 0.75rem;
  margin-bottom: 0.2rem;
}

.refinement-history-question,
.refinement-history-answer {
  margin: 0.15rem 0 0;
  color: var(--text);
  font-size: 0.85rem;
}

.refinement-history-question {
  color: var(--muted);
}

.refine-form {
  margin-top: 0.75rem;
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

.composer-row textarea {
  flex: 1;
  min-width: 0;
  margin: 0;
}

.composer-submit {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border-radius: 10px;
  background: var(--accent);
  color: white;
}

.composer-submit:hover:not(:disabled) {
  background: var(--accent-hover);
}

.composer-submit:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.composer-submit-icon {
  width: 1.25rem;
  height: 1.25rem;
  display: block;
}

.composer-submit-spinner {
  width: 1.15rem;
  height: 1.15rem;
  border-color: rgba(255, 255, 255, 0.35);
  border-top-color: white;
}

.app-dialog {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem 1.15rem;
  background: var(--card);
  color: var(--text);
  max-width: min(22rem, calc(100vw - 2rem));
}

.app-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.app-dialog-title {
  margin: 0 0 0.45rem;
  font-size: 1.05rem;
}

.app-dialog-body {
  margin: 0 0 1rem;
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
}

.app-dialog-actions .primary {
  margin: 0;
  min-width: 4.5rem;
}

.photo-picker-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.photo-picker-actions .secondary {
  margin-top: 0;
  flex: 1;
  min-width: 6.5rem;
}

.photo-picker-actions .secondary[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.photo-picker-file {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

.photo-picker-file .secondary {
  margin-top: 0;
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

.photo-picker-preview {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.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;
}

.meal-edit-header {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: -0.85rem -0.85rem 0.45rem;
  padding: 0.65rem 0.85rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.secondary-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.secondary-link:hover {
  color: var(--accent-hover);
}

.meal-edit-top {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.meal-edit-thumb {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
  flex-shrink: 0;
  background: #111827;
}

.meal-edit-thumb-empty {
  background: #111827;
}

.meal-edit-intro {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.meal-edit-meta-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.meal-edit-intro h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.3;
}

.meal-pill-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.meal-pill-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  margin: 0;
  padding: 0.35rem 1.7rem 0.35rem 0.75rem;
  font-size: 0.84rem;
  font-family: inherit;
  font-weight: 500;
  line-height: 1.2;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 70%, #000);
  color: var(--text);
  cursor: pointer;
  box-sizing: border-box;
}

.meal-pill-select:hover:not(:disabled) {
  border-color: var(--accent);
}

.meal-pill-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.meal-pill-arrow {
  position: absolute;
  right: 0.6rem;
  pointer-events: none;
  font-size: 0.68rem;
  color: var(--muted);
}

.meal-pill-date {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  display: inline-flex;
  align-items: center;
  width: auto;
  max-width: fit-content;
  margin: 0;
  padding: 0.35rem 0.75rem;
  font-size: 0.84rem;
  font-family: inherit;
  font-weight: 500;
  line-height: 1.2;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 70%, #000);
  color: var(--text);
  color-scheme: dark;
  cursor: pointer;
  box-sizing: border-box;
}

.meal-pill-date:hover:not(:disabled) {
  border-color: var(--accent);
}

.meal-pill-date:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.meal-pill-date::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
  filter: invert(0.8);
  margin-left: 0.35rem;
  padding: 0;
}

.meal-confidence-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.2;
  text-transform: capitalize;
  box-sizing: border-box;
}

.meal-confidence-high {
  border: 1px solid rgba(69, 223, 134, 0.4);
  background: rgba(69, 223, 134, 0.12);
  color: var(--accent-green);
}

.meal-confidence-medium {
  border: 1px solid rgba(255, 180, 84, 0.4);
  background: rgba(255, 180, 84, 0.12);
  color: var(--over);
}

.meal-confidence-low,
.meal-confidence-error {
  border: 1px solid rgba(255, 123, 114, 0.4);
  background: rgba(255, 123, 114, 0.12);
  color: var(--error);
}

.meal-edit-danger {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid color-mix(in srgb, var(--error) 45%, var(--border));
}

.meal-edit-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 1rem -0.85rem -0.85rem;
  padding: 0.75rem 0.85rem;
  background: var(--card);
  border-top: 1px solid var(--border);
}

.meal-edit-add-another {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.meal-edit-add-label {
  color: var(--muted);
  font-size: 0.85rem;
}

.meal-edit-actions .primary {
  margin: 0;
}

.meal-group-control {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  border: 0;
  min-inline-size: 0;
}

.meal-group-control .secondary {
  margin: 0;
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
}

.meal-group-control .secondary[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.meal-groups {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.meal-group-section {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.65rem 0.7rem;
  background: #111827;
}

.meal-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.meal-group-header h3 {
  margin: 0;
  font-size: 0.95rem;
}

.meal-group-ingest {
  display: flex;
  gap: 0.25rem;
}

.meal-group-ingest-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  padding: 0;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
}

.meal-group-ingest-btn:hover {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
}

.meal-group-ingest-btn svg {
  width: 1.15rem;
  height: 1.15rem;
}

.meal-group-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.meal-group-row {
  display: grid;
  grid-template-columns: 1.25rem 1fr auto;
  gap: 0.4rem;
  align-items: center;
  padding: 0.35rem 0;
  color: inherit;
  text-decoration: none;
  border-top: 1px solid var(--border);
}

.meal-group-row-desc {
  min-width: 0;
}

.meal-form-dialog-header {
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.meal-form-dialog-header .app-dialog-title {
  margin: 0;
}

.meal-form-dialog-header .secondary {
  margin: 0;
  padding: 0.35rem 0.65rem;
}

.meal-macro-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
  margin: 0 0 0.75rem;
  padding: 0;
}

.meal-macro-grid > div {
  background: #111827;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.45rem;
}

.meal-macro-grid dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.2;
}

.meal-macro-grid dd {
  margin: 0.1rem 0 0;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

@media (max-width: 480px) {
  .meal-macro-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .daily-summary-compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Perspective Page Styles */
.perspective-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.perspective-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.segmented-control {
  display: inline-flex;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #111827;
  padding: 0.2rem;
  gap: 0.2rem;
}

.segmented-btn {
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.segmented-btn:hover {
  color: var(--text);
}

.segmented-btn.active {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.perspective-mode-control {
  margin-bottom: 0.75rem;
  display: flex;
  overflow-x: auto;
}

.perspective-chart-card {
  padding: 1rem 0.85rem 0.85rem;
}

.perspective-chart-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.perspective-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.perspective-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.perspective-legend-color {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.perspective-legend-target-line {
  width: 14px;
  height: 2px;
  border-top: 2px dashed var(--over);
}

.perspective-bars-wrap {
  position: relative;
  height: 190px;
  margin: 0.5rem 0 0.25rem;
  border-bottom: 1px solid var(--border);
}

.perspective-target-indicator {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 2px dashed var(--over);
  z-index: 1;
  pointer-events: none;
  opacity: 0.85;
}

.perspective-bars-track {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-end;
  gap: 0.25rem;
  justify-content: space-between;
}

.perspective-bar-col {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  position: relative;
  min-width: 0;
}

.perspective-bar-stack {
  width: 100%;
  max-width: 28px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-radius: 4px 4px 0 0;
  overflow: hidden;
  position: relative;
}

.perspective-bar-col.selected .perspective-bar-stack {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.perspective-bar-segment {
  width: 100%;
  transition: height 0.2s ease;
}

.color-calories {
  background: var(--accent);
}

.color-protein {
  background: #0073fd;
}

.color-carbs {
  background: #01b6bd;
}

.color-fat {
  background: #011944;
  border-top: 1px solid #1a3a6c;
}

.color-other {
  background: #6b7280;
}

.perspective-bar-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.65rem;
  line-height: 1.1;
  color: var(--muted);
  margin-top: 0.35rem;
}

.perspective-bar-weekday {
  font-weight: 500;
}

.perspective-bar-date {
  font-size: 0.6rem;
  opacity: 0.75;
}

.perspective-bar-col.selected .perspective-bar-label {
  color: var(--accent);
  font-weight: 700;
}

.perspective-day-details {
  margin-top: 0.75rem;
  background: #111827;
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
}

.perspective-day-details h3 {
  margin: 0;
  font-size: 0.95rem;
}

.perspective-day-kcal {
  font-size: 1.25rem;
  font-weight: 600;
}

.perspective-macro-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin-top: 0.65rem;
}

.perspective-macro-box {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.perspective-macro-box .macro-label {
  font-size: 0.68rem;
  color: var(--muted);
}

.perspective-macro-box .macro-sub {
  font-size: 0.68rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.perspective-secondary-row {
  display: flex;
  gap: 1rem;
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
}

.perspective-secondary-item {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
}

.perspective-secondary-item .secondary-label {
  color: var(--muted);
}
