/* ─── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --bg:           #f8f7f5;
  --surface:      #ffffff;
  --border:       #dddbd7;
  --text:         #111111;
  --text-muted:   #555555;
  --accent:       #3d5a80;
  --accent-hover: #2d4a6e;
  --accent-light: #dde8f4;
  --tag-bg:       #dde8f4;
  --tag-text:     #2d4a6e;

  --font-sans:  'Inter', system-ui, -apple-system, sans-serif;

  --nav-height:    60px;
  --sidebar-width: 220px;
  --radius:        8px;
  --radius-sm:     4px;
}

/* ─── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img { display: block; max-width: 100%; }
a { color: inherit; }
button { font-family: inherit; cursor: pointer; }

/* ─── Nav ────────────────────────────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
}

.nav-brand {
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.nav-brand:hover { color: var(--accent); }

.nav-center { width: 100%; max-width: 420px; margin: 0 auto; }

#search {
  width: 100%;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#search::placeholder { color: var(--text-muted); }
#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.nav-end { display: flex; justify-content: flex-end; align-items: center; gap: 0.5rem; }

.card.quality-hidden { display: none; }

.quality-filter {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.quality-filter:focus { outline: none; border-color: var(--accent); }
.quality-filter:not([value="0"]) { border-color: var(--accent); color: var(--accent); }

.drafts-toggle {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.drafts-toggle:hover,
.drafts-toggle.active {
  border-color: #b45309;
  color: #b45309;
  background: #fef3c7;
}
[data-theme="dark"] .drafts-toggle.active {
  background: #2a1f10;
  color: #e8c080;
  border-color: #5a4020;
}

/* Hide draft cards when drafts are hidden */
body.hide-drafts .card[data-draft="true"] { display: none; }

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1;
  transition: border-color 0.15s, color 0.15s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

.nav-new {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.nav-new:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.nav-tags {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
}
.nav-tags:hover { color: var(--text); }

/* Filters toggle — mobile only */
.filters-toggle {
  display: none;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s;
}
.filters-toggle:hover { border-color: var(--accent); color: var(--accent); }

.filters-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}

/* ─── Page layout (index only) ───────────────────────────────────────────────── */
.page-layout {
  display: flex;
  flex: 1;
  align-items: flex-start;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  position: sticky;
  top: var(--nav-height);
  max-height: calc(100vh - var(--nav-height));
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--bg);
}

.sidebar-backdrop { display: none; }

.sidebar-inner { padding: 1.25rem 0; }

.sidebar-header {
  display: none; /* visible on mobile only */
  justify-content: space-between;
  align-items: center;
  padding: 0 1rem 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}
.sidebar-title { font-weight: 600; font-size: 0.95rem; }
.sidebar-close {
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--text-muted);
  padding: 0.25rem;
  line-height: 1;
}
.sidebar-close:hover { color: var(--text); }

/* Filter groups */
.filter-group { border-bottom: 1px solid var(--border); }

.filter-group-btn {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 1rem;
  background: none;
  border: none;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  text-align: left;
  transition: color 0.15s;
}
.filter-group-btn:hover { color: var(--text); }

.filter-arrow {
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.filter-group-btn[aria-expanded="false"] .filter-arrow {
  transform: rotate(-90deg);
}

.filter-group-body {
  padding: 0 0.75rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.filter-group-btn[aria-expanded="false"] + .filter-group-body {
  display: none;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.3rem 0.25rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: color 0.15s;
}
.filter-option:hover { color: var(--text); }
.filter-option input { accent-color: var(--accent); cursor: pointer; }
.filter-option:has(input:checked) { color: var(--text); font-weight: 500; }

.clear-filters {
  display: block;
  margin: 1rem 1rem 0;
  padding: 0.4rem 0.75rem;
  width: calc(100% - 2rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: all 0.15s;
}
.clear-filters:hover { border-color: var(--accent); color: var(--accent); }

/* ─── Main content area ──────────────────────────────────────────────────────── */
/* Type listing pages — fill remaining width beside sidebar */
[data-page="dishes"] .main,
[data-page="staples"] .main,
[data-page="wellness"] .main,
[data-page="references"] .main {
  flex: 1;
  min-width: 0;
  padding: 2rem 1.75rem 4rem;
}

/* Home page */
[data-page="home"] .main {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

.home-header {
  text-align: center;
  margin-bottom: 2.5rem;
}
.home-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  margin-bottom: 0.3rem;
}
.home-sub { font-size: 0.9rem; color: var(--text-muted); }

/* Desktop: 2×2 grid (Option A) */
.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.home-tile {
  display: block;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--tile-accent, var(--accent));
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: box-shadow 0.15s, transform 0.15s;
  color: inherit;
}
.home-tile:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}

.home-tile-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}
.home-tile-icon { font-size: 1.5rem; line-height: 1; }
.home-tile-count {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  padding: 0.2em 0.65em;
  border-radius: 999px;
}
.home-tile-name {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.4rem;
}
.home-tile-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1rem;
}
.home-tile-count-mobile { display: none; }

