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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #ffffff;
  color: #1a1d3b;
  max-width: 480px;
  margin: 0 auto;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.app-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ===== HEADER ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 20px 16px;
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.app-header button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.header-icon {
  width: 24px;
  height: 24px;
  color: #8e92a4;
}

.app-title {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 3px;
  color: #1a1d3b;
}

.header-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

/* ===== DAY SELECTOR ===== */
.day-selector {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 8px;
  background: #fff;
  overflow: hidden;
  max-width: 100%;
}

.day-nav-btn {
  background: #f0f1f5;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  padding: 6px 8px 10px;
  color: #4a4d65;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.15s;
}
.day-nav-btn:active {
  background: #e0e2ea;
}

.days-strip {
  display: flex;
  gap: 2px;
  flex: 1;
  justify-content: space-around;
  min-width: 0;
  overflow: hidden;
}

.day-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 12px;
  transition: all 0.2s;
  min-height: 58px;
  min-width: 0;
}

.day-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: #8e92a4;
  text-transform: uppercase;
}

.day-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #4a4d65;
  transition: all 0.2s;
}

.day-item.selected {
  background: #34c759;
  border-radius: 12px;
}

.day-item.selected .day-label {
  color: #fff;
}

.day-item.selected .day-number {
  color: #fff;
  font-weight: 700;
}

.day-today-label {
  font-size: 0.5rem;
  font-weight: 700;
  color: #34c759;
  margin-top: -8px;
  letter-spacing: 0.02em;
}

.day-item.selected .day-today-label {
  color: #fff;
}

/* ===== NUTRITION SUMMARY ===== */
.nutrition-summary {
  background: #fff;
  padding: 6px 12px 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

/* Calories horizontal progress bar */
.cal-bar-wrap {
  grid-column: 1 / -1;
  background: #fff;
  border-radius: 12px;
  padding: 6px 0;
}
.cal-bar-row-flex {
  display: flex;
  align-items: center;
  gap: 10px;
}
.daily-radar-wrap {
  flex-shrink: 0;
  cursor: pointer;
}
.daily-radar-wrap .meal-radar {
  width: 40px;
  height: 40px;
}
.cal-bar-content {
  flex: 1;
  min-width: 0;
}
.cal-bar-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.cal-bar-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #8e92a4;
  letter-spacing: 0.5px;
}
.cal-bar-status {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1a1d3b;
}
.cal-bar-track {
  width: 100%;
  height: 10px;
  background: #f0f1f5;
  border-radius: 5px;
  overflow: hidden;
}
.cal-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.4s ease, background 0.3s ease;
}
.cal-bar-bottom {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
}
.cal-bar-eaten {
  font-size: 0.75rem;
  color: #8e92a4;
}
.cal-bar-pct {
  font-size: 0.75rem;
  font-weight: 600;
  color: #8e92a4;
}

.meal-nutrition-summary {
  padding: 8px 0;
  gap: 6px;
}

.meal-nutrition-summary .nutrient-card {
  border-radius: 10px;
  padding: 2px;
}

.meal-nutrition-summary .nc-inner {
  border-radius: 8px;
  padding: 6px 4px;
}

.meal-nutrition-summary .nc-name {
  font-size: 0.5rem;
}

.meal-nutrition-summary .nc-hero {
  font-size: 0.8rem;
}

.meal-nutrition-summary .nc-sub {
  font-size: 0.55rem;
}

.nutrient-card {
  border-radius: 14px;
  padding: 3px;
}

.nc-inner {
  background: #fff;
  border-radius: 11px;
  padding: 12px 8px 10px;
  text-align: center;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
}

.nc-name {
  font-size: 0.6rem;
  font-weight: 700;
  color: #8e92a4;
  letter-spacing: 0.5px;
}

.nc-hero {
  font-size: 1.1rem;
  font-weight: 800;
  color: #1a1d3b;
  line-height: 1;
}

.nc-sub {
  font-size: 0.65rem;
  font-weight: 500;
  color: #aab0c0;
}

.nc-check {
  color: #34c759;
  font-size: 0.55rem;
}

/* Card-level color overrides */
.nc-card-red .nc-name,
.nc-card-red .nc-hero,
.nc-card-red .nc-sub {
  color: #ff3b30;
}

.nc-card-green .nc-name,
.nc-card-green .nc-hero,
.nc-card-green .nc-sub,
.nc-card-green .nc-check {
  color: #34c759;
}

/* ===== NEW ITEM HIGHLIGHT ===== */
@keyframes greenBlink {
  0%, 49% { background-color: #a8f0c0; }
  50%, 100% { background-color: #fff; }
}
.food-item-wrapper.newly-added {
  animation: greenBlink 0.25s ease-in-out 3;
}
.food-item-wrapper.newly-added .food-item {
  background: transparent;
}
.food-group-header-wrapper.newly-added {
  animation: greenBlink 0.25s ease-in-out 3;
}

/* ===== MEAL SECTIONS ===== */
.meal-section {
  background: #fff;
  margin: 8px 8px 0;
  padding: 16px 20px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

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

.meal-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.meal-radar {
  flex-shrink: 0;
}

.meal-cal-card {
  display: inline-flex;
  padding: 2px;
  border-radius: 8px;
  /* background is set inline via conic-gradient */
}
.meal-cal-inner {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  background: #fff;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #007aff;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.meal-cal-unit {
  font-size: 0.6rem;
  font-weight: 500;
  color: #8e92a4;
  letter-spacing: 0;
}

.meal-add-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: #007aff;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* ===== MEAL ADD MODAL ===== */
.meal-add-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 900;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 120px;
}
.meal-add-overlay.active {
  display: flex;
}
.meal-add-modal {
  background: #fff;
  border-radius: 16px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  overflow: hidden;
}
.meal-add-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #eef0f5;
}
.meal-add-modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1a1d3b;
}
.meal-add-modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: #8e92a4;
  cursor: pointer;
}
.meal-add-modal-body {
  padding: 20px;
}
.meal-add-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.meal-add-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  background: #f8f8fc;
  border: 1px solid #ddd;
  border-radius: 12px;
  overflow: hidden;
}
.meal-add-input-wrap:focus-within {
  border-color: #007aff;
}
.meal-add-input {
  flex: 1;
  padding: 12px 40px 12px 14px;
  border: none;
  border-radius: 0;
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  outline: none;
  background: transparent;
}
.meal-add-input:focus {
  border-color: transparent;
}
.meal-add-input-wrap .input-thumbs {
  width: 100%;
  padding: 4px 10px 8px;
}
.meal-add-input-wrap .input-thumbs:empty {
  display: none;
  padding: 0;
}
.meal-add-camera {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: #8e92a4;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
}
.meal-add-camera:hover {
  color: #1a1d3b;
}
.meal-add-submit {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: #007aff;
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}
.meal-add-submit.disabled {
  background: #c7c7cc;
  cursor: default;
}
.meal-add-manual {
  font-size: 0.85rem;
  color: #8e92a4;
  cursor: pointer;
  text-align: center;
  padding: 12px 0 4px;
  margin-top: 12px;
  border-top: 1px solid #eee;
}
.meal-add-manual:hover {
  color: #1a1d3b;
}

