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

:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --border: #e8e5e0;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --accent: #c2541a;
  --accent-light: #fdf0e8;
  --tag-bg: #f0ede8;
  --tag-active-bg: #c2541a;
  --tag-active-text: #ffffff;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,0.07);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Header ── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 20px 24px;
}

header a {
  text-decoration: none;
  color: inherit;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

header h1 span {
  color: var(--accent);
}

/* ── Layout ── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Search & Filters ── */
.controls {
  padding: 28px 0 20px;
}

.search-wrap {
  position: relative;
  margin-bottom: 16px;
}

.search-wrap svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

#search {
  width: 100%;
  padding: 12px 16px 12px 42px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s;
  color: var(--text);
}

#search:focus {
  border-color: var(--accent);
}

#search::placeholder {
  color: var(--text-muted);
}

.filters-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex: 1;
}

/* ── View toggle ── */
.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
}

.view-btn {
  padding: 7px 10px;
  background: var(--surface);
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  transition: background 0.15s, color 0.15s;
}

.view-btn:first-child {
  border-right: 1px solid var(--border);
}

.view-btn:hover {
  background: var(--tag-bg);
  color: var(--text);
}

.view-btn.active {
  background: var(--tag-bg);
  color: var(--text);
}

.tag {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
  background: var(--tag-bg);
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}

.tag:hover {
  background: #e2ddd6;
  color: var(--text);
}

.tag.active {
  background: var(--tag-active-bg);
  color: var(--tag-active-text);
}

/* ── Recipe Grid ── */
#results-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  padding-bottom: 48px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}

.card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.card-img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
  background: var(--tag-bg);
}

.card-img-placeholder {
  width: 100%;
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, #f0ede8 0%, #e8e3dc 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #bbb;
  font-size: 2rem;
}

.card-body {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.card-tag {
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--tag-bg);
  color: var(--text-muted);
}

.card-tag.highlight {
  background: var(--accent-light);
  color: var(--accent);
}

/* ── No-image view ── */
body.no-images .card-img,
body.no-images .card-img-placeholder {
  display: none;
}

body.no-images .grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

body.no-images .card-body {
  padding: 14px 16px;
}

/* ── Empty state ── */
.empty {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted);
  grid-column: 1 / -1;
}

.empty p:first-child {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

/* ── Recipe Page ── */
.recipe-page {
  max-width: 720px;
  margin: 40px auto;
  padding: 0 24px 64px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 28px;
  transition: color 0.15s;
}

.back-link:hover {
  color: var(--accent);
}

.recipe-header {
  margin-bottom: 28px;
}

.recipe-header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 12px;
}

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

.recipe-img {
  width: 100%;
  border-radius: var(--radius);
  margin-bottom: 36px;
  display: block;
}

.recipe-section {
  margin-bottom: 36px;
}

.recipe-section h2 {
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.ingredients-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ingredients-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

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

.instructions {
  white-space: pre-wrap;
  line-height: 1.8;
  color: var(--text);
}

/* ── Not found ── */
.not-found {
  text-align: center;
  padding: 80px 24px;
}

.not-found h2 {
  font-size: 1.4rem;
  margin-bottom: 8px;
}

.not-found a {
  color: var(--accent);
}
