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

:root {
  --bg-primary: #F2F2F7;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #E5E5EA;
  --label-primary: #000000;
  --label-secondary: #3C3C43CC;
  --label-tertiary: #3C3C4399;
  --separator: #3C3C4349;
  --accent: #1757e0;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--label-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body.home-page {
  background: linear-gradient(180deg, #ffffff 0%, #dddde6 100%);
}

/* Home button */
.home-btn {
  color: var(--accent);
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

.home-btn:active {
  opacity: 0.5;
}

.nav-detail .nav-logo {
  font-size: 20px;
}

/* Category grid */
.category-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 600px) {
  .category-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.home-hero {
  text-align: center;
  padding: 40px 0 32px;
}

.home-title {
  font-size: 52px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--label-primary);
}

.home-subtitle {
  margin-top: 10px;
  font-size: 18px;
  color: var(--label-secondary);
  font-weight: 400;
  letter-spacing: 0.02em;
}

.home-count {
  margin-top: 6px;
  font-size: 13px;
  color: var(--label-tertiary);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.category-card {
  border-radius: 16px;
  overflow: hidden;
  display: block;
  text-decoration: none;
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.06);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}

.category-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.category-card:active {
  transform: scale(0.97);
  opacity: 0.8;
}

.category-img-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--bg-tertiary);
}

.category-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.category-img-placeholder {
  width: 100%;
  height: 100%;
  background: var(--bg-tertiary);
}

.category-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 36px 12px 14px;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  text-align: center;
  text-transform: capitalize;
  background: linear-gradient(to top, rgba(0,0,0,0.65) 0%, transparent 100%);
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}


/* Nav bar — iOS large title style */
header {
  background: rgba(242, 242, 247, 0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--separator);
  padding: 12px 0 8px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.nav-left,
.nav-right {
  width: 60px;
  display: flex;
  align-items: center;
}

.nav-right {
  justify-content: flex-end;
}

.nav-logo {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  text-align: center;
  flex: 1;
}

.nav-detail .nav-logo,
.recipes-page .nav-logo {
  font-size: 20px;
}

.home-btn-placeholder {
  display: block;
  width: 20px;
  height: 20px;
}


.nav-search-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  position: relative;
  margin-left: auto;
}

.search-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 16px;
  width: 320px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  z-index: 50;
}

@media (max-width: 600px) {

  /* Prevent iOS auto-zoom on input focus */
  .nav-search,
  .ingredient-input {
    font-size: 16px;
  }

  .nav-inner.search-open .nav-logo,
  .nav-inner.search-open .nav-left {
    display: none;
  }

  .nav-inner.search-open .nav-right {
    width: 100%;
  }

  .nav-inner.search-open .nav-search-wrap {
    width: 100%;
  }

  .nav-inner.search-open .nav-search.expanded {
    width: 100%;
    margin-right: 0;
  }

  .search-dropdown {
    width: calc(100vw - 40px);
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    max-height: 70vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .macro-slider::-webkit-slider-thumb {
    width: 26px;
    height: 26px;
  }
}

.search-dropdown.open {
  display: block;
}

.dropdown-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--label-tertiary);
  margin-bottom: 10px;
}

.search-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--label-primary);
  display: flex;
  align-items: center;
  padding: 4px;
  z-index: 1;
  flex-shrink: 0;
}

.nav-search {
  width: 0;
  padding: 7px 0;
  font-size: 14px;
  font-family: var(--font);
  background: var(--bg-secondary);
  border: none;
  border-radius: 10px;
  outline: none;
  color: var(--label-primary);
  -webkit-appearance: none;
  overflow: hidden;
  opacity: 0;
  transition: width 0.3s ease, padding 0.3s ease, opacity 0.2s ease;
  pointer-events: none;
}

.nav-search.expanded {
  width: 200px;
  padding: 7px 12px;
  opacity: 1;
  pointer-events: auto;
  margin-right: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.nav-search::placeholder {
  color: var(--label-tertiary);
}

.nav-eyebrow {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 2px;
}

header h1 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--label-primary);
  line-height: 1.1;
}

/* Main content */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

/* Ingredient text input */
.ingredient-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.ingredient-input {
  flex: 1;
  padding: 7px 12px;
  font-size: 13px;
  font-family: var(--font);
  background: var(--bg-primary);
  border: none;
  border-radius: 10px;
  outline: none;
  color: var(--label-primary);
}

.ingredient-input::placeholder {
  color: var(--label-tertiary);
}

