:root {
  --bg: #f7f4ea;
  --bg-2: #fffdf6;
  --ink: #2b2a24;
  --muted: #6b675c;
  --line: #ddd6c4;
  --olive: #6b7a4d;
  --olive-dark: #4e5a36;
  --terracotta: #b85c38;
  --shadow: 0 10px 30px rgba(43, 42, 36, 0.08);
  --radius: 16px;
  --font: "Source Sans 3", "Segoe UI", sans-serif;
  --serif: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: radial-gradient(circle at top left, #fff 0, var(--bg) 45%);
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
a { color: var(--olive-dark); }
button, input, select, textarea { font: inherit; }
.sr-only, .skip {
  position: absolute;
  left: -999px;
}
.skip:focus { left: 1rem; top: 1rem; background: #fff; padding: 0.5rem; z-index: 20; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(247, 244, 234, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 1rem;
  align-items: center;
}
.brand {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  text-decoration: none;
  color: inherit;
}
.brand-logo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: block;
  background: #f7f4ea;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--serif); font-size: 1.15rem; }

.search-form {
  display: flex;
  gap: 0.4rem;
}
.search-form input,
.search-form select,
.stack input,
.stack textarea,
.recipe-form input:not([type="checkbox"]):not([type="file"]),
.recipe-form textarea,
.recipe-form select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 0.6rem 0.95rem;
}
.recipe-form input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--olive-dark);
  flex-shrink: 0;
}
.recipe-form textarea,
.stack textarea { border-radius: 12px; resize: vertical; }
.search-form button,
.btn {
  border: 0;
  background: var(--olive);
  color: #fff;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.btn.primary { background: var(--olive-dark); }
.btn.danger { background: var(--terracotta); }
.header-links {
  display: flex;
  gap: 0.85rem;
  align-items: center;
}
.header-links form { margin: 0; }
.header-links button {
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--olive-dark);
  font-weight: 600;
}

.shell {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.5rem;
  padding: 1.5rem 1.25rem 3rem;
}
.sidebar {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  height: fit-content;
  position: sticky;
  top: 88px;
}
.sidebar h2 { font-family: var(--serif); font-size: 1.05rem; margin: 0 0 0.6rem; }
.cat-group { border-bottom: 1px solid var(--line); }
.cat-group summary {
  list-style: none;
  cursor: pointer;
  padding: 0.45rem 0;
  font-weight: 600;
}
.cat-group summary::-webkit-details-marker { display: none; }
.cat-group ul { margin: 0 0 0.5rem; padding: 0 0 0 0.8rem; list-style: none; }
.cat-group li { margin: 0.2rem 0; }
.cat-group a { text-decoration: none; color: var(--ink); }
.cat-group a:hover { color: var(--olive-dark); }

.main { min-width: 0; }
.hero, .recipe-hero, .page-copy, .auth-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.hero {
  display: grid;
  gap: 1.5rem;
  margin-bottom: 2rem;
  align-items: start;
}
.hero-with-image {
  grid-template-columns: 1fr;
}
@media (min-width: 1200px) {
  .hero-with-image {
    grid-template-columns: 0.9fr 1.3fr;
  }
}
.hero-figure,
.hero-copy { min-width: 0; }
.hero-figure { margin: 0; }
.hero-image { width: 100%; height: 280px; object-fit: cover; border-radius: 12px; }
.hero-caption {
  margin: 0.7rem 0 0;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
  font-style: normal;
  line-height: 1.45;
}
.hero-caption-form {
  margin: 0.7rem 0 0;
  display: grid;
  gap: 0.5rem;
}
.hero-caption-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 0.6rem 0.95rem;
  resize: vertical;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
}
.hero-caption-form .btn {
  justify-self: start;
}
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; color: var(--olive); font-size: 0.78rem; font-weight: 700; }
h1, h2, h3 { font-family: var(--serif); font-weight: 650; line-height: 1.2; }
h1 { font-size: clamp(1.8rem, 3vw, 2.6rem); margin: 0.2rem 0 0.8rem; }
.prose { line-height: 1.55; color: #3a382f; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; }
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}
.card-grid.compact { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.recipe-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
}
.recipe-card h3 { margin: 0.6rem 0.75rem 0.2rem; font-size: 1.02rem; }
.recipe-card .meta { margin: 0 0.75rem 0.85rem; color: var(--muted); font-size: 0.88rem; }
.thumb { aspect-ratio: 4/3; background: #ece6d4; overflow: hidden; }
.thumb > img { width: 100%; height: 100%; object-fit: cover; }
.thumb-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  line-height: 1.2;
}
.thumb-empty-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  flex-shrink: 0;
}
.card-grid.compact .thumb-empty { font-size: 0.78rem; gap: 0.25rem; }
.card-grid.compact .thumb-empty-logo { width: 40px; height: 40px; }

