/* ===== Design Tokens ===== */
:root {
  --bg:          #FEFCF8;
  --bg-alt:      #F5EDE0;
  --card:        #FFFFFF;
  --text:        #1C1410;
  --muted:       #6B5F52;
  --primary:     #2D4A2D;
  --primary-dk:  #1E3320;
  --accent:      #C75B3F;
  --accent-dk:   #A8472E;
  --accent-lt:   #FFF5F2;
  --warm:        #E8A87C;
  --border:      #E6D8CC;
  --radius:      14px;
  --radius-sm:   8px;
  --shadow:      0 2px 12px rgba(28,20,16,.08);
  --shadow-md:   0 6px 24px rgba(28,20,16,.13);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ===== Header ===== */
header {
  background: var(--primary);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.site-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  letter-spacing: -.01em;
  flex-shrink: 0;
}
.site-name em {
  font-style: normal;
  color: var(--warm);
}

/* Desktop nav */
.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: nowrap;
}
.nav-links a {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-weight: 500;
  font-size: .88rem;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.nav-links a:hover { background: rgba(255,255,255,.13); color: #fff; }
.nav-links a.nav-cta {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  margin-left: 6px;
}
.nav-links a.nav-cta:hover { background: var(--accent-dk); }

/* Hamburger button */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
}
.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform .25s, opacity .2s;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile nav drawer */
.nav-drawer {
  display: none;
  flex-direction: column;
  background: var(--primary-dk);
  padding: 8px 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.nav-drawer.open { display: flex; }
.nav-drawer a {
  color: rgba(255,255,255,.88);
  text-decoration: none;
  font-weight: 500;
  font-size: .98rem;
  padding: 13px 4px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.nav-drawer a:last-child { border-bottom: none; }
.nav-drawer a.nav-cta {
  background: var(--accent);
  color: #fff;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  text-align: center;
  margin-top: 10px;
  border-bottom: none;
  font-weight: 600;
}
.nav-drawer a.nav-cta:hover { background: var(--accent-dk); }

@media (max-width: 800px) {
  .nav-links { display: none; }
  .nav-toggle { display: flex; }
}

/* ===== Layout ===== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 32px;
}

/* ===== Cards ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin: 16px 0;
}

/* ===== Typography ===== */
h1, h2, h3 { margin: 0 0 12px; line-height: 1.25; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: .9rem;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:hover { background: var(--accent-dk); box-shadow: 0 3px 10px rgba(199,91,63,.25); }
.btn:active { transform: scale(.98); }
.btn.secondary {
  background: var(--card);
  color: var(--primary);
  border: 1.5px solid var(--border);
}
.btn.secondary:hover { background: var(--bg-alt); border-color: var(--primary); box-shadow: none; }
.btn.green {
  background: var(--primary);
  color: #fff;
}
.btn.green:hover { background: var(--primary-dk); box-shadow: 0 3px 10px rgba(45,74,45,.3); }
.btn-sm { padding: 6px 12px; font-size: .82rem; }

/* ===== Forms ===== */
label {
  display: block;
  font-weight: 600;
  font-size: .88rem;
  margin-bottom: 5px;
  color: var(--text);
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .93rem;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  margin-bottom: 14px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(199,91,63,.1);
}
input[type="file"] { padding: 8px 12px; cursor: pointer; }
textarea { resize: vertical; }

/* ===== Grid ===== */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
@media (max-width: 800px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 500px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ===== Recipe cards ===== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}
@media (max-width: 480px) {
  .cards { grid-template-columns: 1fr 1fr; gap: 12px; }
}
@media (max-width: 360px) {
  .cards { grid-template-columns: 1fr; }
}
.recipe-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  transition: box-shadow .2s, transform .18s;
  border: 1px solid rgba(230,216,204,.5);
}
.recipe-card:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); }
.recipe-card .thumb {
  aspect-ratio: 16/9;
  width: 100%;
  object-fit: cover;
  background: var(--bg-alt);
  display: block;
}
.recipe-card .thumb-placeholder {
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, var(--bg-alt) 0%, #E8D5C0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  color: var(--muted);
}
.recipe-card .pad {
  padding: 14px 16px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.recipe-card .pad strong { font-size: .97rem; line-height: 1.3; }
.recipe-card .pad .meta { margin: 5px 0 0; font-size: .82rem; flex: 1; }
.thumb-wrap { position: relative; }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  font-size: .76rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-alt);
  color: var(--primary);
  border: 1px solid var(--border);
}
.badge-new {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: .72rem;
  padding: 4px 10px;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,.22);
  letter-spacing: .02em;
}

/* ===== Pills ===== */
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  border: 1.5px solid var(--border);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
  transition: border-color .15s, background .15s;
}
.pill:hover { border-color: var(--accent); background: var(--accent-lt); color: var(--accent-dk); }
.pill.small { padding: 5px 12px; font-size: .82rem; }
.course-row { display: flex; flex-wrap: wrap; gap: 8px; }
.course-row a.btn { text-decoration: none; }

/* ===== Sections ===== */
.section { margin: 28px 0; }
.section h2 { margin-bottom: 14px; }
.meta { color: var(--muted); font-size: .91rem; }

