:root {
  --bg: #f5efe7;
  --panel: #fffdf9;
  --text: #2b211b;
  --muted: #6f6056;
  --accent: #7b3f25;
  --accent-dark: #5b2f20;
  --line: #ddcfc2;
  --soft: #ecddd0;
  --soft-2: #e1c7b3;
  --ok: #315d3b;
  --shadow: 0 16px 36px rgba(67, 43, 29, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.brand-header { background: var(--accent-dark); color: #fffaf4; border-bottom: 4px solid #bb7b52; }
.brand-header__inner { width: min(1100px, calc(100% - 32px)); margin: 0 auto; min-height: 94px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { color: inherit; text-decoration: none; display: flex; align-items: baseline; gap: 13px; }
.brand__kicker { font-size: .78rem; letter-spacing: .14em; font-weight: 900; text-transform: uppercase; }
.brand__title { font-family: Georgia, "Times New Roman", serif; font-size: 2rem; font-style: italic; }
.brand__tagline { margin: 0; color: #ead8ca; font-size: .95rem; }

.page-shell { width: min(1100px, calc(100% - 32px)); margin: 0 auto; }
.hero { display: flex; justify-content: space-between; gap: 24px; align-items: end; padding: 44px 0 24px; }
h1 { margin: 0; font-size: clamp(2.4rem, 6vw, 4.4rem); line-height: .95; letter-spacing: -.05em; }
.hero__button { flex: 0 0 auto; }
.subtitle { color: var(--muted); margin: 12px 0 0; max-width: 650px; line-height: 1.55; }
.project-label { margin: 12px 0 0; color: var(--accent); font-weight: 850; letter-spacing: .04em; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-weight: 900; text-transform: uppercase; letter-spacing: .09em; font-size: .76rem; }

.toolbar { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 91%, transparent); backdrop-filter: blur(14px); padding: 16px 0 18px; }
.search-wrap { display: grid; gap: 7px; font-weight: 750; }
.search-wrap input { width: 100%; border: 1px solid var(--line); border-radius: 15px; padding: 14px 16px; background: var(--panel); color: var(--text); box-shadow: 0 4px 14px rgba(67,43,29,.03); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.filter, .secondary-btn, .primary-btn { border-radius: 999px; padding: 10px 15px; border: 1px solid var(--line); cursor: pointer; transition: transform .15s ease, background .15s ease; }
.filter:hover, .secondary-btn:hover, .primary-btn:hover { transform: translateY(-1px); }
.filter, .secondary-btn { background: var(--panel); color: var(--text); }
.filter.active, .primary-btn { background: var(--accent); border-color: var(--accent); color: white; }
.primary-btn:hover { background: var(--accent-dark); }

.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 20px 0 14px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.section-heading h2 { margin: 0; font-size: 2rem; }
.recipe-count { color: var(--muted); margin: 0; }
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); gap: 20px; padding: 10px 0 64px; }
.recipe-card { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; overflow: hidden; display: flex; flex-direction: column; min-height: 100%; box-shadow: var(--shadow); }
.recipe-image-wrap { aspect-ratio: 16/9; background: var(--soft); position: relative; overflow: hidden; }
.recipe-image { width: 100%; height: 100%; object-fit: cover; display: block; }
.recipe-image.placeholder { object-fit: none; background: linear-gradient(135deg, var(--soft), var(--soft-2)); }
.badge { position: absolute; top: 12px; left: 12px; background: rgba(255,253,249,.94); color: var(--ok); padding: 7px 10px; border-radius: 999px; font-size: .82rem; font-weight: 850; }
.recipe-card-body { padding: 18px; display: flex; flex-direction: column; flex: 1; }
.recipe-meta { color: var(--muted); font-size: .9rem; }
.recipe-title { margin: 7px 0 8px; font-size: 1.5rem; }
.recipe-summary { margin: 0 0 14px; color: var(--muted); line-height: 1.52; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.tag { background: var(--soft); color: var(--accent-dark); border-radius: 999px; padding: 5px 9px; font-size: .78rem; font-weight: 750; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }

.recipe-dialog {
  width: min(860px, calc(100% - 24px));
  height: min(92vh, 900px);
  max-height: 92vh;
  border: 0;
  border-radius: 22px;
  padding: 0;
  overflow: hidden;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 30px 80px rgba(20,12,8,.35);
}
#dialogContent {
  height: calc(100% - 72px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.recipe-detail {
  padding: 26px;
  min-width: 0;
  }
.recipe-detail h2 { font-size: clamp(2rem, 5vw, 3.2rem); margin: 0 0 10px; }
.detail-grid { display: grid; grid-template-columns: .9fr 1.1fr; gap: 26px; margin-top: 24px; }
.detail-section { border-top: 1px solid var(--line); padding-top: 18px; }
.detail-section h3 { margin: 0 0 10px; }
.detail-section ul, .detail-section ol { padding-left: 22px; line-height: 1.68; }
.note-box { background: var(--soft); border-left: 5px solid var(--accent); padding: 14px 16px; border-radius: 12px; margin-top: 18px; line-height: 1.55; }
.dialog-actions { padding: 0 26px 24px; }
.shopping-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 9px; }
.shopping-list li { border-bottom: 1px solid var(--line); padding: 8px 0; }
.shopping-list label { display: flex; gap: 10px; align-items: start; }
.shopping-note { color: var(--muted); }

.cooking-dialog { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; border: 0; padding: 0; background: #17120f; color: #fffaf4; }
.cooking-shell { width: min(900px, calc(100% - 28px)); margin: 0 auto; padding: 24px 0 60px; }
.cooking-topbar { display: flex; justify-content: space-between; align-items: start; gap: 20px; position: sticky; top: 0; background: #17120f; padding: 8px 0 16px; }
.cooking-topbar h2 { margin: 0; font-size: clamp(2rem, 7vw, 4rem); }
.cooking-steps { counter-reset: step; list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 18px; }
.cooking-steps li { background: #2a211d; border: 1px solid #4a3a32; border-radius: 20px; padding: 24px; font-size: clamp(1.25rem, 4vw, 2rem); line-height: 1.35; display: grid; grid-template-columns: auto 1fr; gap: 16px; }
.cooking-steps li::before { counter-increment: step; content: counter(step); width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: #f4c8a8; color: #2a160a; font-weight: 900; }
.empty { padding: 40px 0; color: var(--muted); }
.site-footer { border-top: 1px solid var(--line); text-align: center; color: var(--muted); padding: 28px 16px 44px; }
.site-footer p { margin: 4px 0; }

.site-footer {
  position: relative;
}

.footer-link,
.back-to-top {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.footer-link:hover,
.back-to-top:hover {
  text-decoration: underline;
}

.footer-link {
  display: inline-block;
  margin-top: 18px;
}

.back-to-top {
  position: absolute;
  right: 32px;
  bottom: 44px;
}

@media (max-width: 650px) {
  .back-to-top {
    position: static;
    display: block;
    margin-top: 12px;
  }
}

@media (max-width: 760px) {
  .brand-header__inner { align-items: flex-start; flex-direction: column; justify-content: center; gap: 4px; padding: 16px 0; }
  .brand__tagline { font-size: .86rem; }
  .hero { align-items: start; padding-top: 30px; }
  .hero__button { display: none; }
  .detail-grid { grid-template-columns: 1fr; }
  .card-actions button { flex: 1 1 46%; }
  .recipe-dialog {
  width: calc(100% - 24px);
  max-height: calc(100dvh - 32px);
  margin: 16px auto;
  }
  .dialog-close {
    top: 12px;
    right: 12px;
    z-index: 10;
  }
}

/* v0.2.6 grouped recipe filters */
.filters {
  display: grid;
  gap: 0.5rem;
}

.filter-group {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.5rem;
  align-items: center;
}

.filter-group__label {
  padding-top: 0;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brown, #5b2f20);
}

.filter-group__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.filter {
  padding: 0.55rem 0.9rem;
}

.clear-filters {
  justify-self: start;
  width: auto;
  margin-left: 6rem;
  padding: 0.45rem 0.8rem;
}

@media (max-width: 650px) {
  .filter-group {
    grid-template-columns: 1fr;
    gap: 0.3rem;
  }

  .clear-filters {
    margin-left: 0;
  }
}

.filter-panel {
  margin-top: 0.75rem;
}

.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.filters {
  max-height: 1000px;
  opacity: 1;
  overflow: hidden;
  transition:
    max-height 450ms ease,
    opacity 300ms ease,
    margin-top 450ms ease;
}

.filters--collapsed {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
}

/* ==========================
   Cook Log
   ========================== */

.cook-log {
  margin-top: 1rem;
}

.cook-log__toggle {
  margin-bottom: .75rem;
}

.cook-log__entries {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.cook-log__entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: .9rem 1rem;
}

.cook-log__meta {
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: .5rem;
}

.cook-log__meta strong {
  color: var(--text);
}

.cook-log__entry p {
  margin: 0;
  line-height: 1.55;
}

.cook-log .empty {
  color: var(--muted);
  font-style: italic;
}

.cook-log__author {
  margin-top: .15rem;
  font-size: .8rem;
  color: var(--muted);
  font-style: italic;
}

.cook-log__entries--collapsed {
  display: none;
}

.recipe-dialog {
    position: relative;
}

.dialog-close {
    position: absolute;
    top: 14px;
    right: 28px;

    width: 40px;
    height: 40px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: none;
    border-radius: 50%;

    background: rgba(40, 25, 18, 0.92);
    color: #fff;

    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1;

    cursor: pointer;

    box-shadow: 0 2px 8px rgba(0,0,0,.25);
    transition: all .15s ease;
}

.dialog-close:hover {
    background: #6b3a24;
    transform: scale(1.08);
    cursor: pointer;
}

.dialog-close:active {
    transform: scale(.95);
}

/******* Cook Log editor *******/

.cook-log-dialog {
  width: min(560px, calc(100vw - 2rem));
  padding: 0;
}

.cook-log-dialog form {
  display: grid;
  gap: 1.25rem;
  padding: 2rem;
}

.cook-log-dialog h2,
.cook-log-dialog .eyebrow {
  margin: 0;
}

.form-field {
  display: grid;
  gap: 0.5rem;
  font-weight: 700;
}

.form-field textarea {
  width: 100%;
  min-height: 220px;
  padding: 0.9rem 1rem;

  font: inherit;
  line-height: 1.5;

  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;

  resize: vertical;
  box-sizing: border-box;
}

.form-field textarea:focus {
  outline: 3px solid rgba(107, 58, 36, 0.18);
  border-color: var(--accent);
}

.cook-log-dialog .dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin: 0;
}

.form-field textarea::placeholder {
    color: #8a8179;
}