.meal-modal-ac-dropdown {
  display: none;
  max-height: 250px;
  overflow-y: auto;
  border-top: 1px solid #eee;
  margin-top: 4px;
}
.meal-modal-ac-dropdown.active {
  display: block;
}

/* Spinning Dots Orb Animation */
.spinner-orb {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 0 20px;
}
.spinner-orb-wrapper {
  width: 56px;
  height: 56px;
  position: relative;
  animation: orb-spin 2.4s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}
.spinner-orb-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #007aff;
  top: 50%;
  left: 50%;
}
.spinner-orb-dot:nth-child(1) { transform: translate(-50%, -50%) rotate(0deg) translateY(-24px); opacity: 1; }
.spinner-orb-dot:nth-child(2) { transform: translate(-50%, -50%) rotate(45deg) translateY(-24px); opacity: 0.875; }
.spinner-orb-dot:nth-child(3) { transform: translate(-50%, -50%) rotate(90deg) translateY(-24px); opacity: 0.75; }
.spinner-orb-dot:nth-child(4) { transform: translate(-50%, -50%) rotate(135deg) translateY(-24px); opacity: 0.625; }
.spinner-orb-dot:nth-child(5) { transform: translate(-50%, -50%) rotate(180deg) translateY(-24px); opacity: 0.5; }
.spinner-orb-dot:nth-child(6) { transform: translate(-50%, -50%) rotate(225deg) translateY(-24px); opacity: 0.375; }
.spinner-orb-dot:nth-child(7) { transform: translate(-50%, -50%) rotate(270deg) translateY(-24px); opacity: 0.25; }
.spinner-orb-dot:nth-child(8) { transform: translate(-50%, -50%) rotate(315deg) translateY(-24px); opacity: 0.125; }

@keyframes orb-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.spinner-status {
  text-align: center;
  font-size: 0.8rem;
  color: #8e92a4;
  padding-bottom: 10px;
}

.meal-cal-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.meal-cal-track {
  flex: 1;
  height: 5px;
  background: #eef0f5;
  border-radius: 3px;
  overflow: hidden;
}
.meal-cal-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}
.meal-cal-label {
  font-size: 0.6rem;
  font-weight: 600;
  color: #8e92a4;
  white-space: nowrap;
}
.meal-bar-name {
  font-size: 0.6rem;
  font-weight: 600;
  color: #8e92a4;
  width: 40px;
  flex-shrink: 0;
}
.meal-macro-bars {
  margin-bottom: 8px;
}
.meal-macros-summary {
  font-size: 0.7rem;
  color: #8e92a4;
  margin-bottom: 8px;
}

.meal-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #007aff;
  flex-shrink: 0;
}

.meal-macros {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 75%;
}

.meal-macro-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.68rem;
  color: #8e92a4;
  font-weight: 500;
}

.meal-macro-sep {
  color: #ddd;
  font-size: 0.6rem;
}

.mini-donut {
  width: 16px;
  height: 16px;
  transform: rotate(-90deg);
  flex-shrink: 0;
}

.mini-donut .donut-bg {
  fill: none;
  stroke: #eef0f5;
  stroke-width: 3.5;
}

.mini-donut .donut-fill {
  fill: none;
  stroke-width: 3.5;
  stroke-linecap: round;
  transition: stroke-dasharray 0.4s ease;
}

.meal-items {
  min-height: 48px;
  padding: 4px 0;
}

.meal-empty {
  text-align: center;
  padding: 16px;
  font-size: 0.8rem;
  color: #ccd0dd;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.food-item {
  display: flex;
  align-items: center;
  padding: 8px 16px 8px 14px;
  border-radius: 8px;
  gap: 12px;
  cursor: grab;
  transition: opacity 0.2s, background 0.2s, transform 0.25s ease;
  background: #fff;
  position: relative;
  z-index: 1;
}

.food-item:active {
  cursor: grabbing;
}

.food-item.dragging {
  opacity: 0.4;
}

.food-item:last-child {
  border-bottom: none;
}

.meal-section.drag-over {
  background: #f0fdf4;
  outline: 2px dashed #34c759;
  outline-offset: -2px;
}

.food-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #eef0f5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

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

.food-name-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.food-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1a1d3b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.food-cal-inline {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1a1d3b;
  flex-shrink: 0;
  white-space: nowrap;
}

.food-meta {
  font-size: 0.65rem;
  color: #8e92a4;
  margin-top: 2px;
  text-transform: lowercase;
}

.food-calories {
  text-align: right;
  flex-shrink: 0;
}

.food-cal-num {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1a1d3b;
}

.food-cal-unit {
  font-size: 0.6rem;
  color: #8e92a4;
  margin-left: 2px;
}

.food-edit-btn {
  background: none;
  border: none;
  font-size: 0.85rem;
  color: #bbb;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
  flex-shrink: 0;
}

.food-edit-btn:hover {
  color: #2563eb;
}

.edit-icon-svg {
  width: 14px;
  height: 14px;
}

/* Food Groups */
.food-group {
  border-left: 3px solid #34c759;
  margin: 8px 8px;
  border-radius: 0 8px 8px 0;
  background: #f0faf2;
  overflow: hidden;
  padding-bottom: 0;
  transition: padding-bottom 0.2s ease;
}
.food-group:has(.food-group-items.expanded) {
  padding-bottom: 10px;
}

.food-group-header-wrapper {
  position: relative;
  overflow: hidden;
}

.food-group-actions {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: stretch;
  visibility: hidden;
}

.food-group-header-wrapper:has(.food-group-header.sliding) .food-group-actions {
  visibility: visible;
}

