:root {
  --bg: #f6f4f1;
  --surface: #ffffff;
  --surface-2: #f1eee9;
  --text: #1f1d1a;
  --muted: #6b665e;
  --border: #e3ded6;
  --accent: #c2410c;
  --accent-hover: #9a3412;
  --accent-soft: #fdebdd;
  --heart: #e11d48;
  --topbar: #1f1d1a;
  --topbar-text: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .06);
  --radius: 10px;
  --sidebar: 248px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --surface: #211f1c;
    --surface-2: #2b2925;
    --text: #f2efe9;
    --muted: #a9a399;
    --border: #3a3732;
    --accent: #fb923c;
    --accent-hover: #fdba74;
    --accent-soft: #3b2417;
    --heart: #fb7185;
    --topbar: #0d0c0b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
img { display: block; max-width: 100%; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
main:focus { outline: none; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--topbar);
  color: var(--topbar-text);
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  font-size: 20px;
  white-space: nowrap;
}

.search {
  flex: 1;
  display: flex;
  max-width: 760px;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  padding: 10px 14px;
  font: inherit;
  color: #1f1d1a;
  background: #fff;
}

.search input:focus { outline: none; }
.search:focus-within { box-shadow: 0 0 0 3px var(--accent); }

.search button {
  border: 0;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.search button:hover { background: var(--accent-hover); }

.account {
  display: flex;
  align-items: center;
  gap: 14px;
  white-space: nowrap;
}

.account a, .account button.linklike {
  color: var(--topbar-text);
  text-decoration: none;
  font-size: 14px;
}

.account a:hover, .account button.linklike:hover { text-decoration: underline; }
.account .btn { color: #fff; }
.account .hello { color: #cfc9bf; font-size: 13px; }

/* ---------- Buttons & forms ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  background: var(--accent);
  color: #fff;
}

.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.danger { background: transparent; color: #dc2626; border-color: #dc2626; }
.btn.danger:hover { background: #dc2626; color: #fff; }

button.linklike {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
}

label { font-weight: 600; font-size: 14px; }

input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; min-height: 120px; }

/* ---------- Browse layout ---------- */

.shop {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  gap: 24px;
  align-items: start;
}

.filters {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 16px 16px;
}

.filters-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0 4px;
}

.filters-head h2 { font-size: 16px; margin: 0; }
.filters-close { display: none; }

.facet { border-top: 1px solid var(--border); padding: 8px 0; }
.facet:first-of-type { border-top: 0; }

.facet summary {
  list-style: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  padding: 6px 0;
  display: flex;
  justify-content: space-between;
}

.facet summary::-webkit-details-marker { display: none; }
.facet summary::after { content: "−"; color: var(--muted); }
.facet:not([open]) summary::after { content: "+"; }

.facet-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-weight: 400;
  font-size: 14px;
  cursor: pointer;
}

.facet-option input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.facet-option .count { margin-left: auto; color: var(--muted); font-size: 12px; }
.facet-option.empty { color: var(--muted); }

.results-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.results-bar h1 { font-size: 22px; margin: 0; }
.results-bar .summary { color: var(--muted); font-size: 14px; }
.results-tools { display: flex; align-items: center; gap: 10px; }
.results-tools select { width: auto; padding: 7px 10px; }
.show-filters { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chips:empty { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.chip:hover { border-color: var(--accent); }
.chip span[aria-hidden] { color: var(--muted); }

/* ---------- Cards ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow .15s, transform .15s;
}

.card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.card > a { color: inherit; text-decoration: none; display: flex; flex-direction: column; flex: 1; }

.thumb {
  aspect-ratio: 4 / 3;
  width: 100%;
  object-fit: cover;
  background: var(--surface-2);
}

.thumb.placeholder {
  display: grid;
  place-items: center;
  font-size: 56px;
  background: linear-gradient(135deg, var(--accent-soft), var(--surface-2));
}

.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-title { font-size: 16px; font-weight: 700; margin: 0; }
.card-meta { color: var(--muted); font-size: 13px; }
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; padding-top: 8px; }

.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-hover);
}

@media (prefers-color-scheme: dark) { .tag { color: var(--accent); } }

.heart {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .92);
  color: #57534e;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
}

.heart:hover { color: var(--heart); }
.heart.on { color: var(--heart); }
.heart svg { width: 20px; height: 20px; }

.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 28px; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty-state .big { font-size: 48px; }

.skeleton { background: var(--surface-2); border-radius: var(--radius); aspect-ratio: 3 / 4; animation: pulse 1.2s infinite alternate; }
@keyframes pulse { to { opacity: .5; } }

/* ---------- Recipe detail ---------- */

.page { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.crumbs { font-size: 14px; margin-bottom: 16px; color: var(--muted); }

.detail {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.detail .thumb { border-radius: 8px; }
.detail h1 { font-size: 30px; }
.detail .by { color: var(--muted); margin-bottom: 12px; }

.facts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 16px 0;
}

.fact { background: var(--surface-2); border-radius: 8px; padding: 10px; text-align: center; }
.fact b { display: block; font-size: 18px; }
.fact span { font-size: 12px; color: var(--muted); }

.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.detail-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
  gap: 32px;
  margin-top: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.ingredients ul { padding-left: 20px; margin: 0; }
.ingredients li { margin-bottom: 6px; }
.steps ol { padding-left: 0; margin: 0; list-style: none; counter-reset: step; }

.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 44px;
  margin-bottom: 18px;
  white-space: pre-line;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -2px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
}

/* ---------- Forms ---------- */

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.auth { max-width: 420px; margin: 40px auto; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field .hint { color: var(--muted); font-size: 13px; font-weight: 400; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.checks label { font-weight: 400; display: flex; gap: 6px; align-items: center; }
.checks input { accent-color: var(--accent); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.error { color: #dc2626; font-size: 14px; min-height: 1.5em; }
.photo-preview { max-height: 220px; border-radius: 8px; margin-top: 8px; object-fit: cover; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Small screens ---------- */

@media (max-width: 860px) {
  .topbar-inner { flex-wrap: wrap; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .account { margin-left: auto; }

  .shop { grid-template-columns: 1fr; }
  .show-filters { display: inline-flex; }

  .filters {
    position: fixed;
    inset: 0 auto 0 0;
    top: 0;
    width: min(320px, 88vw);
    max-height: none;
    border-radius: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform .2s;
  }

  .filters.open { transform: none; box-shadow: var(--shadow); }
  .filters-close { display: inline-flex; }
  .backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 30; }

  .detail, .detail-content { grid-template-columns: 1fr; padding: 16px; }
  .facts { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card-body { padding: 10px; }
  .card-title { font-size: 14px; }
  .brand span { display: none; }
  .account { gap: 10px; }
  .account a, .account button.linklike { font-size: 13px; }
  .account .wide { display: none; }
  .account .hello { display: none; }
  .account .btn { padding: 6px 10px; }
}

/* ---------- Photos ---------- */

.photo-list { display: flex; flex-wrap: wrap; gap: 10px; }
.photo-list:empty { display: none; }
.photo-tile { position: relative; width: 140px; }
.photo-tile img { width: 140px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

.photo-tile .cover {
  position: absolute;
  left: 6px;
  bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, .65);
  color: #fff;
}

.photo-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, .65);
  color: #fff;
  cursor: pointer;
}

.photo-remove:hover { background: #dc2626; }
p.hint, span.hint { color: var(--muted); font-size: 13px; }

.gallery { display: flex; flex-direction: column; gap: 10px; }
.gallery-strip { display: flex; gap: 8px; overflow-x: auto; }

.gallery-thumb {
  flex: 0 0 auto;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  background: none;
  cursor: pointer;
}

.gallery-thumb.on { border-color: var(--accent); }
.gallery-thumb img { width: 84px; aspect-ratio: 4 / 3; object-fit: cover; }

/* ---------- Sign-up agreement & footer ---------- */

.agree { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; margin-bottom: 12px; }
.agree input { margin-top: 4px; accent-color: var(--accent); }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 16px 32px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.site-footer a { color: var(--muted); margin: 0 8px; }

/* ---------- Legal pages ---------- */

.legal { max-width: 760px; line-height: 1.65; }
.legal h2 { font-size: 19px; margin-top: 28px; }
.legal li { margin-bottom: 6px; }
.legal mark { background: #fde68a; color: #1f1d1a; padding: 0 3px; border-radius: 3px; }
