:root {
  --ink: #2c2a29;
  --paper: #faf7f2;
  --paper-dim: #f1ebe0;
  --accent: #c85a32;
  --accent-soft: #f0dccc;
  --sage: #6b7a63;
  --sage-soft: #e2e7de;
  --line: #e5ddce;
  --muted: #746c60;
  --font-heading: "Playfair Display", Georgia, "Times New Roman", serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-family: var(--font-body);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, .site-title { font-family: var(--font-heading); }

.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--line);
}
.site-title { font-size: 1.5rem; font-weight: 700; color: var(--ink); }
.site-header nav a { margin-left: 1.5rem; color: var(--ink); font-weight: 500; }

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem;
}

.site-footer {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.hero { text-align: center; margin-bottom: 1.5rem; }
.hero h1 { font-size: 2.6rem; margin-bottom: 0.25rem; }
.hero p { color: var(--muted); }

.search-bar {
  max-width: 480px;
  margin: 0 auto 1.5rem;
  position: relative;
}
.search-bar input {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: 0.7rem 1rem 0.7rem 2.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}
.search-bar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-bar svg {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search-empty {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
  display: none;
}

.search-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 0.4rem);
  left: 0;
  right: 0;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(44, 42, 41, 0.12);
  max-height: 22rem;
  overflow-y: auto;
  text-align: left;
}
.search-results li a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  color: var(--ink);
}
.search-results li a:hover { text-decoration: none; }
.search-results li:hover a,
.search-results li.active a {
  background: var(--accent-soft);
}
.search-title { font-weight: 500; }
.search-cat {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  white-space: nowrap;
}
.search-none {
  padding: 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.tag-cloud {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  padding: 0;
  margin: 0 auto 2.25rem;
  max-width: 700px;
}
.tag-cloud a {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  background: var(--sage-soft);
  color: var(--sage);
}
.tag-cloud a:hover {
  text-decoration: none;
  background: var(--sage);
  color: var(--paper);
}
.tag-cloud a:hover .tag-count { color: var(--paper); opacity: 0.75; }
.tag-count { color: var(--muted); font-variant-numeric: tabular-nums; }

.category-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem;
}
.category-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-dim);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.category-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(44,42,41,0.08); }
.category-card { overflow: hidden; }
.category-card a {
  display: block;
  color: inherit;
}
.category-card a:hover { text-decoration: none; }
.category-photo {
  display: block;
  width: 100%;
  height: 130px;
  object-fit: cover;
  background: var(--accent-soft);
}
.category-photo-blank {
  display: flex;
  align-items: center;
  justify-content: center;
}
.category-card-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.3rem;
  padding: 1rem 1.25rem 1.35rem;
}
.category-card h2 { font-size: 1.15rem; margin: 0; }
.category-count { font-size: 0.85rem; color: var(--muted); }

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}
.back-link:hover { color: var(--accent); }
.category-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}
.category-hero h1 { font-size: 2.4rem; margin: 0; }

.recipe-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.recipe-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-dim);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.recipe-row:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(44,42,41,0.06); }
.recipe-row a { display: block; padding: 0.9rem 1.25rem; color: inherit; }
.recipe-row a:hover { text-decoration: none; }
.recipe-row h2 { font-size: 1.05rem; margin: 0; }
.recipe-category {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  font-weight: 600;
}
.recipe-story {
  font-style: italic;
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.2rem 0 0;
}

.recipe-hero {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 0.5rem;
}
.recipe h1 { font-size: 2.3rem; margin: 0.25rem 0 1rem; }
.headnote, .story {
  font-style: italic;
  color: var(--muted);
  border-left: 3px solid var(--sage);
  padding-left: 1rem;
  margin: 1rem 0;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  margin: 1.25rem 0;
  padding: 1rem 1.25rem;
  background: var(--paper-dim);
  border-radius: 8px;
}
.meta dt { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.meta dd { margin: 0 0 0.5rem; font-weight: 600; }

.tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0;
  margin: 0 0 1.5rem;
}
.tags li {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--sage-soft);
  color: var(--sage);
}

.recipe-body h2 {
  font-size: 1.3rem;
  border-bottom: 2px solid var(--accent-soft);
  padding-bottom: 0.25rem;
  margin-top: 2rem;
}
.recipe-body ul, .recipe-body ol { padding-left: 1.4rem; }
.recipe-body li { margin-bottom: 0.4rem; }

.main-top {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.back-btn {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
}
.back-btn:hover {
  text-decoration: none;
  color: var(--accent);
  border-color: var(--accent);
}

.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1.75rem;
}

.recipe-desc { color: var(--muted); font-size: 0.9rem; margin: 0.2rem 0 0; }
.recipe-desc.lead {
  font-size: 1.05rem;
  color: var(--ink);
  margin: 0 0 1.25rem;
}

.recipe-photo { margin: 0 0 1.5rem; }
.recipe-photo img {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  border-radius: 12px;
  display: block;
}
.recipe-photo figcaption {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.4rem;
}
.recipe-photo { position: relative; }
.recipe-photo.is-stand-in img { opacity: 0.9; }
.stand-in-note { font-style: italic; }
.photo-swap {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink);
  background: rgba(253, 251, 247, 0.92);
  border: 1px solid rgba(44, 42, 41, 0.12);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.photo-swap:hover { background: var(--paper); color: var(--accent); }
.photo-status {
  font-size: 0.85rem;
  color: var(--sage);
  margin: -0.75rem 0 1rem;
  min-height: 1.2em;
}

.tags li a { color: inherit; }
.tags li a:hover { text-decoration: none; }
.tags li:hover { background: var(--sage); }
.tags li:hover a { color: var(--paper); }