.food-group-header.sliding {
  transition: transform 0.25s ease;
  transform: translateX(-240px);
}

.food-group-header.sliding .food-group-edit-btn {
  visibility: hidden;
}

.food-group-header.slide-back {
  transition: transform 0.2s ease;
  transform: translateX(0);
}

.food-group:has(.food-group-header.sliding) .food-group-items {
  transition: transform 0.25s ease;
  transform: translateX(-240px);
}

.food-group:has(.food-group-header.slide-back) .food-group-items {
  transition: transform 0.2s ease;
  transform: translateX(0);
}

.food-group-header {
  display: flex;
  align-items: center;
  padding: 10px 16px 10px 12px;
  cursor: pointer;
  gap: 8px;
  user-select: none;
}

.food-group-header .chevron {
  font-size: 0.7rem;
  color: #34c759;
  transition: transform 0.2s;
  flex-shrink: 0;
  min-width: 32px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
}

.food-group-header.expanded .chevron {
  transform: rotate(90deg);
}

.food-group-header .group-info {
  flex: 1;
  min-width: 0;
}

.food-group-header .group-name-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.food-group-header .group-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1a1d3b;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-meta {
  font-size: 0.65rem;
  color: #8e92a4;
  text-transform: lowercase;
  margin-top: 2px;
}

.nf-readonly-banner {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffc107;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.75rem;
  margin-bottom: 10px;
  line-height: 1.4;
}

.food-group-header .group-cal {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1a1d3b;
  flex-shrink: 0;
}

.food-group-header .group-cal-unit {
  font-size: 0.6rem;
  color: #8e92a4;
  margin-left: 2px;
}

