/* NutriGuru Home responsive repair: layout-only layer over the shared dashboard. */
.home-screen-mode #screenContent {
  width: 100%;
  max-width: 1280px;
  min-width: 0;
  margin-inline: auto;
}

.home-screen-mode .home-dashboard-v2 {
  width: 100%;
  max-width: 1280px;
  min-width: 0;
  margin: 0 auto;
  padding: 20px clamp(16px, 3vw, 28px) calc(118px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow: visible;
}

.home-screen-mode .home-dashboard-v2 > * {
  min-width: 0;
  width: 100%;
  margin: 0;
}

/* Fasting is a full-width dashboard section. Without an explicit grid span,
   the desktop 12-column layout can place it in a one-column track and wrap
   every character vertically. */
.home-screen-mode .home-dashboard-v2 > .fasting-home-widget {
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
}

.home-screen-mode .home-card {
  min-width: 0;
  width: 100%;
  overflow: hidden;
}

.home-screen-mode .home-dashboard-intro {
  padding: 0 2px;
}

.home-screen-mode .home-v2-date,
.home-screen-mode .home-v2-title,
.home-screen-mode .home-card h2,
.home-screen-mode .home-card p,
.home-screen-mode .home-card strong,
.home-screen-mode .home-card span {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: normal;
  word-break: normal;
}

.home-screen-mode .home-card-head {
  min-width: 0;
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.home-screen-mode .home-card-head > div {
  min-width: 0;
  flex: 1 1 220px;
}

.home-screen-mode .home-card-head h2 {
  line-height: 1.12;
}

.home-screen-mode .home-card-head p {
  max-width: 66ch;
}

.home-screen-mode .home-link-button {
  flex: 0 1 auto;
  max-width: 100%;
  white-space: normal;
  text-align: left;
  line-height: 1.25;
}

/* Coach: normal flow on every viewport, with the CTA after the tip. */
.home-screen-mode .home-coach-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  /* Use a bundled asset so the Coach visual works in Preview and offline exports. */
  background-image: linear-gradient(90deg, rgba(4, 10, 14, .96) 0%, rgba(4, 14, 19, .82) 44%, rgba(4, 14, 19, .4) 100%), url("images/nutrition-bowl.svg");
  background-position: center;
  background-size: cover;
}

.home-screen-mode .home-coach-content {
  width: 100%;
  padding: 24px 24px 14px;
}

.home-screen-mode .home-coach-content h2 {
  max-width: 18ch;
  font-size: clamp(25px, 4vw, 36px);
  line-height: 1.08;
}

.home-screen-mode .home-coach-content > p {
  max-width: 70ch;
}

.home-screen-mode .home-coach-tip {
  width: auto;
  max-width: none;
  margin: 0 24px 16px;
}

.home-screen-mode .home-coach-action {
  align-self: flex-start;
  width: auto;
  max-width: calc(100% - 48px);
  min-height: 46px;
  margin: 0 24px 24px;
}

/* Today's data: consistent 2x2 mobile grid and no fake width. */
.home-screen-mode .home-today-card {
  position: static !important;
  padding: 20px;
}

.home-screen-mode .home-stat-grid {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.home-screen-mode .home-stat {
  min-width: 0;
  width: 100%;
  min-height: 142px;
  padding: 15px;
  overflow: hidden;
}

.home-screen-mode .home-stat-icon,
.home-screen-mode .home-stat-label,
.home-screen-mode .home-stat-value,
.home-screen-mode .home-stat-detail,
.home-screen-mode .home-stat-progress {
  min-width: 0;
  max-width: 100%;
}

.home-screen-mode .home-stat-label,
.home-screen-mode .home-stat-detail {
  white-space: normal;
  overflow-wrap: normal;
  line-height: 1.25;
}

.home-screen-mode .home-stat-value {
  display: block;
  font-size: clamp(16px, 4.6vw, 23px);
  line-height: 1.15;
  white-space: normal;
}

.home-screen-mode .home-stat-progress {
  display: block;
  width: 100%;
}

.home-screen-mode .home-stat-plus {
  flex: 0 0 auto;
}

/* Full-width plan card with readable copy over its own image. */
.home-screen-mode .home-plan-card {
  min-height: 0;
  padding: 0;
  background-image: linear-gradient(105deg, rgba(5, 12, 15, .96) 0%, rgba(6, 15, 21, .82) 58%, rgba(6, 15, 21, .48) 100%), url("https://images.unsplash.com/photo-1547592180-85f173990554?auto=format&fit=crop&w=1400&q=75");
  background-position: center;
  background-size: cover;
}

.home-screen-mode .home-plan-content {
  width: 100%;
  max-width: 720px;
  padding: clamp(22px, 4vw, 34px);
}

.home-screen-mode .home-plan-content h2 {
  max-width: 18ch;
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1.04;
}

.home-screen-mode .home-plan-content p {
  max-width: 58ch;
}

.home-screen-mode .home-plan-meta {
  max-width: 100%;
  overflow-wrap: normal;
}

.home-screen-mode .home-plan-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: 100%;
  min-height: 46px;
  white-space: normal;
  text-align: center;
}

/* Meals: rows have the same action position and can wrap without overflow. */
.home-screen-mode .home-meals-card,
.home-screen-mode .home-recipe-card,
.home-screen-mode .home-achievements {
  padding: 20px;
}

.home-screen-mode .home-meals-card {
  background-image: linear-gradient(112deg, rgba(5, 12, 16, .96), rgba(7, 20, 27, .82)), url("https://images.unsplash.com/photo-1498837167922-ddd27525d991?auto=format&fit=crop&w=1400&q=75");
  background-position: center;
  background-size: cover;
}

.home-screen-mode .home-meal-list {
  width: 100%;
  min-width: 0;
  display: grid;
  gap: 10px;
}

.home-screen-mode .home-meal-row {
  min-width: 0;
  width: 100%;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
}

.home-screen-mode .home-meal-main {
  min-width: 0;
  overflow-wrap: normal;
}

.home-screen-mode .home-meal-main strong,
.home-screen-mode .home-meal-main span {
  display: block;
  min-width: 0;
  white-space: normal;
  overflow-wrap: normal;
  line-height: 1.25;
}

.home-screen-mode .home-meal-actions {
  min-width: 0;
  justify-self: end;
}

.home-screen-mode .home-meal-edit,
.home-screen-mode .home-meal-add {
  min-width: 92px;
  min-height: 44px;
  white-space: normal;
}

/* Recipes and achievements use their own full-width image and readable content. */
.home-screen-mode .home-recipe-card {
  background-image: linear-gradient(112deg, rgba(5, 11, 15, .96), rgba(10, 18, 24, .78)), url("https://images.unsplash.com/photo-1556911220-bff31c812dba?auto=format&fit=crop&w=1400&q=75");
  background-position: center;
  background-size: cover;
}

.home-screen-mode .home-recipe-actions {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.home-screen-mode .home-recipe-action {
  width: 100%;
  min-width: 0;
  min-height: 76px;
  padding: 14px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 10px;
  text-align: left;
}

.home-screen-mode .home-recipe-action i {
  grid-row: 1 / span 2;
  align-self: center;
}

.home-screen-mode .home-recipe-action strong,
.home-screen-mode .home-recipe-action span {
  min-width: 0;
  white-space: normal;
  overflow-wrap: normal;
  line-height: 1.25;
}

.home-screen-mode .home-achievements {
  background-image: linear-gradient(112deg, rgba(8, 12, 17, .97), rgba(17, 19, 28, .78)), url("https://images.unsplash.com/photo-1533130061792-64b345e4a833?auto=format&fit=crop&w=1400&q=75");
  background-position: center;
  background-size: cover;
}

.home-screen-mode .home-achievements h2 {
  display: flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
}

.home-screen-mode .home-achievements h2::before {
  content: "\f091";
  color: #ff9d20;
  font-family: "Font Awesome 6 Free";
  font-size: .86em;
  font-weight: 900;
  flex: 0 0 auto;
}

.home-screen-mode .home-achievement-list,
.home-screen-mode .home-empty,
.home-screen-mode .home-motivation {
  min-width: 0;
  max-width: 100%;
}

.home-screen-mode .home-achievement strong,
.home-screen-mode .home-achievement span,
.home-screen-mode .home-empty,
.home-screen-mode .home-motivation {
  overflow-wrap: normal;
  word-break: normal;
}

.home-screen-mode .home-achievement strong {
  line-height: 1.25;
}

@media (max-width: 760px) {
  .home-screen-mode .home-coach-action,
  .home-screen-mode .home-plan-button {
    width: 100%;
  }

  .home-screen-mode .home-coach-action {
    max-width: calc(100% - 48px);
  }

  .home-screen-mode .home-card-head > div {
    flex-basis: 100%;
  }

  .home-screen-mode .home-card-head .home-link-button {
    margin-top: -4px;
  }
}

@media (max-width: 390px) {
  .home-screen-mode .home-dashboard-v2 {
    padding-inline: 16px;
    gap: 16px;
  }

  .home-screen-mode .home-card-head h2 {
    font-size: 21px;
  }

  .home-screen-mode .home-today-card,
  .home-screen-mode .home-meals-card,
  .home-screen-mode .home-recipe-card,
  .home-screen-mode .home-achievements {
    padding: 16px;
  }

  .home-screen-mode .home-stat {
    min-height: 128px;
    padding: 12px;
  }

  .home-screen-mode .home-stat-value {
    font-size: 16px;
  }

  .home-screen-mode .home-meal-row {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 8px 10px;
  }

  .home-screen-mode .home-meal-actions {
    grid-column: 2;
    justify-self: start;
  }

  .home-screen-mode .home-meal-edit,
  .home-screen-mode .home-meal-add {
    min-width: 104px;
  }
}

@media (min-width: 761px) and (max-width: 899px) {
  .home-screen-mode .home-dashboard-v2 {
    padding-inline: 24px;
  }
}

@media (min-width: 900px) {
  .home-screen-mode .home-dashboard-v2 {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    align-items: start;
    gap: 20px;
  }

  .home-screen-mode .home-dashboard-v2 > .home-dashboard-intro,
  .home-screen-mode .home-dashboard-v2 > .home-coach-card,
  .home-screen-mode .home-dashboard-v2 > .home-today-card,
  .home-screen-mode .home-dashboard-v2 > .home-plan-card,
  .home-screen-mode .home-dashboard-v2 > .home-achievements,
  .home-screen-mode .home-dashboard-v2 > .home-bottom-space {
    grid-column: 1 / -1;
  }

  .home-screen-mode .home-dashboard-v2 > .home-meals-card {
    grid-column: span 7;
  }

  .home-screen-mode .home-dashboard-v2 > .home-recipe-card {
    grid-column: span 5;
  }

  .home-screen-mode .home-recipe-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-screen-mode .home-coach-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, .55fr);
    align-items: end;
  }

  .home-screen-mode .home-coach-action {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
    margin: 0 24px 24px;
  }

  .home-screen-mode .home-coach-tip {
    grid-column: 2;
    grid-row: 1;
    margin: 24px 24px 10px;
  }

  .home-screen-mode .home-coach-content {
    grid-column: 1;
    grid-row: 1 / span 2;
  }
}

