.recommended-recipes-page {
  background: #f7faf8;
  color: #152315;
}

.recommended-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid #dce8dc;
}

.recommended-header .site-logo {
  margin-right: 8px;
}

.recommended-header h1 {
  margin: 0;
  font-size: 20px;
}

.recommended-header p,
.recipe-count p {
  margin: 4px 0 0;
  color: #667566;
  font-size: 13px;
}

.back-button {
  width: 38px;
  height: 38px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #2563eb;
  color: #fff;
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.recommended-main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px;
}

.recipe-search-panel {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid #d9e5d9;
  border-radius: 16px;
  background: #fff;
}

.search-box {
  display: grid;
  gap: 6px;
  color: #5d6d5d;
  font-size: 13px;
}

.search-box input {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cbdccc;
  border-radius: 12px;
  padding: 0 14px;
  font-size: 16px;
}

.filter-row {
  position: relative;
  display: flex;
  gap: 8px;
  overflow: visible;
  padding-bottom: 2px;
}

.filter-toggle,
.filter-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border: 1px solid #35aa4a;
  border-radius: 999px;
  background: #fff;
  color: #23853a;
  min-height: 36px;
  padding: 0 14px;
  font-weight: 700;
}

.filter-chip[aria-pressed="true"] {
  background: #2fb24a;
  color: #fff;
}

.filter-panel {
  position: absolute;
  top: var(--filter-panel-top, calc(100% + 6px));
  left: var(--filter-panel-left, 0);
  z-index: 20;
  display: grid;
  width: min(240px, calc(100vw - 40px));
  min-width: var(--filter-panel-width, 180px);
  max-height: 240px;
  overflow: auto;
  padding: 8px 0;
  border: 1px solid #35aa4a;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 24px rgba(26, 79, 33, 0.18);
}

.filter-panel[hidden] {
  display: none !important;
}

.filter-panel .filter-chip {
  width: 100%;
  justify-content: flex-start;
  border: 0;
  border-radius: 0;
  color: #1d632c;
  background: #fff;
  text-align: left;
}

.filter-panel .filter-chip:hover,
.filter-panel .filter-chip[aria-pressed="true"] {
  background: #eaf7ed;
  color: #1d7d33;
}

.recipe-count {
  text-align: center;
  padding: 28px 0 20px;
}

.recipe-count h2 {
  margin: 0;
  font-size: clamp(24px, 4vw, 34px);
  font-weight: 500;
}

.recommended-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.recommended-card {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 320px;
  border: 1px solid #d9d9d9;
  border-radius: 8px;
  background: #fff;
  padding: 22px 18px;
  text-align: center;
  cursor: pointer;
}

.recommended-card h3 {
  margin: 0;
  font-size: 19px;
  font-weight: 500;
}

.recipe-image-wrap {
  display: grid;
  place-items: center;
  min-height: 138px;
}

.recipe-image-wrap img {
  display: block;
  width: min(150px, 72%);
  height: 126px;
  object-fit: contain;
}

.recipe-badges {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.recipe-badge {
  border: 1px solid #35aa4a;
  border-radius: 999px;
  color: #2e9d43;
  padding: 4px 12px;
  font-size: 12px;
}

.recipe-ingredients {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 10px;
  border-top: 1px solid #e0e0e0;
  margin-top: 16px;
  padding-top: 14px;
  text-align: left;
  font-size: 14px;
}

.recipe-ingredients strong {
  font-weight: 600;
}

.recipe-ingredients span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recipe-detail-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: end center;
  background: rgba(0, 0, 0, 0.38);
}

.recipe-detail-modal[hidden] {
  display: none !important;
}

.recipe-detail-dialog {
  position: relative;
  width: min(760px, 100%);
  max-height: min(86vh, 900px);
  overflow: auto;
  border-radius: 20px 20px 0 0;
  background: #fff;
  padding: 24px;
}