.recipe-hero { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 1.5rem; margin-bottom: 1.5rem; }
.recipe-photo img { width: 100%; border-radius: 12px; max-height: 420px; object-fit: cover; }
.recipe-grid { display: grid; grid-template-columns: 0.85fr 1.15fr; gap: 1.25rem; }
.recipe-grid section, .notes {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}
.ingredients { white-space: pre-wrap; }
.pill {
  display: inline-block;
  background: #e7ecd8;
  color: var(--olive-dark);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  text-decoration: none;
  margin-right: 0.3rem;
  font-size: 0.85rem;
}
.pill.muted { background: #eee; color: var(--muted); }
.recipe-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }
.recipe-actions button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 0.45rem 0.9rem; cursor: pointer; }
.crumbs { display: flex; gap: 0.4rem; color: var(--muted); margin-bottom: 0.8rem; font-size: 0.92rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.page-head-copy { min-width: 0; }
.page-head-copy p { margin: 0; color: var(--muted); }
.recipe-sort {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.recipe-sort-label {
  color: var(--muted);
  font-size: 0.88rem;
  margin-right: 0.15rem;
}
.recipe-sort a {
  text-decoration: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  color: var(--ink);
  font-size: 0.92rem;
}
.recipe-sort a.is-active {
  background: var(--olive-dark);
  border-color: var(--olive-dark);
  color: #fff;
}
.recipe-card .recipe-views {
  color: var(--olive-dark);
  font-weight: 600;
}
.subcats { display: flex; flex-wrap: wrap; gap: 0.45rem; list-style: none; padding: 0; }
.subcats a { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 0.3rem 0.75rem; text-decoration: none; }
.empty, .flash { background: #fff; border: 1px dashed var(--line); padding: 1rem; border-radius: 12px; }
.flash.error { border-color: var(--terracotta); color: var(--terracotta); }

.admin-nav { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.2rem; }
.admin-nav a {
  text-decoration: none;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
}
.admin-nav a.active { background: var(--olive); color: #fff; border-color: var(--olive); }
.admin-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0 1.5rem; }
.storage-pill { color: var(--muted); font-size: 0.92rem; }
.admin-list { list-style: none; padding: 0; }
.admin-list li { display: flex; gap: 0.7rem; align-items: center; padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
.admin-list img, .thumb-cell img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; }
.data { width: 100%; border-collapse: collapse; background: var(--bg-2); border-radius: 12px; overflow: hidden; }
.data th, .data td { text-align: left; padding: 0.6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.stack, .recipe-form { display: grid; gap: 0.85rem; max-width: 760px; }
.stack.narrow { max-width: 420px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.category-picker {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 1rem 1rem;
  background: #fff;
  min-width: 0;
  min-inline-size: 0;
  max-width: 100%;
}
.category-picker legend { font-weight: 700; }
.field-hint,
.category-picker .hint {
  margin: 0;
  font-weight: 400;
  color: var(--muted);
  font-size: 0.92rem;
}
.category-picker .hint {
  margin: 0.2rem 0 0.7rem;
}
.category-picker-list {
  max-height: 22rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding-right: 0.2rem;
}
.category-group {
  margin: 0;
  min-width: 0;
}
.category-group-title {
  display: block;
  font-weight: 700;
  margin: 0 0 0.25rem;
}
.category-options {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.1rem;
}
.category-picker .category-option {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.45rem;
  width: fit-content;
  max-width: 100%;
  margin: 0;
  padding: 0.15rem 0;
  font-weight: 500;
  cursor: pointer;
}
.category-picker .category-option input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  padding: 0;
  flex: 0 0 1.1rem;
  align-self: center;
}
.category-picker .category-name {
  flex: 0 1 auto;
  min-width: 0;
}
.category-picker .category-option-root {
  font-weight: 700;
}
.form-actions { display: flex; gap: 0.6rem; }
label { display: grid; gap: 0.3rem; font-weight: 600; }
label.inline {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.45rem;
  width: fit-content;
  font-weight: 500;
}
.upload-box, .dropzone {
  border: 1px dashed var(--olive);
  border-radius: 14px;
  padding: 1rem;
  background: #fbfaf3;
}
.upload-box { display: grid; gap: 0.75rem; }
.upload-box p { margin: 0; font-weight: 500; color: var(--muted); }
.current-image {
  display: grid;
  gap: 0.55rem;
  justify-items: start;
}
.dropzone { text-align: center; }
.dropzone.drag { background: #eef4e0; }
.preview { max-width: 280px; max-height: 180px; object-fit: cover; border-radius: 10px; margin: 0.5rem auto; }
.current-image .preview { margin: 0; }
.hidden { display: none; }
.auth-card { max-width: 420px; margin: 2rem auto; }

.site-footer {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem 5.5rem;
}
.footer-legal { margin-top: 0.4rem; }
.footer-legal a, .linkish {
  color: var(--olive-dark);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
}
.legal ul { padding-left: 1.2rem; line-height: 1.55; }
.consent {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: #2b2a24;
  color: #f7f4ea;
  padding: 1rem 1.25rem;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.18);
}
.consent[hidden] { display: none !important; }
.consent a { color: #e7ecd8; }
.consent-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  gap: 1.2rem;
  align-items: center;
  justify-content: space-between;
}
.consent h2 { font-size: 1.05rem; margin: 0 0 0.35rem; color: #fff; }
.consent p { margin: 0; font-size: 0.95rem; }
.consent-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

@media (max-width: 900px) {
  .consent-inner { flex-direction: column; align-items: stretch; }
}
.nav-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 8px;
}
.nav-toggle span { display: block; height: 2px; background: var(--ink); }

@media (max-width: 900px) {
  .header-inner { grid-template-columns: auto 1fr auto; }
  .search-form { grid-column: 1 / -1; }
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    display: none;
    position: static;
  }
  .sidebar.open { display: block; }
  .nav-toggle { display: flex; }
  .hero,
  .hero-with-image,
  .recipe-hero,
  .recipe-grid,
  .form-row { grid-template-columns: 1fr; }
  .hero-image { height: 200px; }
}

@media print {
  .no-print,
  .site-header,
  .sidebar,
  .site-footer,
  .recipe-actions,
  .admin-nav,
  .hero-caption-form,
  .consent,
  .skip,
  .nav-toggle { display: none !important; }
  .shell { display: block; max-width: none; padding: 0; margin: 0; }
  body { background: #fff; color: #000; }
  a { color: inherit; text-decoration: none; }
  a[href]::after { content: none !important; }
  .recipe-page { max-width: 100%; }
  .recipe-hero,
  .recipe-grid,
  .recipe-grid section,
  .notes {
    display: block;
    background: #fff;
    border: 0;
    box-shadow: none;
    padding: 0;
    margin: 0 0 1rem;
  }
  .recipe-hero { margin-bottom: 0.8rem; }
  .recipe-photo { margin: 0.6rem 0 1rem; }
  .recipe-photo img {
    max-height: 8cm;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    border-radius: 0;
  }
  .recipe-page h1 { font-size: 22pt; margin: 0 0 0.35rem; }
  .recipe-page .servings { color: #000; font-size: 12pt; }
  .recipe-page h2 { font-size: 14pt; margin: 0.9rem 0 0.35rem; }
  .recipe-ingredients,
  .recipe-method,
  .notes { break-inside: avoid; }
}