@media (min-width: 1280px) {
  .home-screen-mode .home-dashboard-v2 {
    padding-inline: 0;
  }
}

/* Keep the content flow intentional: recipes belong below the meal diary,
   never in a narrow side column. */
@media (min-width: 761px) and (max-width: 1199px) {
  .home-screen-mode .home-dashboard-v2 {
    display: flex;
    flex-direction: column;
  }

  .home-screen-mode .home-recipe-card,
  .home-screen-mode .home-meals-card {
    width: 100%;
  }

  .home-screen-mode .home-recipe-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1200px) {
  .home-screen-mode .home-dashboard-v2 > .home-meals-card,
  .home-screen-mode .home-dashboard-v2 > .home-recipe-card {
    grid-column: 1 / -1;
  }

  .home-screen-mode .home-dashboard-v2 > .home-recipe-card {
    grid-row: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .home-screen-mode .home-card,
  .home-screen-mode .home-stat,
  .home-screen-mode .home-plan-button,
  .home-screen-mode .home-recipe-action {
    transition: none;
  }
}

/* Desktop guard: the diary is a full-width dashboard section. Keep it out of
   any legacy grid track so its heading can never collapse into a letter-wide
   column in desktop Preview/WebViews. */
@media (min-width: 761px) {
  .home-screen-mode .home-dashboard-v2 > .home-meals-card {
    box-sizing: border-box !important;
    display: block !important;
    flex: 0 0 100% !important;
    grid-column: 1 / -1 !important;
    inline-size: 100% !important;
    max-inline-size: none !important;
    min-inline-size: 0 !important;
    width: 100% !important;
    max-width: none !important;
  }

  .home-screen-mode .home-dashboard-v2 > .home-workout-widget {
    box-sizing: border-box !important;
    display: block !important;
    flex: 0 0 100% !important;
    grid-column: 1 / -1 !important;
    inline-size: 100% !important;
    max-inline-size: none !important;
    min-inline-size: 0 !important;
    width: 100% !important;
    max-width: none !important;
  }
}

/* Home quick actions: camera and meal logging stay above the fixed nav. */
.home-screen-mode .home-action-fab {
  position: fixed;
  z-index: 65;
  bottom: calc(84px + env(safe-area-inset-bottom));
  width: 58px !important;
  min-width: 58px !important;
  height: 58px !important;
  min-height: 58px !important;
  border-radius: 50%;
}

.home-screen-mode .food-scan-sticky.home-action-fab {
  left: calc(50% - 34px);
}

.home-screen-mode .tracker-fab.home-action-fab {
  left: calc(50% + 34px);
}

@media (max-width: 520px) {
  .home-screen-mode .home-action-fab {
    bottom: calc(80px + env(safe-area-inset-bottom));
    width: 52px !important;
    min-width: 52px !important;
    height: 52px !important;
    min-height: 52px !important;
  }

  .home-screen-mode .food-scan-sticky.home-action-fab {
    left: calc(50% - 32px);
  }

  .home-screen-mode .tracker-fab.home-action-fab {
    left: calc(50% + 32px);
  }

  .home-screen-mode .food-scan-sticky.home-action-fab i:first-child,
  .home-screen-mode .tracker-fab.home-action-fab i {
    font-size: 25px !important;
  }
}

/* On phones, keep the four daily metrics in a compact, readable 2x2 grid. */
@media (max-width: 600px) {
  .home-screen-mode .home-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .home-screen-mode .home-stat {
    min-height: 198px;
  }

  .home-screen-mode .home-stat-value {
    font-size: clamp(18px, 5vw, 23px);
  }
}

/* Open widget layout: remove the decorative outer shells so the content and
   inner action cards get the full dashboard width. Individual stat cards keep
   their own glass borders, colors and elevation. */
.home-screen-mode .home-dashboard-v2 > .home-card {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background-color: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  overflow: visible;
}

.home-screen-mode .home-dashboard-v2 > .home-today-card,
.home-screen-mode .home-dashboard-v2 > .home-recipe-card,
.home-screen-mode .home-dashboard-v2 > .home-achievements {
  background-image: none;
}

/* The metrics no longer need a padded outer container: the 2x2 grid owns the
   available width, while the heading stays aligned with the dashboard. */
.home-screen-mode .home-dashboard-v2 > .home-today-card {
  padding: 0;
}

/* Restore the visual shells for the highlighted home widgets. Each card gets
   its own themed stock image, while the dark overlay keeps every label easy
   to read on small screens. */
.home-screen-mode .home-dashboard-v2 > .home-plan-card,
.home-screen-mode .home-dashboard-v2 > .home-recipe-card,
.home-screen-mode .home-dashboard-v2 > .home-achievements {
  border: 1px solid rgba(183, 255, 0, .24);
  border-radius: 24px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, .22), inset 0 1px 0 rgba(255, 255, 255, .08);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  overflow: hidden;
  background-size: cover;
  background-position: center;
}