.detail-hero {
  display: grid;
  place-items: center;
  min-height: 160px;
  margin: 0 0 12px;
  border-radius: 16px;
  background: #f6faf6;
}

.detail-hero img {
  display: block;
  width: min(220px, 70%);
  max-height: 180px;
  object-fit: contain;
}

.modal-close {
  position: sticky;
  top: 0;
  float: right;
  width: 36px;
  height: 36px;
  border: 1px solid #d3ded3;
  border-radius: 50%;
  background: #fff;
  font-size: 22px;
}

.detail-section {
  border-top: 1px solid #e4ebe4;
  padding: 18px 0;
}

.detail-section h3 {
  margin: 0 0 10px;
}

.detail-section pre {
  white-space: pre-wrap;
  font: inherit;
  line-height: 1.7;
}

.recipe-detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.recipe-detail-table th,
.recipe-detail-table td {
  border-bottom: 1px solid #e4ebe4;
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.recipe-detail-table th {
  background: #f2f8f3;
  color: #315b36;
  font-weight: 700;
}

.nutrition-summary {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid #d8e7d9;
  border-radius: 8px;
  background: #f8fbf8;
  text-align: center;
}

.nutrition-summary strong,
.nutrition-summary b {
  display: block;
}

.nutrition-summary strong {
  color: #2563eb;
  font-size: 16px;
}

.nutrition-summary b {
  font-size: 18px;
}

.nutrition-summary p {
  margin: 6px 0 0;
  color: #667566;
  font-size: 13px;
}

.ingredient-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ingredient-cell img {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 1px solid #e1e9e1;
  border-radius: 8px;
  background: #f8fbf8;
  object-fit: contain;
  padding: 4px;
}

.ingredient-cell span {
  min-width: 0;
  line-height: 1.35;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.macro-stack {
  display: flex;
  width: 100%;
  height: 76px;
  overflow: hidden;
  margin: 14px 0 10px;
  background: #eef2f7;
}

.macro-stack span {
  display: grid;
  place-items: center;
  min-width: 24px;
  flex: 0 0 auto;
  color: #0f172a;
  font-size: 12px;
  font-weight: 850;
}

.macro-legend {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
  color: #667566;
  font-size: 12px;
}

.macro-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.macro-legend i {
  display: inline-block;
  width: 22px;
  height: 9px;
}

.macro-caption {
  margin: 0 0 18px;
  text-align: center;
  font-size: 14px;
}

.nutrient-comparison {
  margin-top: 12px;
}

.nutrient-comparison h4 {
  margin: 0 0 8px;
}

.nutrient-comparison p {
  margin: 0 0 14px;
  color: #667566;
  font-size: 13px;
}

.nutrient-comparison-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.nutrient-comparison h5 {
  margin: 0 0 10px;
  color: #2563eb;
  font-size: 15px;
}

.nutrient-table {
  display: grid;
  gap: 8px;
}

.nutrient-row {
  display: grid;
  grid-template-columns: minmax(72px, 104px) minmax(90px, 1fr) minmax(78px, max-content);
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.nutrient-row span {
  min-width: 0;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.nutrient-row > div {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e6ea;
}

.nutrient-row i {
  display: block;
  height: 100%;
  border-radius: 999px;
}

.nutrient-before {
  background: #e88484;
}

.nutrient-after {
  background: #6fa3ff;
}

.nutrient-row b {
  text-align: right;
  white-space: nowrap;
  font-size: 12px;
}

@media (max-width: 640px) {
  .recommended-main {
    padding: 12px;
  }

  .recommended-grid {
    grid-template-columns: 1fr;
  }

  .recommended-card {
    min-height: 280px;
  }

  .nutrient-comparison-grid {
    grid-template-columns: 1fr;
  }

  .nutrient-row {
    grid-template-columns: minmax(64px, 92px) minmax(82px, 1fr) minmax(72px, max-content);
    gap: 8px;
  }
}