.home-tile-arrow {
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: color 0.15s, transform 0.15s;
}
.home-tile:hover .home-tile-arrow {
  color: var(--tile-accent, var(--accent));
  transform: translateX(3px);
}

/* Type page heading */
.type-back {
  display: inline-block;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 1rem;
}
.type-back:hover { color: var(--accent); }
.type-heading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.type-heading-icon { font-size: 1.75rem; line-height: 1; }

/* Recipe pages — centered, readable width */
[data-page="dish"] .main,
[data-page="staple"] .main,
[data-page="wellness-detail"] .main,
[data-page="reference"] .main {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ─── Tags & badges ──────────────────────────────────────────────────────────── */
.tag {
  display: inline-block;
  padding: 0.2em 0.65em;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.type-badge {
  display: inline-block;
  padding: 0.2em 0.6em;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.type-badge--dishes     { background: var(--accent-light); color: var(--accent); }
.type-badge--staples    { background: #e8f0e8; color: #3d6b3d; }
.type-badge--references { background: #e8eaf6; color: #3949ab; }
.type-badge--wellness   { background: #e0f2ec; color: #2d7a5e; }

/* ─── Index header ───────────────────────────────────────────────────────────── */
.index-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.index-title {
  font-family: var(--font-sans);
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.index-count { color: var(--text-muted); font-size: 0.875rem; }

/* ─── Card grid ──────────────────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
}

.card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(42, 36, 32, 0.09);
}
.card.hidden { display: none; }
.card-link { display: block; text-decoration: none; color: inherit; }

/* Color tile (replaces image on cards) */
.card-tile {
  height: 4px;
  background: var(--tile-color, #3d5a80);
  flex-shrink: 0;
}

.card-badge {
  display: inline-block;
  padding: 0.15em 0.5em;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.card-badge--variant { background: #e8eaf6; color: #3949ab; }
.card-badge--draft   { background: #fef3c7; color: #92400e; }

.card-body { padding: 0.85rem 1rem 1rem; }
.card-top-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
  flex-wrap: wrap;
}
.card-role {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}
.card-time { font-size: 0.75rem; color: var(--text-muted); margin-left: auto; }
.card-title {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 0.45rem;
  line-height: 1.3;
}
.card-tags { display: flex; flex-wrap: wrap; gap: 0.25rem; }

/* Adaptable badge — hidden until JS sets .adaptable-match on the card */
.card-adaptable-badge {
  display: none;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--accent);
  margin-top: 0.4rem;
  letter-spacing: 0.02em;
}
.card-adaptable-badge::before { content: '✦ '; }
.card.adaptable-match .card-adaptable-badge { display: block; }

/* ─── No results ─────────────────────────────────────────────────────────────── */
.no-results {
  text-align: center;
  color: var(--text-muted);
  margin-top: 4rem;
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.no-results-icon {
  font-size: 2.5rem;
  line-height: 1;
  opacity: 0.4;
}
.no-results-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.no-results-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
}
.hidden { display: none !important; }

/* ─── Draft banner ───────────────────────────────────────────────────────────── */
.draft-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  margin-bottom: 1.5rem;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 500;
  color: #92400e;
}
.draft-banner::before { content: '✎'; font-size: 1rem; }

/* ─── Recipe hero (page only, not cards) ─────────────────────────────────────── */
.recipe-hero {
  width: 100%;
  max-height: 400px;
  overflow: hidden;
  border-radius: var(--radius);
  margin-bottom: 2rem;
}
.recipe-hero img { width: 100%; height: 400px; object-fit: cover; }

/* ─── Recipe header ──────────────────────────────────────────────────────────── */
.recipe-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.back-link {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.back-link:hover { color: var(--accent); }

/* Hidden on desktop (instructions are already visible in right column) */
.jump-to-instructions {
  display: none;
  font-size: 0.82rem;
  color: var(--accent);
  text-decoration: none;
  margin-top: 0.75rem;
  font-weight: 500;
}
.jump-to-instructions:hover { text-decoration: underline; }

.variant-of {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.variant-of::before { content: '·'; margin-right: 0.75rem; }
.variant-of a { color: var(--accent); text-decoration: none; }
.variant-of a:hover { text-decoration: underline; }

.recipe-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.recipe-title {
  font-family: var(--font-sans);
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}
.recipe-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.recipe-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* Serving scaler */
.scaler {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.75rem;
}
.scaler-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }
.scaler-btn {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 1rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
  transition: all 0.15s;
}
.scaler-btn:hover  { background: var(--accent); border-color: var(--accent); color: #fff; }
.scaler-btn:disabled { opacity: 0.35; pointer-events: none; }
.scaler-value { font-weight: 600; font-size: 0.9rem; min-width: 1.5ch; text-align: center; }

/* Print button */
.print-btn {
  padding: 0.4rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  font-size: 0.85rem; font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s;
}
.print-btn:hover { border-color: var(--accent); color: var(--accent); }

.draft-toggle-btn {
  padding: 0.4rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  font-size: 0.85rem; font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.draft-toggle-btn:hover { border-color: #16a34a; color: #16a34a; }
.draft-toggle-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.delete-btn {
  padding: 0.4rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  font-size: 0.85rem; font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.delete-btn:hover { border-color: #dc2626; color: #dc2626; }
.delete-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Recipe meta bar */
.recipe-meta {
  display: flex;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 1.25rem;
  background: #fff;
}
.meta-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.85rem 1.25rem;
  border-right: 1px solid var(--border);
  flex: 1;
  min-width: 90px;
  gap: 0.25rem;
}
.meta-item:last-child { border-right: none; }
.meta-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); font-weight: 600; }
.meta-value { font-size: 1rem; font-weight: 600; }

/* Source attribution */
.recipe-source {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Adaptable hints — dietary swap suggestions on recipe page */
.adaptable-hints {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}
.adaptable-hint strong {
  color: var(--accent);
  font-weight: 600;
}

/* Dates — sits below the recipe body */
.recipe-dates {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.recipe-source a { color: var(--accent); text-decoration: none; }
.recipe-source a:hover { text-decoration: underline; }

.recipe-prevnext {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.prevnext-link {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  text-decoration: none;
  max-width: 45%;
}
.prevnext-next { text-align: right; margin-left: auto; }
.prevnext-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.prevnext-title {
  font-size: 0.9rem;
  color: var(--accent);
  font-weight: 500;
}
.prevnext-link:hover .prevnext-title { text-decoration: underline; }

/* ─── Recipe body ────────────────────────────────────────────────────────────── */
.recipe-header { margin-bottom: 2.5rem; }
.recipe-body { font-size: 1rem; line-height: 1.7; }

.recipe-body h2 {
  font-family: var(--font-sans);
  font-size: 1.2rem; font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1rem; margin-top: 0;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--border);
}
.recipe-body h3 {
  font-family: var(--font-sans);
  font-size: 0.95rem; font-weight: 700;
  letter-spacing: -0.01em;
  margin: 1.25rem 0 0.5rem;
}
.recipe-body ul, .recipe-body ol {
  padding-left: 1.4rem;
  margin-bottom: 0.5rem;
}
.recipe-body li     { margin-bottom: 0.4rem; }
.recipe-body ol li  { padding-left: 0.25rem; }
.recipe-body p      { margin-bottom: 0.85rem; }
.recipe-body strong { font-weight: 600; }
.recipe-body em     { font-style: italic; }
.recipe-body hr     { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* Tables (used in reference pages) */
.recipe-body table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}
.recipe-body th,
.recipe-body td {
  padding: 0.55rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.recipe-body th {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--surface);
  border-bottom: 2px solid var(--border);
}
.recipe-body tbody tr:nth-child(even) td { background: var(--surface); }
.recipe-body tbody tr:last-child td { border-bottom: none; }
.recipe-body tbody tr:hover td { background: var(--tag-bg); }

/* Two-column layout */
.recipe-columns {
  display: grid;
  grid-template-columns: 2fr 3fr;
  gap: 3.5rem;
  align-items: start;
  margin-bottom: 2.5rem;
}
.col-ingredients {
  position: sticky;
  top: calc(var(--nav-height) + 1.5rem);
}

/* ── Ingredient list styling ──────────────────────────────────────────────── */

/* Strip default bullets; we'll style our own */
.col-ingredients ul {
  list-style: none;
  padding-left: 0;
  margin-bottom: 0;
}

.col-ingredients li {
  position: relative;
  padding: 0.5rem 0 0.5rem 1.6rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 0;
}
.col-ingredients li:last-child { border-bottom: none; }

/* Checkbox injected by JS — absolutely positioned so text flows normally */
.ingredient-check {
  position: absolute;
  left: 0;
  top: 0.6rem;
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Ingredient alternative annotation: "(or X)" */
.ingredient-alt {
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.82em;
}

/* Checked ingredient: dim + strikethrough */
.col-ingredients li.checked {
  color: var(--text-muted);
  text-decoration: line-through;
}
/* Checkbox stays at full colour inside the dimmed li */
.col-ingredients li.checked .ingredient-check {
  accent-color: var(--text-muted);
}

/* Reset button sits inline in the Ingredients h2 */
.col-ingredients h2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ingredients-reset {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}
.ingredients-reset:hover { color: var(--accent); }

.ingredients-copy {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
  margin-left: 0.6rem;
}
.ingredients-copy:hover { color: var(--accent); }

/* Subsection group headers: **Marinade**, **Tempering** etc.
   marked renders these as <p><strong>label</strong></p>           */
.col-ingredients p {
  margin-top: 1.4rem;
  margin-bottom: 0.1rem;
}
/* First p (right after the h2) needs less top space */
.col-ingredients h2 + p { margin-top: 0.25rem; }

.col-ingredients p:has(> strong:only-child) strong,
.col-ingredients p > strong:first-child:last-child {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--accent);
  padding: 0.15em 0.5em;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
}

/* ─── Responsive ─────────────────────────────────────────────────────────────── */

/* Home page: switch to Option C row layout on mobile */
@media (max-width: 600px) {
  [data-page="home"] .main { padding: 1.5rem 1rem 3rem; }
  .home-header { margin-bottom: 1.5rem; }
  .home-title { font-size: 1.5rem; }

  .home-grid { grid-template-columns: 1fr; gap: 0.5rem; }

  .home-tile {
    border-top: none;
    border-left: 3px solid var(--tile-accent, var(--accent));
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transform: none !important;
  }
  .home-tile-top {
    flex-shrink: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    margin-bottom: 0;
  }
  .home-tile-icon { font-size: 1.4rem; margin-bottom: 0.25rem; }
  .home-tile-count { display: none; }
  .home-tile-name { font-size: 1rem; margin-bottom: 0; }
  .home-tile-desc { display: none; }
  .home-tile-arrow { margin-left: auto; flex-shrink: 0; }

  .home-tile-count-mobile {
    display: inline;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 0.5rem;
  }
}

@media (max-width: 900px) {
  .recipe-columns { grid-template-columns: 1fr; gap: 0; }
  .col-ingredients { position: static; margin-bottom: 2rem; }
  .jump-to-instructions { display: inline-block; }
}

@media (max-width: 768px) {
  /* Show mobile filters toggle */
  .filters-toggle { display: flex; }

  /* Sidebar becomes a slide-in drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(var(--sidebar-width), 80vw);
    max-height: 100vh;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    border-right: 1px solid var(--border);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(42,36,32,0.12);
  }

  /* Backdrop */
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(42, 36, 32, 0.4);
    z-index: 299;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .sidebar.open .sidebar-backdrop {
    opacity: 1;
    pointer-events: all;
  }

  /* Show header with close button inside drawer */
  .sidebar-header { display: flex; }

  /* Main takes full width */
  [data-page="dishes"] .main,
  [data-page="staples"] .main,
  [data-page="wellness"] .main,
  [data-page="references"] .main { padding: 1.5rem 1rem 3rem; }

  .recipe-title { font-size: 1.75rem; }
  .recipe-title-row { flex-direction: column; }
}

/* Meta bar: stacked label/value rows instead of horizontal pills */
@media (max-width: 600px) {
  .recipe-meta { display: block; }
  .meta-item {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0.6rem 1rem;
    min-width: unset;
  }
  .meta-item:last-child { border-bottom: none; }
}

@media (max-width: 480px) {
  [data-page="dish"] .main,
  [data-page="staple"] .main,
  [data-page="wellness-detail"] .main,
  [data-page="reference"] .main { padding: 1.5rem 1rem 3rem; }
  .recipe-title { font-size: 1.5rem; }
  .card-grid { grid-template-columns: 1fr 1fr; gap: 0.85rem; }
  .card-title { font-size: 0.9rem; }
}

/* Very narrow phones: prevent nav search from being crushed */
@media (max-width: 400px) {
  .nav { padding: 0 0.75rem; }
  .nav-new { display: none; }
}

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

/* ─── Tags page ─────────────────────────────────────────────────────────────── */
[data-page="tags"] .main {
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.tags-header {
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 2px solid var(--border);
}
.tags-title {
  font-family: var(--font-sans);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  margin-bottom: 0.25rem;
}
.tags-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
}
.tags-group {
  margin-bottom: 2rem;
}
.tags-group-name {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
}
.tags-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.tags-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35em 0.9em;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--tag-text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1.5px solid transparent;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  text-transform: capitalize;
}
.tags-pill:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}
.tags-count {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}
.tags-pill:hover .tags-count { color: var(--accent); }

/* ─── Print ──────────────────────────────────────────────────────────────────── */
@media print {
  /* ── Hide all UI chrome ── */
  .nav, .footer, .sidebar,
  .back-link, .variant-of,
  .recipe-actions, .recipe-tags,
  .recipe-dates, .recipe-prevnext,
  .jump-to-instructions,
  .ingredients-reset, .ingredients-copy, .ingredient-check,
  .draft-banner, .card-tile,
  .related-recipes, .my-notes,
  .recipe-hero, .adaptable-hints { display: none !important; }

  /* ── Page setup ── */
  @page { margin: 1.5cm 1.8cm; }
  body  { background: #fff; color: #000; font-size: 10pt; line-height: 1.45; }
  a     { text-decoration: none; color: inherit; }

  [data-page="dish"] .main,
  [data-page="staple"] .main,
  [data-page="wellness-detail"] .main,
  [data-page="reference"] .main {
    max-width: 100%;
    padding: 0;
    margin: 0;
  }

  /* ── Title ── */
  .recipe-header  { margin-bottom: 0.6rem; }
  .recipe-title   { font-size: 18pt; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; margin-bottom: 0.25rem; }

  /* ── Meta bar — render inline, no box ── */
  .recipe-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0 1.5rem;
    border: none;
    background: none;
    margin: 0.3rem 0 0.5rem;
  }
  .meta-item {
    display: flex;
    flex-direction: row;
    gap: 0.3rem;
    align-items: baseline;
    border: none;
    padding: 0;
    flex: none;
    min-width: unset;
  }
  .meta-label {
    font-size: 7pt;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #555;
  }
  .meta-value { font-size: 10pt; font-weight: 600; }

  /* Source line */
  .recipe-source {
    display: block;
    font-size: 8pt;
    color: #666;
    margin-bottom: 0.4rem;
  }

  /* Divider below header */
  .recipe-header::after {
    content: '';
    display: block;
    border-top: 1.5px solid #000;
    margin-top: 0.5rem;
  }

  /* ── Suppress duplicate h1 in body ── */
  .recipe-body h1 { display: none; }

  /* ── Two-column → single column ── */
  .recipe-columns {
    display: grid;
    grid-template-columns: 2fr 3fr;
    gap: 1.5rem;
    margin-bottom: 0.75rem;
  }

  /* ── Ingredients ── */
  .col-ingredients { position: static; }
  .col-ingredients ul { list-style: none; padding: 0; margin: 0; }
  .col-ingredients li {
    font-size: 9.5pt;
    padding: 0.2rem 0;
    border-bottom: 0.5pt solid #ddd;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .col-ingredients li:last-child { border-bottom: none; }
  .col-ingredients p { margin: 0.6rem 0 0.1rem; }

  /* ── Section headings ── */
  .recipe-body h2 {
    font-size: 11pt;
    font-weight: 700;
    margin: 0.75rem 0 0.35rem;
    padding-bottom: 0.2rem;
    border-bottom: 1pt solid #ccc;
    break-after: avoid;
    page-break-after: avoid;
  }
  .recipe-body h3 {
    font-size: 9.5pt;
    font-weight: 700;
    margin: 0.5rem 0 0.2rem;
    break-after: avoid;
    page-break-after: avoid;
  }

  /* ── Body text ── */
  .recipe-body { font-size: 10pt; line-height: 1.45; }
  .recipe-body p  { margin: 0.3rem 0; }
  .recipe-body li { margin-bottom: 0.2rem; break-inside: avoid; page-break-inside: avoid; }
  .recipe-body ul,
  .recipe-body ol { padding-left: 1.2rem; margin-bottom: 0.4rem; }

  /* ── Tables (reference pages) ── */
  .recipe-body table { font-size: 9pt; width: 100%; border-collapse: collapse; }
  .recipe-body th,
  .recipe-body td { padding: 0.25rem 0.4rem; border-bottom: 0.5pt solid #ccc; text-align: left; }
  .recipe-body th { font-size: 7.5pt; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }

  /* ── Keep blocks together ── */
  .recipe-step    { break-inside: avoid; page-break-inside: avoid; }
  .recipe-header  { break-inside: avoid; page-break-inside: avoid; }

  /* ── Checked ingredients: no strikethrough in print ── */
  .col-ingredients li.checked { color: inherit; text-decoration: none; }
  .ingredient-alt { font-style: italic; color: #666; }
}

/* ─── Collection layout ──────────────────────────────────────────────────────── */
[data-page="collection"] .main {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.collection-intro {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  line-height: 1.6;
}

.collection-theme {
  margin-bottom: 2.5rem;
}
.collection-theme-name {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  padding: 0.4rem 0.75rem;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  display: inline-block;
}
.collection-theme-intro {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  line-height: 1.5;
}
.collection-theme-intro p { margin: 0; }

.collection-combos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

.collection-combo {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}
.collection-combo-name {
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 0.5rem;
  color: var(--text);
}
.collection-combo-body ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.collection-combo-body li {
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 0.15rem 0;
  border-bottom: 0.5px solid var(--border);
  line-height: 1.4;
}
.collection-combo-body li:last-child { border-bottom: none; }

@media (max-width: 600px) {
  .collection-combos { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 400px) {
  .collection-combos { grid-template-columns: 1fr; }
}

/* Print: collection flows naturally as single column */
@media print {
  .collection-combos { grid-template-columns: repeat(3, 1fr); }
  .collection-combo { break-inside: avoid; }
}

/* ─── Dev quality panel ──────────────────────────────────────────────────────── */
.quality-panel {
  margin-top: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 0.82rem;
}
.quality-panel-summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  cursor: pointer;
  background: var(--surface);
  list-style: none;
  user-select: none;
}
.quality-panel-summary::-webkit-details-marker { display: none; }
.quality-score {
  font-weight: 700;
  color: var(--score-color, var(--text));
  white-space: nowrap;
  flex-shrink: 0;
}
.quality-bar-wrap {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.quality-bar {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}
.quality-issues {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.quality-issues-list {
  padding: 0.6rem 1rem 0.75rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.quality-issues-list li { color: var(--text-muted); }

@media print { .quality-panel { display: none !important; } }

/* ─── Related recipes ────────────────────────────────────────────────────────── */
.related-recipes {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.related-heading {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 1rem;
}
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}
.related-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.related-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.related-tile {
  height: 4px;
  background: var(--tile-color, var(--accent));
}
.related-title {
  padding: 0.45rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}

/* ─── Personal notes ─────────────────────────────────────────────────────────── */
.my-notes {
  margin-top: 2.5rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border-radius: var(--radius);
  border-left: 3px solid var(--accent);
}
.my-notes-heading {
  font-family: var(--font-sans);
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
}
.my-note {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.5rem 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.my-note:last-child { border-bottom: none; }
.my-note-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding-top: 0.1rem;
  white-space: nowrap;
}
.my-note-text {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.5;
}
@media (max-width: 600px) {
  .my-note { grid-template-columns: 1fr; gap: 0.2rem; }
}

/* ─── Dark mode ──────────────────────────────────────────────────────────────── */
/* Applied via [data-theme="dark"] (JS toggle) or system preference fallback    */

[data-theme="dark"],
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:           #141618;
    --surface:      #1e2124;
    --border:       #2e3338;
    --text:         #f0f2f5;
    --text-muted:   #9aa0a8;
    --accent:       #7db3e8;
    --accent-hover: #6aa2d6;
    --accent-light: #1a2a3a;
    --tag-bg:       #1a2a3a;
    --tag-text:     #7db3e8;
  }
}

[data-theme="dark"] {
  --bg:           #141618;
  --surface:      #1e2124;
  --border:       #2e3338;
  --text:         #f0f2f5;
  --text-muted:   #9aa0a8;
  --accent:       #7db3e8;
  --accent-hover: #6aa2d6;
  --accent-light: #1a2a3a;
  --tag-bg:       #1a2a3a;
  --tag-text:     #7db3e8;
}

[data-theme="dark"] .nav,
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .nav { background: var(--bg); } }
[data-theme="dark"] .nav { background: var(--bg); }

[data-theme="dark"] .form-input,
[data-theme="dark"] .form-select {
  background: var(--surface); color: var(--text); border-color: var(--border);
}

[data-theme="dark"] #search { background: var(--surface); color: var(--text); }
[data-theme="dark"] #search::placeholder { color: var(--text-muted); }

[data-theme="dark"] .card { background: var(--surface); }
[data-theme="dark"] .scaler-btn { background: var(--bg); color: var(--text); }
[data-theme="dark"] .recipe-meta { background: var(--surface); }

[data-theme="dark"] .type-badge--dishes     { background: #1a2a3a; color: #7db3e8; }
[data-theme="dark"] .type-badge--staples    { background: #1a2e1a; color: #6db86d; }
[data-theme="dark"] .type-badge--references { background: #1a1e36; color: #7986cb; }
[data-theme="dark"] .type-badge--wellness   { background: #0f2820; color: #4db891; }

[data-theme="dark"] .card-badge--variant { background: #1a1e36; color: #7986cb; }
[data-theme="dark"] .card-badge--draft   { background: #2a1f10; color: #e8c080; }
[data-theme="dark"] .draft-banner { background: #2a1f10; color: #e8c080; border-color: #5a4020; }

[data-theme="dark"] .form-error   { background: #2d1515; border-color: #7f2020; color: #f8a0a0; }
[data-theme="dark"] .form-success { background: #0f2518; border-color: #2d6a40; }
[data-theme="dark"] .form-success-title,
[data-theme="dark"] .form-success-path { color: #6ee7a0; }
[data-theme="dark"] .form-success-path code { background: #1a4030; }

/* System preference fallback (no JS / no explicit theme set) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg:           #141618;
    --surface:      #1e2124;
    --border:       #2e3338;
    --text:         #f0f2f5;
    --text-muted:   #9aa0a8;
    --accent:       #7db3e8;
    --accent-hover: #6aa2d6;
    --accent-light: #1a2a3a;
    --tag-bg:       #1a2a3a;
    --tag-text:     #7db3e8;
  }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .nav { background: var(--bg); }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .card { background: var(--surface); }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .scaler-btn { background: var(--bg); color: var(--text); }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .recipe-meta { background: var(--surface); }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .type-badge--dishes     { background: #1a2a3a; color: #7db3e8; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .type-badge--staples    { background: #1a2e1a; color: #6db86d; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .type-badge--references { background: #1a1e36; color: #7986cb; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .type-badge--wellness   { background: #0f2820; color: #4db891; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .draft-banner { background: #2a1f10; color: #e8c080; border-color: #5a4020; }
}