.food-group-items {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.food-group-items.expanded {
  max-height: 500px;
}

.food-group-items .food-item-wrapper {
  padding-left: 12px;
  border: none;
}

.food-group-items .food-item {
  padding-left: 8px;
}

.food-group-edit-btn {
  background: none;
  border: none;
  font-size: 0.85rem;
  color: #bbb;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
  flex-shrink: 0;
}

.food-group-edit-btn:hover {
  color: #2563eb;
}

.food-group.drag-over {
  background: #fff3b0;
  border-left-color: #ffcc00;
  box-shadow: inset 0 0 0 3px #ffcc00, 0 0 12px rgba(255,204,0,0.4);
}

.food-item.drag-target {
  background: #fff3b0 !important;
  box-shadow: inset 0 0 0 3px #ffcc00, 0 0 12px rgba(255,204,0,0.4);
  border-radius: 8px;
}

.drag-tooltip {
  position: fixed;
  background: #ffcc00;
  color: #1a1d3b;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  z-index: 10000;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  display: none;
}

/* Group Name Modal */
.group-name-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.group-name-modal.active {
  opacity: 1; pointer-events: auto;
}
.group-name-panel {
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  width: 90%; max-width: 340px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.group-name-title {
  font-size: 1rem;
  font-weight: 800;
  color: #1a1d3b;
  margin-bottom: 12px;
  text-align: center;
}
.group-name-foods {
  margin-bottom: 14px;
}
.group-name-food-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0;
  font-size: 0.8rem;
  color: #555;
  border-bottom: 1px solid #f0f0f0;
}
.group-name-food-item:last-child { border-bottom: none; }
.group-name-food-icon { font-size: 0.7rem; color: #34c759; }
.group-name-input {
  width: 100%; box-sizing: border-box;
  padding: 10px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 14px;
}
.group-name-input:focus { border-color: #34c759; }
.group-name-buttons { display: flex; gap: 10px; }
.group-name-btn {
  flex: 1; padding: 10px;
  border: none; border-radius: 8px;
  font-size: 0.85rem; font-weight: 700;
  font-family: 'Inter', sans-serif;
  cursor: pointer; transition: opacity 0.15s;
}
.group-name-btn:active { opacity: 0.7; }
.group-name-btn.cancel { background: #f0f0f0; color: #555; }
.group-name-btn.save { background: #34c759; color: #fff; }

/* Slide-to-delete */
.food-item-wrapper {
  position: relative;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin: 4px 8px;
}

.food-item-actions {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: stretch;
  visibility: hidden;
}

.food-item-wrapper:has(.food-item.sliding) .food-item-actions {
  visibility: visible;
}

.food-action-btn {
  border: none;
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0 16px;
  display: flex;
  align-items: center;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.food-action-cancel {
  background: #8e92a4;
  color: #fff;
}

.food-action-delete {
  background: #ff3b30;
  color: #fff;
}

.food-action-ai-edit {
  background: #5856d6;
  color: #fff;
}

.food-item.sliding {
  transition: transform 0.25s ease;
  transform: translateX(-240px);
}

.food-item.sliding .food-edit-btn {
  visibility: hidden;
}

.food-item.slide-back {
  transition: transform 0.2s ease;
  transform: translateX(0);
}

/* ===== BOTTOM INPUT BAR ===== */
.bottom-bar {
  background: transparent;
  padding: 12px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.food-input-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  border: none;
  border-radius: 16px;
  background: #fff;
  transition: box-shadow 0.2s;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
  z-index: 201;
  min-height: 48px;
}
.food-input-wrapper:focus-within {
  box-shadow: 0 2px 8px rgba(52,199,89,0.25), 0 1px 3px rgba(0,0,0,0.1);
}

.input-thumbs {
  display: flex;
  gap: 8px;
  padding: 8px 10px 0;
  flex-wrap: wrap;
}
.input-thumbs:empty {
  display: none;
}
.input-thumb-wrap {
  position: relative;
  width: 56px; height: 56px;
  border-radius: 8px;
  overflow: visible;
}
.input-thumb-wrap img {
  width: 56px; height: 56px;
  object-fit: cover;
  border-radius: 8px;
}
.input-thumb-remove {
  position: absolute;
  top: -6px; right: -6px;
  width: 20px; height: 20px;
  background: #fff;
  border: 1.5px solid #ddd;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: #777;
  cursor: pointer;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  z-index: 1;
}
.input-thumb-remove:active {
  background: #f0f0f0;
}

.input-row {
  display: flex;
  align-items: center;
  min-height: 48px;
}

.food-input {
  flex: 1;
  padding: 12px 10px;
  border: none;
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  background: transparent;
  color: #1a1d3b;
  outline: none;
}

.input-attach-btn {
  background: #eef0f5;
  border: none;
  cursor: pointer;
  padding: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 7px;
  transition: background 0.15s;
}
.input-attach-btn:active {
  background: #dde0e8;
}
.input-attach-btn svg {
  width: 18px;
  height: 18px;
  color: #8e92a4;
}

.food-input:focus {
  border-color: #34c759;
}

.food-input::placeholder {
  color: #b8bcc8;
}

/* Autocomplete dropdown */
.autocomplete-dropdown {
  display: none;
  background: #fff;
  border-top: 1px solid #eef0f5;
  max-height: 200px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.autocomplete-dropdown.active {
  display: block;
}

.ac-item {
  display: flex;
  flex-direction: column;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid #e0e0e0;
  transition: background 0.15s;
}

.ac-item:hover, .ac-item:active {
  background: #ffffff;
}

.ac-item-row1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ac-item-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1a1d3b;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ac-item-add {
  background: #34c759;
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 28px;
  height: 28px;
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ac-item-row2 {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.ac-item-meta {
  font-size: 0.7rem;
  color: #8e92a4;
  margin-left: 12px;
  white-space: nowrap;
}

.ac-item.ac-group {
  border-left: 3px solid #34c759;
  background: #fafbfc;
}
.ac-item.ac-group:hover, .ac-item.ac-group:active {
  background: #f0faf2;
}
.ac-group-icon {
  font-size: 0.75rem;
  margin-right: 4px;
}
.ac-group-meta {
  font-size: 0.65rem;
  color: #8e92a4;
  margin-top: 2px;
}

.add-btn {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: #ccc;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
  z-index: 201;
}

.add-btn.active {
  background: #34c759;
  cursor: pointer;
  pointer-events: auto;
}

.add-btn.active:hover {
  background: #2fb34d;
}

.add-btn.loading {
  background: #8e92a4;
  pointer-events: none;
}

.add-btn .spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.manual-add-btn {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: #fff;
  border: none;
  color: #8e92a4;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
  z-index: 201;
}

.manual-add-btn:hover {
  background: #ddd;
}

.media-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #eef0f5;
  border: none;
  color: #666;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.media-btn:hover {
  background: #ddd;
}

.bottom-bar-wrapper {
  display: none;
  flex-shrink: 0;
  max-width: 480px;
  margin: 0 auto;
  z-index: 200;
  width: 100%;
}

.image-preview-bar {
  display: none;
  padding: 8px 16px;
  background: #fff;
  border-top: 1px solid #eef0f5;
  align-items: center;
  gap: 8px;
}

.image-preview-bar.active {
  display: flex;
}

.preview-thumb {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: cover;
  border: 2px solid #34c759;
}

.preview-label {
  flex: 1;
  font-size: 0.75rem;
  color: #8e92a4;
}

.preview-remove {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #ff3b30;
  padding: 4px;
}

.food-thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 440px;
  width: calc(100% - 40px);
  background: #1a7a3a;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
}

/* ===== MANAGE GOALS SCREEN ===== */
.goals-screen {
  display: none;
  position: fixed;
  inset: 0;
  background: #ffffff;
  z-index: 300;
  max-width: 480px;
  margin: 0 auto;
  overflow-y: auto;
}

.goals-screen.active {
  display: block;
}

.goals-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: #fff;
  border-bottom: 1px solid #eef0f5;
  position: sticky;
  top: 0;
  z-index: 10;
}

.screen-back-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
}
.screen-back-btn svg {
  width: 22px;
  height: 22px;
  stroke: #1a1d3b;
}

.goals-title {
  font-size: 1.1rem;
  font-weight: 700;
  flex: 1;
}

.goals-save-btn {
  padding: 6px 16px;
  border-radius: 8px;
  border: none;
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: default;
  background: #ccc;
  color: #fff;
  pointer-events: none;
  transition: background 0.2s;
}
.goals-save-btn.active {
  background: #34c759;
  cursor: pointer;
  pointer-events: auto;
}
.goals-save-btn.active:active {
  background: #2fb34d;
}

.goals-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #8e92a4;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 20px 20px 12px;
  border-bottom: 1px solid #eef0f5;
}
.goals-section-label-sub {
  margin-top: 8px;
  font-size: 0.65rem;
}

.goal-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px 22px;
  background: #fff;
  margin: 8px 12px;
  border-radius: 12px;
  border: 1px solid #eef0f5;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.goal-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1a1d3b;
  white-space: nowrap;
}

.goal-spacer {
  flex: 1;
}

.goal-toggles {
  display: flex;
  align-items: center;
  gap: 6px;
}

.goal-mode-toggle {
  font-size: 0.65rem;
  font-weight: 700;
  border: none;
  border-radius: 6px;
  padding: 3px 0;
  width: 60px;
  text-align: center;
  cursor: pointer;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.goal-mode-toggle.goal {
  background: #e8f5e9;
  color: #2e7d32;
}
.goal-mode-toggle.limit {
  background: #fff3e0;
  color: #e65100;
}

.goal-controls {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.goal-input-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.goal-input {
  width: 90px;
  text-align: right;
  font-size: 1.2rem;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  border: 1px solid #e8eaf0;
  background: #f0f1f5;
  border-radius: 8px;
  padding: 4px 8px;
  color: #1a1d3b;
  outline: none;
  -moz-appearance: textfield;
}
.goal-input::-webkit-outer-spin-button,
.goal-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.goal-input:focus {
  border-color: #34c759;
  background: #fff;
}

.goal-unit {
  font-size: 0.8rem;
  color: #8e92a4;
  width: 20px;
  padding-top: 6px;
}

.goal-kcal-est {
  font-size: 0.6rem;
  color: #8e92a4;
  font-style: italic;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
}

/* Toggle switch */
.goal-switch {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: #ddd;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
  margin-right: 6px;
}
.goal-switch.on {
  background: #34c759;
}
.goal-switch-knob {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.goal-switch.on .goal-switch-knob {
  transform: translateX(16px);
}

/* Emoji toggle checkboxes */
.goal-emoji-toggles {
  display: flex;
  gap: 4px;
  margin-right: 8px;
  flex-shrink: 0;
}
.goal-emoji-toggle {
  font-size: 18px;
  cursor: pointer;
  opacity: 0.25;
  filter: grayscale(1);
  transition: opacity 0.2s, filter 0.2s;
  user-select: none;
  -webkit-user-select: none;
  line-height: 1;
  padding: 2px;
}
.goal-emoji-toggle.active {
  opacity: 1;
  filter: none;
}

/* Disabled row */
.goal-row-parent {
  margin-bottom: 0;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: none;
}
.goal-row-sub {
  margin-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-top: 1px dashed #dde0e8;
  padding-left: 36px;
  padding-top: 10px;
  padding-bottom: 18px;
}
.goal-row-sub-mid {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: none;
  margin-bottom: 0;
}
.goal-row-disabled .goal-name {
  color: #bbb;
}
.goal-row-disabled .goal-mode-toggle {
  background: #eee !important;
  color: #bbb !important;
}
.goal-row-disabled .goal-input {
  color: #bbb;
}
.goal-row-disabled .goal-unit {
  color: #ccc;
}
.goal-meal-targets-disabled .meal-target-label {
  color: #ccc !important;
}
.goal-meal-targets-disabled .meal-target-input {
  color: #bbb;
}
.goal-meal-targets-disabled .meal-target-unit {
  color: #ccc;
}
.goal-meal-targets-disabled .goal-kcal-est {
  color: #ccc;
}

/* Advanced mode toggle */
.advanced-mode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: #fff;
  border-bottom: 1px solid #eef0f5;
}
.advanced-mode-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #1a1d3b;
}
.advanced-mode-desc {
  font-size: 0.6rem;
  color: #8e92a4;
  margin-top: 2px;
}
.toggle-switch {
  width: 46px; height: 26px;
  background: #ccc;
  border-radius: 13px;
  position: relative;
  cursor: pointer;
  border: none;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle-switch.on {
  background: #34c759;
}
.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch.on::after {
  transform: translateX(20px);
}

/* Per-meal sub-targets */
.goal-meal-targets {
  background: #fafbfc;
  padding: 4px 20px 12px 20px;
  margin: 0 12px 0;
  border: 1px solid #eef0f5;
  border-top: none;
  border-radius: 0 0 12px 12px;
  margin-top: -12px;
}
.meal-target-row {
  display: flex;
  align-items: center;
  padding: 6px 0;
  gap: 6px;
}
.meal-target-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #8e92a4;
  flex-shrink: 0;
  white-space: nowrap;
}
.meal-target-input-wrap {
  margin-left: auto;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.meal-target-input-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.meal-target-input {
  width: 65px;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  border: 1px solid #e8eaf0;
  border-radius: 6px;
  background: #f0f1f5;
  color: #1a1d3b;
  outline: none;
  padding: 4px 6px;
  -moz-appearance: textfield;
}
.meal-target-input::-webkit-outer-spin-button,
.meal-target-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.meal-target-input:focus {
  border-color: #34c759;
  background: #fff;
}
.meal-target-unit {
  font-size: 0.7rem;
  color: #8e92a4;
  padding-top: 5px;
  width: 20px;
}

/* Per-meal progress on main page */
.meal-progress-rows {
  padding: 0 0 4px;
}
.meal-progress-row {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  padding: 2px 0;
  gap: 6px;
}
.meal-progress-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  justify-self: center;
}
.meal-progress-bar {
  height: 3px;
  background: #eef0f5;
  border-radius: 2px;
  overflow: hidden;
}
.meal-progress-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}
.meal-progress-label {
  font-size: 0.55rem;
  color: #8e92a4;
  white-space: nowrap;
  font-weight: 600;
}

.commit-btn {
  margin: 32px 20px;
  padding: 16px;
  width: calc(100% - 40px);
  background: #1a1d3b;
  color: #fff;
  border: none;
  border-radius: 16px;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s;
}

.commit-btn:hover {
  background: #2a2d4b;
}

/* ===== CUSTOM MEALS SETTINGS ===== */
.custom-meals-list {
  padding: 0 16px;
}
.custom-meal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
  transition: opacity 0.15s;
}
.custom-meal-row.meal-dragging {
  opacity: 0.4;
}
.custom-meal-row.meal-drag-over {
  border-top: 2px solid #5856d6;
}
.custom-meal-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.custom-meal-grip {
  cursor: grab;
  padding: 4px 6px;
  display: flex;
  align-items: center;
}
.custom-meal-grip:active {
  cursor: grabbing;
}
.custom-meal-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.custom-meal-name-input {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.85rem;
  flex: 1;
  min-width: 0;
  color: #1a1d3b;
}
.custom-meal-name-input:focus {
  outline: none;
  border-color: #5856d6;
}
.custom-meal-delete {
  background: none;
  border: none;
  color: #ff3b30;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
}
.custom-meal-delete:disabled {
  opacity: 0.2;
  cursor: default;
}
.custom-meal-add-btn {
  display: block;
  width: calc(100% - 32px);
  margin: 10px 16px 16px;
  padding: 10px;
  background: #f0f0f5;
  border: 1px dashed #ccc;
  border-radius: 8px;
  color: #5856d6;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.custom-meal-add-btn:hover {
  background: #e8e8f0;
}

/* ===== ORPHANED MEALS SECTION ===== */
.orphaned-section {
  border: 2px dashed #ff9500;
  background: #fffbf0;
}
.orphaned-header .meal-title {
  color: #ff9500 !important;
  font-size: 0.8rem;
}

/* ===== DELETE MEAL CONFIRMATION MODAL ===== */
.delete-meal-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 9999;
  justify-content: center;
  align-items: center;
}
.delete-meal-modal-overlay.active {
  display: flex;
}
.delete-meal-modal {
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  width: min(90%, 340px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}
.delete-meal-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a1d3b;
  margin-bottom: 12px;
}
.delete-meal-modal-body {
  font-size: 0.85rem;
  color: #555;
  line-height: 1.5;
}
.delete-meal-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: flex-end;
}
.delete-meal-cancel-btn {
  padding: 8px 18px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #f5f5f5;
  color: #333;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.delete-meal-confirm-btn {
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  background: #ff3b30;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.goals-footer {
  text-align: center;
  font-size: 0.7rem;
  color: #b8bcc8;
  padding: 0 20px 24px;
}

