:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --ink: #2b2320;
  --muted: #8a7f77;
  --accent: #e2542f;
  --accent-dark: #c23f1e;
  --border: #eee4da;
  --shadow: 0 6px 18px rgba(43, 35, 32, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(250, 247, 242, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
}

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

.logo {
  font-size: 2rem;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #ffe3d0, #ffc39a);
  border-radius: 50%;
  box-shadow: var(--shadow);
}

h1 { margin: 0; font-size: 1.5rem; letter-spacing: -0.02em; }
#subtitle { margin: 2px 0 0; color: var(--muted); font-size: 0.85rem; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; }

.controls input,
.controls select {
  font: inherit;
  font-size: 0.9rem;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.controls input:focus,
.controls select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(226, 84, 47, 0.15);
}

#search { width: 240px; max-width: 100%; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  padding: 24px;
  max-width: 1440px;
  margin: 0 auto;
}

.tile {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--border);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.tile:hover { transform: translateY(-3px); box-shadow: 0 12px 26px rgba(43, 35, 32, 0.16); }

.tile .photo {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-color: #f0e7dc;
  transition: transform 0.4s ease;
}

.tile:hover .photo { transform: scale(1.05); }

.tile .photo.placeholder {
  background: linear-gradient(135deg, #ffb88c, #e2542f);
  background-size: cover;
}

.tile .shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(20, 12, 8, 0.82) 0%, rgba(20, 12, 8, 0.25) 45%, transparent 70%);
}

.tile .info {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 12px 14px;
  color: #fff;
}

.tile .title {
  font-weight: 700;
  font-size: 1.02rem;
  line-height: 1.25;
  margin: 0 0 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tile .meta { display: flex; flex-wrap: wrap; gap: 6px; }

.badge {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
}

.badge.cat { background: var(--accent); color: #fff; }
.badge.easy { background: #7bc96f; color: #fff; }
.badge.medium { background: #f0a34b; color: #fff; }
.badge.hard { background: #d95c4f; color: #fff; }

.tile .src {
  position: absolute;
  top: 10px; right: 10px;
  font-size: 0.7rem;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  padding: 3px 9px;
  border-radius: 999px;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s;
}

.tile:hover .src { opacity: 1; }

.empty { text-align: center; color: var(--muted); padding: 40px; }

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 24px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(25, 15, 10, 0.55);
  backdrop-filter: blur(3px);
  animation: fade 0.2s ease;
}

.modal-content {
  position: relative;
  background: #fff;
  border-radius: var(--radius);
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  animation: pop 0.22s ease;
}

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.98); } }

.modal-close {
  position: sticky;
  top: 12px;
  float: right;
  margin: 12px 12px 0 0;
  z-index: 5;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover { background: rgba(0, 0, 0, 0.7); }

.modal-hero {
  height: 230px;
  background-size: cover;
  background-position: center;
  background-color: #f0e7dc;
}

.modal-hero.placeholder {
  background: linear-gradient(135deg, #ffb88c, #e2542f);
  display: grid;
  place-items: center;
  font-size: 4rem;
}

.modal-body-inner { padding: 24px 26px 26px; position: relative; }

.modal-title { font-size: 1.6rem; margin: 0 0 8px; letter-spacing: -0.02em; }

.modal-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.modal-chips .badge { background: var(--border); }
.modal-chips .badge.cat { background: var(--accent); }

.source-link {
  display: inline-block;
  margin: 4px 0 18px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.source-link:hover { text-decoration: underline; }

.columns { display: grid; grid-template-columns: 1fr 1.4fr; gap: 26px; }
@media (max-width: 640px) { .columns { grid-template-columns: 1fr; } }

.columns h2 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.ingredients { list-style: none; margin: 0; padding: 0; }
.ingredients li {
  padding: 7px 0 7px 22px;
  border-bottom: 1px dashed var(--border);
  position: relative;
}
.ingredients li::before {
  content: "";
  position: absolute;
  left: 2px; top: 14px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps li {
  counter-increment: step;
  position: relative;
  padding: 8px 0 8px 40px;
  line-height: 1.55;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 10px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.obtained { margin-top: 20px; font-size: 0.78rem; color: var(--muted); }