.home-screen-mode .home-dashboard-v2 > .home-plan-card {
  background-image: linear-gradient(105deg, rgba(5, 12, 15, .96) 0%, rgba(6, 15, 21, .82) 58%, rgba(6, 15, 21, .48) 100%), url("https://images.unsplash.com/photo-1547592180-85f173990554?auto=format&fit=crop&w=1400&q=75");
}

.home-screen-mode .home-dashboard-v2 > .home-recipe-card {
  border-color: rgba(255, 177, 78, .34);
  background-image: linear-gradient(112deg, rgba(8, 13, 17, .95), rgba(12, 21, 27, .76)), url("https://images.unsplash.com/photo-1556911220-bff31c812dba?auto=format&fit=crop&w=1400&q=75");
}

.home-screen-mode .home-dashboard-v2 > .home-achievements {
  border-color: rgba(255, 177, 78, .34);
  background-image: linear-gradient(112deg, rgba(8, 12, 17, .96), rgba(17, 19, 28, .76)), url("https://images.unsplash.com/photo-1533130061792-64b345e4a833?auto=format&fit=crop&w=1400&q=75");
}

@media (max-width: 600px) {
  .home-screen-mode .home-dashboard-v2 > .home-plan-card,
  .home-screen-mode .home-dashboard-v2 > .home-recipe-card,
  .home-screen-mode .home-dashboard-v2 > .home-achievements {
    border-radius: 20px;
  }
}