/* ===== LOGIN OVERLAY ===== */
#login-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 500;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

#login-overlay.active {
  display: flex;
}

#login-overlay h2 {
  color: #fff;
  font-size: 1.2rem;
  margin-bottom: 20px;
}

#login-error {
  color: #ff3b30;
  font-size: 0.8rem;
  margin-top: 12px;
  display: none;
}

/* ===== ADD FOOD MODAL ===== */
.add-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 400;
  align-items: flex-end;
  justify-content: center;
}

.add-modal.active {
  display: flex;
}

.add-modal-content {
  background: #fff;
  width: 100%;
  max-width: 480px;
  border-radius: 20px 20px 0 0;
  padding: 24px 20px;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 20px;
  text-align: center;
}

.modal-field {
  margin-bottom: 16px;
}

.modal-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #8e92a4;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
  display: block;
}

.modal-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #eef0f5;
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  background: #ffffff;
  outline: none;
}

.modal-input:focus {
  border-color: #34c759;
}

.meal-select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #eef0f5;
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  background: #ffffff;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.modal-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.modal-cancel-btn {
  flex: 1;
  padding: 14px;
  background: #ffffff;
  border: none;
  border-radius: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: #8e92a4;
  cursor: pointer;
}

.modal-add-btn {
  flex: 1;
  padding: 14px;
  background: #34c759;
  border: none;
  border-radius: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}