.ingredient-add-btn {
  background: var(--bg-tertiary);
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  color: var(--label-tertiary);
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

.ingredient-add-btn.active {
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.ingredient-add-btn.active:active {
  opacity: 0.7;
}

/* Filter chips */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  background: var(--bg-secondary);
  border: 1.5px solid var(--separator);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 500;
  color: var(--label-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.filter-chip:active {
  opacity: 0.7;
}

.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Macro filter sliders */
.macro-slider-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.macro-slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.macro-slider-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--label-secondary);
}

.macro-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-tertiary);
  outline: none;
  cursor: pointer;
}

.macro-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.macro-slider-val {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

/* Section label */
.section-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--label-secondary);
  text-transform: uppercase;
  margin-bottom: 12px;
  padding-left: 4px;
}

/* Grid */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

/* Card — iOS grouped list / widget card feel */
.recipe-card {
  background: var(--bg-secondary);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.06),
    0 4px 12px rgba(0, 0, 0, 0.06);
}

.recipe-card:active {
  opacity: 0.7;
  transform: scale(0.98);
}

@media (hover: hover) {
  .recipe-card:hover {
    box-shadow:
      0 2px 6px rgba(0, 0, 0, 0.08),
      0 8px 24px rgba(0, 0, 0, 0.1);
  }
}

.recipe-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}

.recipe-card .img-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg-tertiary);
  overflow: hidden;
}

.recipe-card .img-wrap img {
  aspect-ratio: unset;
  height: 100%;
}

.card-no-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #E5F5EA;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}

.card-body {
  padding: 12px 14px 14px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--label-primary);
  letter-spacing: -0.1px;
  text-align: center;
}

.card-date {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 400;
  color: var(--label-tertiary);
  letter-spacing: 0;
}

/* Empty state */
.empty-state {
  text-align: center;
  color: var(--label-secondary);
  margin-top: 80px;
  font-size: 15px;
  line-height: 1.8;
}

.empty-state code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 13px;
}


/* Detail page nav */
.nav-detail {
  display: flex;
  align-items: center;
  min-height: 32px;
}

.back-btn {
  font-size: 17px;
  font-weight: 400;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.1px;
}

.back-btn:active {
  opacity: 0.5;
}

/* Recipe detail page */
.recipe-detail {
  max-width: 680px;
  margin: 0 auto;
  padding-bottom: 60px;
}

.detail-hero {
  width: 80%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  margin: 24px auto 0;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
}

.detail-body {
  padding: 24px 20px 0;
}

.detail-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.4px;
  line-height: 1.2;
  color: var(--label-primary);
}

.detail-date {
  font-size: 13px;
  color: var(--label-tertiary);
  margin-top: 6px;
  margin-bottom: 20px;
}

.detail-separator {
  height: 0.5px;
  background: var(--separator);
  margin-bottom: 20px;
}

.detail-caption {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: #3C3C43;
  white-space: pre-wrap;
  word-break: break-word;
  font-weight: 400;
}

/* Servings */
.detail-servings {
  font-size: 14px;
  font-weight: 500;
  color: var(--label-secondary);
  margin-bottom: 12px;
}

/* Servings slider */
.servings-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.detail-servings {
  font-size: 14px;
  color: var(--label-secondary);
  white-space: nowrap;
}

.servings-slider {
  -webkit-appearance: none;
  flex: 1;
  max-width: 200px;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-tertiary);
  outline: none;
  cursor: pointer;
}

.servings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

/* Macros row */
.macros-row {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.macro-pill {
  background: #abc6e3;
  border-radius: 12px;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 68px;
  flex: 1;
}

.macro-value {
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
}

.macro-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--label-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

/* Structured recipe sections */
.recipe-section {
  margin-bottom: 28px;
}

.section-header {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}

.ingredients-list {
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ingredients-list li {
  font-size: 16px;
  line-height: 1.5;
  color: var(--label-primary);
  padding: 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.ingredients-list li::before {
  content: "";
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-top: 7px;
}


.recipe-list {
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.recipe-list li {
  font-size: 16px;
  line-height: 1.5;
  color: var(--label-primary);
  padding: 11px 0;
  border-bottom: 0.5px solid var(--separator);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.recipe-list li::before {
  content: "";
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-top: 7px;
}

.recipe-steps li {
  counter-increment: steps;
}

.recipe-steps li::before {
  content: counter(steps);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: #abc6e3;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.recipe-steps {
  counter-reset: steps;
}

.recipe-notes {
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 14px 16px;
}

.recipe-notes p {
  font-size: 15px;
  line-height: 1.6;
  color: var(--label-secondary);
  font-style: italic;
}

@media (max-width: 480px) {
  header h1 {
    font-size: 28px;
  }

  .recipe-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .detail-title {
    font-size: 24px;
  }

  .home-hero {
    padding: 20px 0 20px;
  }
}