:root {
  color-scheme: light;

  --bg: #f6f3ea;
  --surface: #fffdf8;
  --surface-soft: #eceade;
  --text: #17241f;
  --muted: #6e756f;
  --line: #dddcd2;

  --green-900: #184739;
  --green-700: #356b55;
  --green-500: #5b8b68;
  --green-100: #d8e4d6;

  --warm: #d99352;

  --shadow:
    0 18px 50px
    rgba(23, 36, 31, 0.08);

  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;

  min-width: 320px;

  color: var(--text);
  background:
    radial-gradient(
      circle at top right,
      rgba(91, 139, 104, 0.12),
      transparent 34rem
    ),
    var(--bg);

  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;

  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  width: min(1180px, 100%);
  min-height: 100vh;

  margin: 0 auto;

  padding:
    env(safe-area-inset-top)
    24px
    calc(110px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 18px 0 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  position: relative;

  width: 44px;
  height: 44px;

  border-radius: 14px;

  background: var(--green-900);

  box-shadow:
    0 10px 30px
    rgba(24, 71, 57, 0.18);
}

.brand-mark::before {
  content: "";

  position: absolute;

  width: 22px;
  height: 22px;

  top: 11px;
  left: 11px;

  border-radius: 50%;

  background: #f4efe0;
}

.brand-mark span {
  position: absolute;

  width: 8px;
  height: 15px;

  top: 10px;
  left: 23px;

  border-radius: 80% 20% 80% 20%;

  transform: rotate(28deg);

  background: var(--green-500);
}

.brand-name {
  font-weight: 800;
  font-size: 16px;
  line-height: 1.15;
}

.brand-caption {
  margin-top: 3px;

  font-size: 12px;
  color: var(--muted);
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 7px;

  padding: 8px 11px;

  border: 1px solid var(--line);
  border-radius: 999px;

  color: var(--muted);
  background: rgba(255, 253, 248, 0.7);

  font-size: 12px;
  font-weight: 650;
}

.status-dot {
  width: 8px;
  height: 8px;

  border-radius: 50%;

  background: #c9984b;
}

.connection-status.online .status-dot {
  background: #5f9b69;
}

.connection-status.error .status-dot {
  background: #bc5d51;
}

.hero {
  display: grid;
  grid-template-columns:
    minmax(0, 1fr)
    auto;

  gap: 24px;

  align-items: end;

  margin-bottom: 36px;
}

.eyebrow {
  margin-bottom: 8px;

  color: var(--green-700);

  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.15em;
}

.hero h1 {
  max-width: 720px;

  margin: 0;

  font-size:
    clamp(42px, 7vw, 78px);

  font-weight: 820;
  letter-spacing: -0.055em;
  line-height: 0.98;
}

.hero h1 span {
  color: var(--green-700);
}

.hero p {
  max-width: 550px;

  margin:
    22px
    0
    0;

  color: var(--muted);

  font-size:
    clamp(15px, 2vw, 18px);

  line-height: 1.6;
}

.hero-stat {
  display: flex;
  flex-direction: column;

  align-items: center;
  justify-content: center;

  min-width: 116px;
  min-height: 116px;

  padding: 18px;

  border-radius: 50%;

  color: #fff;
  background: var(--green-900);

  box-shadow: var(--shadow);
}

.hero-stat strong {
  font-size: 35px;
  line-height: 1;
}

.hero-stat span {
  margin-top: 5px;

  font-size: 12px;
  opacity: 0.76;
}

.controls {
  display: flex;
  flex-wrap: wrap;

  gap: 14px;

  align-items: center;
  justify-content: space-between;

  margin-bottom: 42px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;

  min-width: min(100%, 330px);

  padding:
    0
    16px;

  border:
    1px solid
    var(--line);

  border-radius: 17px;

  background: var(--surface);
}

.search-icon {
  color: var(--green-700);

  font-size: 23px;
  line-height: 1;
}

.search-box input {
  width: 100%;

  padding:
    14px
    0;

  border: 0;
  outline: 0;

  color: var(--text);
  background: transparent;
}

.search-box input::placeholder {
  color: #9c9f9b;
}

.filters {
  display: flex;
  gap: 6px;

  padding: 5px;

  border-radius: 16px;

  background: #e9e7dd;
}

.filter-button {
  padding:
    9px
    14px;

  border: 0;
  border-radius: 12px;

  background: transparent;

  cursor: pointer;

  color: var(--muted);

  font-size: 13px;
  font-weight: 700;
}

.filter-button.active {
  color: var(--green-900);
  background: var(--surface);

  box-shadow:
    0 4px 14px
    rgba(23, 36, 31, 0.07);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;

  gap: 20px;

  margin-bottom: 17px;
}

.section-heading h2 {
  margin: 0;

  font-size: 28px;
  letter-spacing: -0.03em;
}

.section-heading > span {
  color: var(--muted);

  font-size: 13px;
}

.recipe-grid {
  display: grid;

  grid-template-columns:
    repeat(
      3,
      minmax(0, 1fr)
    );

  gap: 17px;
}

.recipe-card {
  position: relative;

  overflow: hidden;

  display: flex;
  flex-direction: column;

  min-height: 290px;

  padding: 22px;

  border:
    1px solid
    rgba(221, 220, 210, 0.85);

  border-radius: var(--radius-lg);

  background: var(--surface);

  box-shadow:
    0 3px 0
    rgba(23, 36, 31, 0.015);

  cursor: pointer;

  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.recipe-card:hover {
  transform: translateY(-3px);

  border-color:
    rgba(91, 139, 104, 0.44);

  box-shadow: var(--shadow);
}

.recipe-card::after {
  content: "";

  position: absolute;

  width: 145px;
  height: 145px;

  right: -58px;
  top: -65px;

  border-radius: 50%;

  background:
    rgba(91, 139, 104, 0.08);
}

.card-category {
  position: relative;
  z-index: 1;

  display: inline-flex;
  align-items: center;

  align-self: flex-start;

  padding:
    7px
    10px;

  border-radius: 999px;

  color: var(--green-700);
  background: var(--green-100);

  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.recipe-card h3 {
  position: relative;
  z-index: 1;

  margin:
    24px
    0
    8px;

  font-size: 23px;
  line-height: 1.07;
  letter-spacing: -0.035em;
}

.card-meta {
  margin-bottom: auto;

  color: var(--muted);

  font-size: 13px;
}

.nutrition-row {
  display: grid;
  grid-template-columns:
    repeat(2, 1fr);

  gap: 8px;

  margin-top: 22px;
}

.nutrition-chip {
  padding: 10px 12px;

  border-radius: 13px;

  background: #f2f0e7;
}

.nutrition-chip strong {
  display: block;

  font-size: 17px;
  line-height: 1.1;
}

.nutrition-chip span {
  display: block;

  margin-top: 3px;

  color: var(--muted);

  font-size: 10px;
  font-weight: 650;
}

.skeleton-card {
  min-height: 290px;

  border-radius: var(--radius-lg);

  background:
    linear-gradient(
      90deg,
      #ece9df 25%,
      #f5f2e9 50%,
      #ece9df 75%
    );

  background-size: 200% 100%;

  animation:
    skeleton
    1.3s
    infinite;
}

@keyframes skeleton {
  from {
    background-position: 200% 0;
  }

  to {
    background-position: -200% 0;
  }
}

.empty-state {
  padding: 60px 20px;

  text-align: center;

  color: var(--muted);
}

.empty-state.hidden {
  display: none;
}

.empty-icon {
  margin-bottom: 10px;

  font-size: 42px;
  color: var(--green-500);
}

.empty-state h3 {
  margin: 0 0 6px;

  color: var(--text);
}

.empty-state p {
  margin: 0;
}

.bottom-nav {
  position: fixed;

  z-index: 20;

  left: 50%;
  bottom:
    calc(
      14px
      + env(safe-area-inset-bottom)
    );

  transform: translateX(-50%);

  display: grid;
  grid-template-columns:
    repeat(3, 1fr);

  width: min(430px, calc(100% - 32px));

  padding: 7px;

  border:
    1px solid
    rgba(221, 220, 210, 0.85);

  border-radius: 22px;

  background:
    rgba(255, 253, 248, 0.92);

  backdrop-filter: blur(18px);

  box-shadow:
    0 14px 45px
    rgba(23, 36, 31, 0.14);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;

  gap: 3px;

  padding: 8px;

  border: 0;
  border-radius: 16px;

  color: var(--muted);
  background: transparent;

  font-size: 10px;
  font-weight: 700;
}

.nav-item.active {
  color: var(--green-900);
  background: var(--green-100);
}

.nav-item:disabled {
  opacity: 0.42;
}

.nav-icon {
  font-size: 18px;
}

.recipe-dialog {
  width:
    min(
      760px,
      calc(100% - 24px)
    );

  max-height:
    min(
      860px,
      calc(100vh - 24px)
    );

  padding: 0;

  border: 0;
  border-radius: 30px;

  color: var(--text);
  background: var(--surface);

  box-shadow:
    0 30px 90px
    rgba(17, 34, 28, 0.30);
}

.recipe-dialog::backdrop {
  background:
    rgba(16, 29, 24, 0.60);

  backdrop-filter: blur(4px);
}

.dialog-shell {
  position: relative;

  max-height:
    calc(100vh - 24px);

  overflow-y: auto;

  padding:
    36px
    34px
    42px;
}

.close-button {
  position: sticky;
  z-index: 5;

  top: 0;
  float: right;

  width: 42px;
  height: 42px;

  margin-left: 12px;

  border: 0;
  border-radius: 50%;

  background: #efede5;

  cursor: pointer;

  font-size: 27px;
  line-height: 1;
}

.detail-category {
  color: var(--green-700);

  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.13em;
}

.recipe-detail h2 {
  max-width: 600px;

  margin:
    7px
    0
    10px;

  font-size:
    clamp(
      30px,
      7vw,
      48px
    );

  letter-spacing: -0.045em;
  line-height: 1.02;
}

.detail-description {
  max-width: 610px;

  margin:
    0
    0
    26px;

  color: var(--muted);

  line-height: 1.55;
}

.detail-summary {
  display: grid;

  grid-template-columns:
    repeat(4, 1fr);

  gap: 9px;

  margin-bottom: 30px;
}

.summary-cell {
  padding: 14px;

  border-radius: 16px;

  background: #efede4;
}

.summary-cell strong {
  display: block;

  font-size: 19px;
}

.summary-cell span {
  display: block;

  margin-top: 3px;

  color: var(--muted);

  font-size: 10px;
  font-weight: 700;
}

.detail-section {
  margin-top: 32px;
}

.detail-section h3 {
  margin:
    0
    0
    13px;

  font-size: 18px;
}

.ingredient-list,
.step-list {
  display: grid;
  gap: 8px;

  margin: 0;
  padding: 0;

  list-style: none;
}

.ingredient-row {
  display: flex;
  justify-content: space-between;

  gap: 20px;

  padding:
    12px
    0;

  border-bottom:
    1px solid
    var(--line);
}

.ingredient-row span:first-child {
  font-weight: 650;
}

.ingredient-row span:last-child {
  flex: none;

  color: var(--green-700);
  font-weight: 800;
}

.step-row {
  display: grid;
  grid-template-columns:
    34px
    1fr;

  gap: 12px;

  align-items: start;

  padding:
    12px
    0;
}

.step-number {
  display: grid;
  place-items: center;

  width: 32px;
  height: 32px;

  border-radius: 50%;

  color: white;
  background: var(--green-900);

  font-size: 12px;
  font-weight: 800;
}

.step-row p {
  margin:
    4px
    0
    0;

  line-height: 1.5;
}

.detail-nutrition {
  display: grid;

  grid-template-columns:
    repeat(5, 1fr);

  gap: 8px;
}

.detail-nutrient {
  padding:
    13px
    9px;

  border-radius: 15px;

  text-align: center;

  background: var(--green-100);
}

.detail-nutrient strong {
  display: block;

  font-size: 17px;
}

.detail-nutrient span {
  display: block;

  margin-top: 3px;

  color: var(--green-700);

  font-size: 9px;
  font-weight: 800;
}

.equipment-list {
  display: flex;
  flex-wrap: wrap;

  gap: 7px;
}

.equipment-chip {
  padding:
    8px
    11px;

  border:
    1px solid
    var(--line);

  border-radius: 999px;

  font-size: 12px;
}

.loading-detail {
  padding:
    80px
    20px;

  text-align: center;

  color: var(--muted);
}

.error-banner {
  padding: 16px;

  border-radius: 16px;

  color: #833d35;
  background: #f3ddd8;
}

@media (max-width: 880px) {
  .recipe-grid {
    grid-template-columns:
      repeat(
        2,
        minmax(0, 1fr)
      );
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding:
      env(safe-area-inset-top)
      16px
      calc(
        105px
        + env(safe-area-inset-bottom)
      );
  }

  .topbar {
    padding-top: 13px;
  }

  .connection-status span:last-child {
    display: none;
  }

  .hero {
    grid-template-columns: 1fr;

    margin-top: 16px;
  }

  .hero-stat {
    display: none;
  }

  .controls {
    align-items: stretch;

    margin-bottom: 34px;
  }

  .search-box {
    width: 100%;
  }

  .filters {
    width: 100%;
  }

  .filter-button {
    flex: 1;
  }

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

  .recipe-card {
    min-height: 250px;
  }

  .dialog-shell {
    padding:
      26px
      20px
      35px;
  }

  .detail-summary {
    grid-template-columns:
      repeat(2, 1fr);
  }

  .detail-nutrition {
    grid-template-columns:
      repeat(2, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