.modal-add-btn:hover {
  background: #2fb34d;
}

/* ===== NUTRITION FACTS LABEL ===== */
.nf-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 400;
  align-items: flex-end;
  justify-content: center;
}

.nf-modal.active {
  display: flex;
}

.nf-panel {
  background: #fff;
  width: 100%;
  max-width: 480px;
  border-radius: 20px 20px 0 0;
  padding: 0;
  animation: slideUp 0.3s ease;
  max-height: 80vh;
  overflow-y: auto;
}

.nf-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 8px;
}

.nf-food-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: #1a1d3b;
  flex: 1;
  border: none;
  background: transparent;
  font-family: 'Inter', sans-serif;
  outline: none;
}

.nf-close-x {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #999;
  padding: 4px 0 4px 12px;
}

.nf-label-box {
  border: 2px solid #000;
  margin: 4px 20px 12px;
  padding: 8px 10px;
  background: #fff;
}

.nf-facts-title {
  font-size: 1.8rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.5px;
}

.nf-serving-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  padding: 2px 0 4px;
  border-bottom: none;
}

.nf-serving-size {
  font-weight: 700;
}

.nf-calories-row {
  display: grid;
  grid-template-columns: 1fr 95px 95px;
  gap: 4px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 4px solid #000;
}
.nf-calories-label {
  font-size: 1rem;
  font-weight: 900;
}
.nf-cal-input {
  width: 100%;
  text-align: right;
  border: none;
  font-size: 1.8rem;
  font-weight: 900;
  font-family: 'Inter', sans-serif;
  outline: none;
  background: #f0f0f4;
  border-radius: 6px;
  padding: 4px 8px;
  -moz-appearance: textfield;
}
.nf-cal-input::-webkit-outer-spin-button,
.nf-cal-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.nf-cal-total-box {
  min-width: 80px;
  text-align: right;
  font-size: 1.8rem;
  font-weight: 900;
  font-family: 'Inter', sans-serif;
  color: #2563eb;
  background: #edf1f8;
  border-radius: 6px;
  padding: 4px 8px;
}

/* ── DV header ── */
.nf-dv-header {
  display: grid;
  grid-template-columns: 1fr 95px 95px;
  gap: 4px;
  padding: 4px 0 2px;
  border-bottom: 1px solid #000;
}
.nf-dv-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  align-self: end;
}
.nf-col-hdr {
  font-size: 0.55rem;
  font-weight: 800;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: #1e293b;
  line-height: 1.3;
}
.nf-col-hdr-total {
  color: #2563eb;
  font-weight: 900;
}

/* ── Data rows ── */
.nf-row {
  display: grid;
  grid-template-columns: 1fr 95px 95px;
  gap: 4px;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid #ddd;
  font-size: 0.8rem;
}
.nf-row.thick-top { border-top: 8px solid #000; }
.nf-row-name { font-weight: 700; }
.nf-row-name.light { font-weight: 400; }
.nf-row.indented { padding-left: 16px; }
.nf-row.indented .nf-row-name { font-weight: 400; }

/* Per-serving column */
.nf-row-right {
  display: flex;
  align-items: center;
  gap: 3px;
  justify-content: flex-start;
}
.nf-input {
  width: 44px;
  text-align: right;
  border: none;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  outline: none;
  background: #f0f0f4;
  border-radius: 4px;
  padding: 3px 5px;
  -moz-appearance: textfield;
}
.nf-input::-webkit-outer-spin-button,
.nf-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.nf-unit {
  font-size: 0.7rem;
  color: #888;
  min-width: 18px;
  text-align: left;
}

/* Total-eaten column */
.nf-row-total-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
  justify-content: flex-start;
}
.nf-row-total {
  min-width: 36px;
  text-align: right;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  color: #2563eb;
  background: #edf1f8;
  border-radius: 4px;
  padding: 3px 5px;
}
.nf-unit-total {
  font-size: 0.7rem;
  color: #90a0c0;
  min-width: 18px;
  text-align: left;
}

.nf-qty-section {
  padding: 12px 20px 28px;
  background: #ffffff;
}

.nf-qty-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #8e92a4;
  margin-bottom: 8px;
}

.nf-qty-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}
.nf-total-cal {
  font-size: 0.85rem;
  font-weight: 600;
  color: #2563eb;
  white-space: nowrap;
  flex-shrink: 0;
}

.nf-qty-num {
  width: 70px;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 1rem;
  font-family: 'Inter', sans-serif;
  text-align: center;
  background: #fff;
  outline: none;
  -moz-appearance: textfield;
}

.nf-qty-num::-webkit-outer-spin-button,
.nf-qty-num::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.nf-qty-num:focus {
  border-color: #34c759;
}

.nf-qty-unit {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  background: #fff;
  outline: none;
  color: #1a1d3b;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%23666' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
}

.nf-qty-unit:focus {
  border-color: #34c759;
}

.nf-save-btn {
  width: 100%;
  padding: 14px;
  background: #34c759;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.nf-save-btn:hover {
  background: #2db84d;
}

.nf-bottom {
  padding: 16px 20px 32px;
}

.nf-qty-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.nf-qty-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: #8e92a4;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.nf-qty-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e5e5e5;
  border-radius: 12px;
  font-size: 1rem;
  font-family: 'Inter', sans-serif;
  background: #fff;
  outline: none;
}

.nf-qty-input:focus {
  border-color: #34c759;
}

.nf-update-btn {
  width: 100%;
  padding: 16px;
  background: #4066ff;
  border: none;
  border-radius: 14px;
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s;
}

