/* BiteOff Meal Plan layer only */
.meal-plan-shell {
  width: min(980px, calc(100vw - 48px));
  margin-inline: auto;
}

.meal-plan-header {
  width: 100%;
  margin-inline: 0;
  text-align: left;
}

.meal-plan-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
  width: 100%;
}

.meal-plan-card {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: var(--radius-xl);
  padding: 22px;
  min-width: 0;
}

.meal-plan-form {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.meal-plan-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 700;
}

.meal-plan-form input,
.meal-plan-form select,
.meal-plan-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 13px 14px;
  background: var(--surface-strong);
  color: var(--text);
  font: inherit;
  outline: none;
}

.meal-plan-form textarea {
  resize: vertical;
}

.meal-plan-form input:focus,
.meal-plan-form select:focus,
.meal-plan-form textarea:focus {
  border-color: rgba(145, 214, 77, .65);
  box-shadow: 0 0 0 4px rgba(145, 214, 77, .12);
}

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

.meal-plan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}

.meal-plan-days {
  display: grid;
  gap: 14px;
}

.plan-day-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px;
  background: rgba(145, 214, 77, .06);
}

.plan-day-card h4 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.plan-meal-list {
  display: grid;
  gap: 10px;
}

.plan-meal {
  border-radius: 18px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  padding: 12px;
}

.plan-meal span {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 5px 9px;
  margin-bottom: 8px;
  background: rgba(145, 214, 77, .13);
  color: var(--deep);
  font-size: .76rem;
  font-weight: 900;
}

.plan-meal strong {
  display: block;
  margin-bottom: 4px;
}

.plan-meal p,
.plan-day-note {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.meal-plan-note {
  margin-top: 16px;
}

@media (min-width: 1000px) {
  .meal-plan-shell {
    width: min(980px, calc(100vw - 96px));
  }

  .meal-plan-grid.has-result {
    width: min(1180px, calc(100vw - 96px));
    margin-left: 50%;
    transform: translateX(-50%);
    grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .meal-plan-shell {
    width: 100%;
  }

  .meal-plan-card {
    padding: 16px;
  }

  .meal-plan-form-row {
    grid-template-columns: 1fr;
  }

  .meal-plan-actions .primary-btn,
  .meal-plan-actions .secondary-btn {
    width: 100%;
  }
}


/* Actual visible Meal Plan nav fix */
.bottom-nav {
  grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
}

.bottom-nav .nav-item {
  min-width: 0 !important;
  white-space: nowrap;
}

@media (min-width: 861px) {
  .bottom-nav {
    width: min(760px, calc(100vw - 48px)) !important;
    max-width: calc(100vw - 48px) !important;
  }
}

@media (max-width: 560px) {
  .bottom-nav {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 4px !important;
  }

  .bottom-nav .nav-item {
    padding-left: 5px !important;
    padding-right: 5px !important;
    font-size: .66rem !important;
  }
}


/* Meal Plan tab isolation + loader animation */
#mealPlanScreen {
  display: none;
}

#mealPlanScreen.active {
  display: block;
}

.meal-plan-loader-icon {
  animation: biteoffMealPlanSpin 0.85s linear infinite;
}

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


/* Scan + Plan history layer */
.history-switch {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  margin: 12px 0 18px;
}

.history-switch button {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .86rem;
  font-weight: 900;
  cursor: pointer;
}

.history-switch button.active {
  background: var(--green);
  color: var(--deep);
}

.plan-history-list {
  display: grid;
  gap: 12px;
}

.plan-history-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px;
  background: var(--surface);
}

.plan-history-card h4 {
  margin: 0 0 6px;
  color: var(--text);
}

.plan-history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}

.plan-history-meta span {
  display: inline-flex;
  border-radius: 999px;
  padding: 6px 9px;
  background: rgba(145, 214, 77, .12);
  color: var(--muted);
  font-size: .76rem;
  font-weight: 800;
}

.plan-history-card p {
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

.bottom-nav {
  grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
}

.bottom-nav .nav-item {
  min-width: 0 !important;
}

@media (max-width: 560px) {
  .bottom-nav {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 4px !important;
  }

  .bottom-nav .nav-item {
    padding-left: 5px !important;
    padding-right: 5px !important;
    font-size: .66rem !important;
  }
}




/* Meal scan / Meal plan history correction */
.history-switch {
  background: var(--surface-strong) !important;
}

.history-switch button {
  color: var(--muted) !important;
}

.history-switch button.active {
  background: var(--green) !important;
  color: #10230f !important;
}

.plan-history-list {
  display: grid;
  gap: 16px;
}

.plan-history-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.plan-history-card-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.plan-history-card h4 {
  margin: 0 0 6px;
  color: var(--text);
}

.plan-history-card p {
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

.plan-history-preview {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.plan-history-day {
  box-shadow: none;
}

.plan-history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.danger-text-btn {
  color: #ef4444 !important;
}

@media (max-width: 560px) {
  .plan-history-actions .secondary-btn,
  .plan-history-actions .text-btn {
    width: 100%;
    justify-content: center;
  }
}