.cook-note {
  padding: 0.85rem 1.1rem;
  background: #fdf6ee;
  border-left: 3px solid #d8a45a;
  border-radius: 6px;
  font-size: 0.92rem;
  color: #6b5a3a;
  margin: 1.25rem 0;
}

.notes-block, .photo-block {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}
.notes-block h2, .photo-block h2 {
  font-size: 1.2rem;
  margin: 0 0 0.35rem;
}
.notes-hint { font-size: 0.85rem; color: var(--muted); margin: 0 0 0.75rem; }
#recipe-notes {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  resize: vertical;
}
#recipe-notes:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.notes-status {
  font-size: 0.8rem;
  color: var(--sage);
  min-height: 1.2em;
  margin: 0.35rem 0 0;
}

.stack-form { display: flex; flex-direction: column; gap: 0.9rem; }
.stack-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
}
.stack-form input[type="text"],
.stack-form input[type="file"],
.stack-form select,
.stack-form textarea {
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  width: 100%;
}
.stack-form textarea { resize: vertical; }
.stack-form input:focus, .stack-form select:focus, .stack-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.stack-form button {
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.6rem 1.4rem;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  cursor: pointer;
  align-self: flex-start;
}
.stack-form button:hover { filter: brightness(1.07); }
.stack-form button.secondary {
  background: transparent;
  color: var(--accent);
}
.form-row { display: flex; gap: 0.9rem; flex-wrap: wrap; }
.form-row label { flex: 1 1 12rem; }
.form-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.hidden-field { display: none; }

.markdown-preview {
  margin-top: 2rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-dim);
}
.markdown-preview summary { cursor: pointer; font-weight: 600; }
.markdown-preview pre {
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.5;
  background: white;
  padding: 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.print-btn {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  cursor: pointer;
}
.print-btn:hover { color: var(--accent); border-color: var(--accent); }

.history-block {
  margin: 1.5rem 0;
  padding: 1.1rem 1.3rem;
  background: var(--sage-soft);
  border-radius: 10px;
}
.history-block h2 {
  font-size: 1rem;
  margin: 0 0 0.4rem;
  color: var(--sage);
}
.history-block p { margin: 0; }

/* ---------- phones ---------- */
@media (max-width: 640px) {
  main { padding: 1.25rem 1rem 2rem; }

  .site-header {
    padding: 0.85rem 1rem;
    flex-wrap: wrap;
    gap: 0.2rem 1rem;
  }
  .site-title { font-size: 1.2rem; }
  .site-header nav { display: flex; gap: 1rem; }
  .site-header nav a { margin-left: 0; font-size: 0.85rem; }

  .hero h1 { font-size: 1.95rem; }
  .hero p { font-size: 0.95rem; }

  .category-hero { gap: 0.6rem; }
  .category-hero h1 { font-size: 1.75rem; }
  .category-hero .category-art { width: 40px; height: 40px; }

  .recipe-hero { gap: 0.8rem; }
  .recipe-hero .category-art { width: 42px; height: 42px; }
  .recipe h1 { font-size: 1.7rem; }
  .recipe-desc.lead { font-size: 1rem; }

  .recipe-photo img { max-height: 260px; }
  .recipe-photo figcaption { flex-direction: column; gap: 0.15rem; }

  .tag-cloud { gap: 0.3rem; margin-bottom: 1.75rem; }
  .tag-cloud a { font-size: 0.73rem; padding: 0.18rem 0.55rem; }

  .category-photo { height: 150px; }
  .category-grid { gap: 1rem; }

  .meta { gap: 0.15rem 1.25rem; padding: 0.85rem 1rem; }
  .search-results { max-height: 60vh; }
  .form-row { flex-direction: column; gap: 0.9rem; }
  .subnav { gap: 0.4rem; }
  .chip { font-size: 0.82rem; padding: 0.35rem 0.7rem; }
}

/* ---------- paper ---------- */
@media print {
  .site-header,
  .site-footer,
  .main-top,
  .recipe-photo,
  .notes-block,
  .photo-block,
  .photo-status,
  .search-bar,
  .tag-cloud,
  .subnav,
  .tags,
  .category-grid,
  .recipe-hero .category-art {
    display: none !important;
  }

  :root { --ink: #000; --muted: #333; }

  body {
    background: white;
    color: #000;
    font-size: 11pt;
    line-height: 1.4;
  }
  main { max-width: none; margin: 0; padding: 0; }

  .recipe h1 { font-size: 21pt; margin: 0 0 0.35rem; }
  .recipe-hero { display: block; margin-bottom: 0.35rem; }
  .recipe-category { font-size: 8pt; }
  .recipe-desc.lead { font-size: 11pt; margin-bottom: 0.6rem; }

  .meta {
    background: none;
    border: 1px solid #bbb;
    border-radius: 0;
    padding: 0.5rem 0.75rem;
    margin: 0.6rem 0;
  }
  .meta dt { color: #555; }

  .headnote, .story, .history-block {
    background: none;
    border: none;
    border-left: 2px solid #bbb;
    border-radius: 0;
    padding: 0 0 0 0.75rem;
    margin: 0.5rem 0;
  }
  .history-block h2 { font-size: 10pt; color: #555; }

  .cook-note {
    background: none;
    border: 1px solid #999;
    border-left: 3px solid #666;
    border-radius: 0;
    color: #000;
  }

  .recipe-body h2 {
    font-size: 13pt;
    border-bottom: 1px solid #999;
    margin-top: 1rem;
    page-break-after: avoid;
    break-after: avoid;
  }
  .recipe-body li,
  .recipe-body ul,
  .recipe-body ol {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  a { color: #000; text-decoration: none; }
}