.nf-update-btn:hover {
  background: #3355dd;
}

/* ===== ACCOUNT SCREEN ===== */
.account-screen {
  display: none;
  position: fixed;
  inset: 0;
  background: #ffffff;
  z-index: 300;
  max-width: 480px;
  margin: 0 auto;
  overflow-y: auto;
}

.account-screen.active {
  display: block;
}

.account-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: #fff;
  border-bottom: 1px solid #eef0f5;
  position: sticky;
  top: 0;
  z-index: 10;
}

.account-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.account-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 20px;
  background: #fff;
  margin-bottom: 8px;
}

.account-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 12px;
  border: 3px solid #34c759;
}

.account-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a1d3b;
}

.account-email {
  font-size: 0.8rem;
  color: #8e92a4;
  margin-top: 4px;
}

.account-section {
  background: #fff;
  margin-bottom: 8px;
}

.account-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #f0f1f5;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.account-item:hover {
  background: #f9f9fb;
}

.account-item:last-child {
  border-bottom: none;
}

.account-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-item-icon {
  font-size: 1.2rem;
  width: 32px;
  text-align: center;
}

.account-item-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1a1d3b;
}

.account-item-desc {
  font-size: 0.7rem;
  color: #8e92a4;
  margin-top: 2px;
}

.account-item-arrow {
  color: #ccc;
  font-size: 1.1rem;
}

.account-signout {
  margin: 24px 20px;
  padding: 14px;
  width: calc(100% - 40px);
  background: #fff;
  color: #ff3b30;
  border: 1px solid #ff3b30;
  border-radius: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.account-signout:hover {
  background: #ff3b30;
  color: #fff;
}

.export-loading {
  display: none;
  text-align: center;
  padding: 12px;
  font-size: 0.8rem;
  color: #8e92a4;
}

.export-loading.active {
  display: block;
}

/* ===== SAVED REPORTS ===== */
.saved-reports-header {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #8e92a4;
  padding: 16px 16px 8px;
}

.saved-report-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f2f8;
}

.saved-report-card:last-child {
  border-bottom: none;
}

.saved-report-info {
  flex: 1;
  min-width: 0;
}

.saved-report-range {
  font-size: 0.8rem;
  font-weight: 600;
  color: #1a1d3b;
}

.saved-report-created {
  font-size: 0.65rem;
  color: #8e92a4;
  margin-top: 2px;
}

.saved-report-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.saved-report-btn {
  border: none;
  background: none;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}

.saved-report-btn:active {
  background: #f0f2f8;
}

.delete-confirm-text {
  font-size: 0.75rem;
  font-weight: 600;
  color: #ff3b30;
}

.saved-report-btn.confirm-yes {
  font-size: 0.75rem;
  font-weight: 700;
  color: #ff3b30;
}

.saved-report-btn.confirm-no {
  font-size: 0.75rem;
  font-weight: 600;
  color: #8e92a4;
}

/* Report View Overlay */
.report-view-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 2000;
  flex-direction: column;
}

.report-view-overlay.active {
  display: flex;
}

.report-view-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid #e8ecf4;
  font-weight: 600;
  font-size: 1rem;
  color: #1a1d3b;
}

.report-view-close {
  border: none;
  background: #f0f2f8;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.report-view-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  -webkit-overflow-scrolling: touch;
}


.email-report-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(6px);
  z-index: 500;
  align-items: center;
  justify-content: center;
}
.email-report-overlay.active {
  display: flex;
}
.email-report-modal {
  background: #fff;
  border-radius: 20px;
  padding: 28px 24px;
  width: 90%;
  max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.email-report-modal h3 {
  margin: 0 0 20px;
  font-size: 1.1rem;
  text-align: center;
}
.email-report-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #8e92a4;
  display: block;
  margin-bottom: 6px;
}
.email-report-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #dde0e8;
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  background: #f7f8fc;
  appearance: auto;
  margin-bottom: 12px;
  box-sizing: border-box;
}
.email-custom-dates {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}
.email-date-row {
  flex: 1;
}
.email-date-row label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #8e92a4;
  display: block;
  margin-bottom: 4px;
}
.email-date-row input[type="date"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #dde0e8;
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  background: #f7f8fc;
  box-sizing: border-box;
}
.email-report-btn {
  width: 100%;
  padding: 12px;
  background: #007aff;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  font-family: 'Inter', sans-serif;
}
.email-report-btn:active {
  opacity: 0.85;
}

/* ===== FOOD HISTORY SCREEN ===== */
.history-screen {
  display: none;
  position: fixed;
  inset: 0;
  background: #ffffff;
  z-index: 300;
  max-width: 480px;
  margin: 0 auto;
  overflow-y: auto;
}
.history-screen.active { display: block; }

.history-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: #fff;
  border-bottom: 1px solid #eef0f5;
  position: sticky;
  top: 0;
  z-index: 10;
}
.history-title {
  font-size: 1.1rem;
  font-weight: 700;
  flex: 1;
}

.history-search-wrap {
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #eef0f5;
  position: sticky;
  top: 53px;
  z-index: 9;
}
.history-search {
  width: 100%;
  border: 1px solid #dde0ea;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  outline: none;
  background: #ffffff;
  box-sizing: border-box;
}
.history-search:focus {
  border-color: #34c759;
  background: #fff;
}

.history-list {
  padding: 0;
}

.history-date-sep {
  padding: 10px 20px 6px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #8e92a4;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: #ffffff;
}

.history-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid #f0f1f5;
  gap: 12px;
}

.history-item-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #eef0f5;
  flex-shrink: 0;
  object-fit: cover;
}

.history-item-info {
  flex: 1;
  min-width: 0;
}
.history-item-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1a1d3b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-item-meta {
  font-size: 0.7rem;
  color: #8e92a4;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.history-item-group-badge {
  background: #eef6ee;
  color: #34c759;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
}