/* ===== Home hero ===== */
.home-hero {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #1a120a;
  color: #fff;
  min-height: 320px;
  display: flex;
  align-items: flex-end;
}
.home-hero .bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: saturate(1.1) brightness(.7);
}
.home-hero .bg-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, rgba(0,0,0,.82) 0%, rgba(0,0,0,.5) 55%, rgba(0,0,0,.08) 90%);
}
.home-hero .inner {
  position: relative;
  z-index: 2;
  padding: 36px 32px;
  max-width: 620px;
  width: 100%;
}
.home-hero h1 { font-size: 2.4rem; margin-bottom: 8px; color: #fff; line-height: 1.15; }
.home-hero .meta { color: rgba(255,255,255,.78); margin-bottom: 0; }
.home-search { display: flex; gap: 8px; margin-top: 18px; }
.home-search input { flex: 1; margin-bottom: 0; background: rgba(255,255,255,.95); }
.hero-feat { margin-top: 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ===== Link button ===== */
.link-btn {
  background: transparent;
  border: 0;
  color: var(--accent);
  padding: 6px 0;
  cursor: pointer;
  font-weight: 600;
  font-size: .88rem;
}
.link-btn:hover { text-decoration: underline; }

/* ===== Auth pages ===== */
.auth-wrap {
  max-width: 440px;
  margin: 48px auto;
}
.auth-wrap .card { padding: 36px 32px; }
.auth-wrap h1 { margin-bottom: 4px; font-size: 1.7rem; }
.auth-subtitle { color: var(--muted); margin-bottom: 24px; font-size: .93rem; }
.auth-footer { text-align: center; margin-top: 20px; font-size: .88rem; color: var(--muted); }
.auth-footer a { color: var(--accent); font-weight: 600; text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

/* ===== Messages ===== */
.msg-error {
  background: #FEF2F2;
  color: #B91C1C;
  border: 1px solid #FECACA;
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  margin-bottom: 16px;
  font-size: .9rem;
}
.msg-success {
  background: #F0FDF4;
  color: #15803D;
  border: 1px solid #BBF7D0;
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  margin-bottom: 16px;
  font-size: .9rem;
}

/* ===== Dynamic ingredient / step rows ===== */
.dynamic-list { list-style: none; padding: 0; margin: 0 0 6px; }
.dynamic-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.dynamic-row .row-num {
  flex-shrink: 0;
  width: 26px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  color: var(--muted);
  padding-top: 2px;
}
.dynamic-row input,
.dynamic-row textarea {
  margin-bottom: 0;
  flex: 1;
}
.dynamic-row textarea { resize: none; overflow: hidden; min-height: 38px; }
.remove-row {
  flex-shrink: 0;
  background: none;
  border: 1.5px solid #FECACA;
  border-radius: 6px;
  color: #B91C1C;
  width: 34px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  transition: background .15s;
  flex-shrink: 0;
}
.remove-row:hover { background: #FEF2F2; }
.add-row-btn {
  background: none;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--primary);
  font-weight: 600;
  font-size: .88rem;
  padding: 9px 14px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: border-color .15s, background .15s, color .15s;
  margin-bottom: 14px;
}
.add-row-btn:hover { border-color: var(--accent); background: var(--accent-lt); color: var(--accent); }

/* ===== Advanced options toggle ===== */
.advanced-toggle {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--primary);
  font-weight: 600;
  font-size: .88rem;
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 16px;
  transition: background .15s, border-color .15s;
  width: 100%;
}
.advanced-toggle:hover { background: var(--bg-alt); border-color: var(--primary); }
.advanced-toggle .arrow { transition: transform .2s; display: inline-block; font-style: normal; }
.advanced-toggle[aria-expanded="true"] .arrow { transform: rotate(90deg); }
.advanced-section { display: none; }
.advanced-section.open { display: block; }

/* ===== Photo preview ===== */
.photo-preview-wrap { margin: -8px 0 14px; }
.photo-preview {
  max-width: 300px;
  max-height: 200px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  display: none;
  object-fit: cover;
  margin-top: 8px;
}

/* ===== Form section divider ===== */
.form-section {
  border-top: 1.5px solid var(--border);
  padding-top: 20px;
  margin-top: 6px;
}
.form-section h3 { margin-bottom: 14px; color: var(--primary); }

/* ===== Footer ===== */
footer {
  background: var(--primary);
  color: rgba(255,255,255,.75);
  text-align: center;
  padding: 28px 20px;
  margin-top: 48px;
  font-size: .88rem;
}
footer a { color: rgba(255,255,255,.75); }

/* ===== Scroll margin ===== */
.anchor-offset { scroll-margin-top: 80px; }

/* ===== Mobile pantry collapse ===== */
.pill-wrap { position: relative; }
@media (max-width: 640px) {
  .home-hero { min-height: 280px; }
  .home-hero .inner { padding: 22px 18px; }
  .home-hero h1 { font-size: 1.65rem; }
  .home-search { flex-wrap: wrap; }
  .home-search input { min-width: 0; }
  .pill-wrap:not(.expanded) #pantryRow {
    max-height: 48px;
    overflow: hidden;
    position: relative;
  }
  .pill-wrap:not(.expanded) #pantryRow::after {
    content: "";
    position: absolute; right: 0; top: 0; bottom: 0; width: 52px;
    background: linear-gradient(90deg, rgba(254,252,248,0), var(--bg));
  }
  .pill.small { padding: 4px 10px; font-size: .8rem; }
  .auth-wrap { margin: 24px auto; }
  .auth-wrap .card { padding: 24px 18px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
}
