:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --surface-subtle: #f3efe7;
  --ink: #1e1c1a;
  --muted: #645d55;
  --border: #e5dfd4;
  --accent: #9a4a24;
  --accent-soft: #f6e7de;
  --radius: 10px;
  --max: 1080px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151413;
    --surface: #1e1c1a;
    --surface-subtle: #272421;
    --ink: #f2ede6;
    --muted: #aba298;
    --border: #332e2a;
    --accent: #e08b5c;
    --accent-soft: #33231b;
  }
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 20px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
}

.brand {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.back-link,
.count-pill {
  font-size: 0.9rem;
  color: var(--muted);
  text-decoration: none;
}

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

.home-page,
.recipe-page {
  padding-top: 28px;
  padding-bottom: 56px;
}

.search-bar {
  margin-bottom: 22px;
}

.search-bar input {
  width: 100%;
  padding: 12px 15px;
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
}

.search-bar input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.recipe-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.recipe-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.recipe-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.recipe-card h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  line-height: 1.3;
  color: var(--ink);
}

.badge {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.card-meta {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.recipe-hero {
  margin-bottom: 24px;
}

.recipe-hero h1 {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 4vw, 2.4rem);
  line-height: 1.15;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.chip {
  font-size: 0.85rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--muted);
  border: 1px solid var(--border);
}

.source-line {
  margin: 6px 0 0;
  font-size: 0.92rem;
  color: var(--muted);
}

.diagram-block {
  margin-bottom: 26px;
}

.diagram-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.diagram-head h2,
.card h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.diagram-head h2 {
  margin-bottom: 0;
}

.full-link {
  font-size: 0.88rem;
  text-decoration: none;
}

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

.diagram-frame {
  display: block;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.diagram-frame img {
  display: block;
  width: 100%;
  height: auto;
}

.recipe-grid {
  display: grid;
  grid-template-columns: minmax(250px, 340px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.col-ingredients,
.col-prep {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.ingredient-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.check-item input[type="checkbox"] {
  margin-top: 4px;
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.check-item input:checked + span {
  text-decoration: line-through;
  color: var(--muted);
}

.subhead {
  font-weight: 600;
  margin: 14px 0 6px;
}

.step-list {
  margin: 0;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.notes-card p:first-of-type {
  margin-top: 0;
}

.notes-card ul {
  margin: 8px 0 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.gallery img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  display: block;
}

.empty {
  color: var(--muted);
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 18px 0;
  font-size: 0.85rem;
  color: var(--muted);
}

@media (max-width: 780px) {
  .recipe-grid {
    grid-template-columns: 1fr;
  }
}

@media print {
  .site-header,
  .site-footer,
  .full-link {
    display: none;
  }
  body {
    background: #fff;
    color: #000;
  }
  .card,
  .diagram-frame {
    border-color: #ccc;
  }
}