.history-add-btn {
  background: #34c759;
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.history-add-btn:active {
  background: #2aa84a;
}

/* ===== HISTORY ADD MODAL ===== */
.hist-add-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 9999;
  justify-content: center;
  align-items: center;
}
.hist-add-overlay.active {
  display: flex;
}
.hist-add-modal {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  width: min(92%, 380px);
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}
.hist-add-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.hist-add-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1a1d3b;
}
.hist-add-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: #999;
  cursor: pointer;
}
.hist-add-contents {
  background: #f5f5fa;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 16px;
}
.hist-add-children-label {
  font-size: 0.75rem;
  color: #888;
  margin-bottom: 6px;
  font-weight: 600;
}
.hist-add-child {
  font-size: 0.82rem;
  color: #444;
  padding: 3px 0;
  display: flex;
  justify-content: space-between;
}
.hist-add-child-cal {
  color: #888;
  font-size: 0.78rem;
}
.hist-add-field {
  margin-bottom: 14px;
}
.hist-add-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.hist-add-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 0.9rem;
  color: #1a1d3b;
  background: #fff;
  appearance: none;
  -webkit-appearance: none;
}
.hist-add-day-picker {
  display: flex;
  align-items: center;
  gap: 4px;
}
.hist-add-day-picker .days-strip {
  flex: 1;
}
.hist-add-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}
.hist-add-cancel {
  padding: 10px 20px;
  border: 1px solid #ddd;
  border-radius: 10px;
  background: #f5f5f5;
  color: #333;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.hist-add-save {
  padding: 10px 24px;
  border: none;
  border-radius: 10px;
  background: #34c759;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.hist-add-save:active {
  background: #2aa84a;
}

.toast.red {
  background: #d32f2f;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: auto;
}

.toast-undo-btn {
  background: transparent;
  border: 1.5px solid rgba(255,255,255,0.7);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  flex-shrink: 0;
}
.toast-undo-btn:active {
  background: rgba(255,255,255,0.2);
}

.history-loading {
  text-align: center;
  padding: 24px;
  font-size: 0.8rem;
  color: #8e92a4;
}
.history-empty {
  text-align: center;
  padding: 40px 20px;
  color: #8e92a4;
  font-size: 0.85rem;
}

.history-group-wrapper {
  border-left: 3px solid #34c759;
}
.history-item.history-group-header {
  cursor: pointer;
}
.history-group-chevron {
  font-size: 0.6rem;
  color: #8e92a4;
  transition: transform 0.2s;
  margin-right: 4px;
}
.history-group-chevron.expanded {
  transform: rotate(90deg);
}
.history-group-children {
  display: none;
}
.history-group-children.expanded {
  display: block;
}
.history-group-children .history-item {
  padding-left: 36px;
  background: #fafbfc;
}

/* Firebase Google Sign-In Button */
.firebase-google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 280px;
  padding: 12px 24px;
  border: 1px solid #dadce0;
  border-radius: 8px;
  background: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #3c4043;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
.firebase-google-btn:hover {
  background: #f8f9fa;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.firebase-google-btn:active {
  background: #f1f3f4;
}

/* ===== UNSAVED CHANGES MODAL ===== */
.unsaved-modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.2s ease;
}
.unsaved-modal.active {
  display: flex;
}
.unsaved-modal-card {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  width: 85vw;
  max-width: 340px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  text-align: center;
}
.unsaved-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a1d3b;
  margin-bottom: 8px;
}
.unsaved-modal-text {
  font-size: 0.9rem;
  color: #6b7280;
  margin-bottom: 20px;
  line-height: 1.4;
}
.unsaved-modal-actions {
  display: flex;
  gap: 12px;
}
.unsaved-btn-discard {
  flex: 1;
  padding: 12px;
  border: 1px solid #e0e4ed;
  border-radius: 10px;
  background: #f8f9fa;
  color: #6b7280;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.unsaved-btn-save {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: #2563eb;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

/* ===== RADAR DIAGRAM MODAL ===== */
/* ===== FOOD PLACEHOLDER ===== */
.food-placeholder .food-placeholder-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: #f8f9fc;
  border: 1px dashed #d0d4e2;
  border-radius: 10px;
  margin: 4px 8px;
}
.food-placeholder-spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid #e0e4ed;
  border-top-color: #5856d6;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.food-placeholder-text {
  font-size: 0.82rem;
  color: #8e92a4;
  font-style: italic;
}
.food-placeholder-error {
  font-size: 0.82rem;
  color: #ff3b30;
  padding: 4px 0;
}
.food-placeholder-retry-btn {
  background: #007aff;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 18px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  margin-right: 8px;
}
.food-placeholder-dismiss-btn {
  background: none;
  color: #8e92a4;
  border: 1px solid #dde0e8;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.78rem;
  cursor: pointer;
  margin-top: 6px;
}

/* AI Edit loading overlay on existing items */
.ai-editing {
  position: relative;
}
.ai-edit-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 10px;
  z-index: 5;
}
.ai-edit-overlay span {
  font-size: 0.8rem;
  color: #5856d6;
  font-weight: 600;
}

/* ===== AI EDIT MODAL ===== */
.ai-edit-modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.ai-edit-modal.active {
  display: flex;
}
.ai-edit-card {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 400px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.ai-edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid #eef0f5;
}
.ai-edit-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #1a1d3b;
  flex: 1;
}
.ai-edit-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: #8e92a4;
  cursor: pointer;
  padding: 4px;
  margin-left: 8px;
}
.ai-edit-input {
  width: 100%;
  border: none;
  padding: 16px 20px;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  resize: none;
  outline: none;
  color: #1a1d3b;
  box-sizing: border-box;
}
.ai-edit-input::placeholder {
  color: #b0b4c8;
}
.ai-edit-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid #eef0f5;
}
.ai-edit-cancel-btn {
  background: #e8eaf0;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: #555;
  cursor: pointer;
}
.ai-edit-submit-btn {
  background: #5856d6;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  min-width: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ai-edit-submit-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}
.ai-edit-submit-btn .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.radar-modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9500;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.2s ease;
}
.radar-modal.active {
  display: flex;
}
.radar-modal-card {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  width: 90vw;
  max-width: 400px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.radar-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 12px;
}
.radar-modal-header span {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1a1d3b;
}
.radar-modal-desc {
  font-size: 0.8rem;
  color: #6b6f80;
  line-height: 1.45;
  margin: 0 0 8px;
  padding: 0 4px;
}
.radar-modal-desc strong {
  color: #1a1d3b;
}

.radar-modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: #8e92a4;
  cursor: pointer;
  padding: 4px 8px;
}

/* ===== IMAGE LIGHTBOX ===== */
.food-thumb {
  cursor: zoom-in;
}
.image-lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 10000;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.2s ease;
}
.image-lightbox.active {
  display: flex;
}
.image-lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  cursor: zoom-out;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
