:root {
  --paper: #faf7f2;
  --card: #ffffff;
  --ink: #2a2622;
  --muted: #7a7068;
  --rule: #d9d1c6;
  --accent: #a4472a;
  --accent-soft: #f3e4dc;
  --serif-display: 'Cormorant Garamond', Georgia, serif;
  --serif: 'EB Garamond', Georgia, serif;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--serif); font-size: 19px; line-height: 1.55;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.center { text-align: center; }
[hidden] { display: none !important; }

/* Header */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; padding-top: max(14px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--rule); background: var(--paper);
  position: sticky; top: 0; z-index: 5;
}
.brand { text-decoration: none; font-family: var(--serif-display); font-weight: 600; font-size: 1.45rem; letter-spacing: .01em; }
#nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
#nav a, #nav button { font-size: .9rem; }

main { max-width: 860px; margin: 0 auto; padding: 24px 20px 80px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; text-decoration: none;
  border: 1px solid var(--rule); background: var(--card); border-radius: 999px;
  padding: 6px 14px; font-size: .95rem; line-height: 1.3;
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: #9b1c1c; border-color: #e5b4b4; }
.btn.link { border: none; background: none; padding: 6px 4px; text-decoration: underline; text-underline-offset: 3px; }
.btn[disabled] { opacity: .55; cursor: default; }

/* Home */
.hero { text-align: center; margin: 8px 0 22px; }
.hero h1 { font-family: var(--serif-display); font-weight: 500; font-size: 2.4rem; margin: 0; line-height: 1.1; }
.hero p { margin: 6px 0 0; font-style: italic; color: var(--muted); }
.search {
  width: 100%; padding: 14px 18px; font-size: 1.1rem; border: 1px solid var(--rule);
  border-radius: 999px; background: var(--card); outline: none;
}
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 14px 0 6px; }
.chip { border: 1px solid var(--rule); background: transparent; border-radius: 999px; padding: 4px 12px; font-size: .9rem; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.filters { display: flex; justify-content: center; align-items: center; gap: 12px; flex-wrap: wrap; margin: 8px 0 18px; }
.filters select { border: 1px solid var(--rule); background: var(--card); border-radius: 999px; padding: 4px 12px; font-size: .9rem; }
.count { color: var(--muted); font-size: .9rem; }
.chip.fav { border-color: #d8b25a; }
.chip.fav[aria-pressed="true"] { background: #b8860b; border-color: #b8860b; color: #fff; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.group h2 {
  font-family: var(--serif-display); font-weight: 600; font-size: 1.5rem;
  margin: 26px 0 4px; padding-bottom: 4px; border-bottom: 1px solid var(--rule);
}
.list { list-style: none; margin: 0; padding: 0; }
.list li a {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 10px 2px; text-decoration: none; border-bottom: 1px dotted var(--rule);
}
.list li a:hover .t { color: var(--accent); }
.list .t { font-size: 1.12rem; }
.list .by { font-style: italic; color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.list .cat { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-left: 8px; }

/* Recipe */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar .spacer { flex: 1; }
article.recipe { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 28px 30px 34px; }
.recipe h1 { font-family: var(--serif-display); font-weight: 500; font-size: 2.3rem; line-height: 1.1; margin: 0; }
.recipe .byline { font-style: italic; margin: 6px 0 0; color: var(--ink); }
.recipe .byline .lbl { color: var(--muted); }
.recipe .meta { font-size: .9rem; color: var(--muted); margin-top: 4px; }
.recipe hr { border: none; border-top: 1px solid var(--ink); opacity: .55; margin: 14px 0 20px; }
.recipe h3 { font-family: var(--serif-display); font-weight: 600; font-size: 1.25rem; margin: 22px 0 6px; }
.ingredients { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 34px; }
.ingredients li { break-inside: avoid; padding: 2px 0 2px 26px; position: relative; cursor: pointer; }
.ingredients li::before {
  content: ''; position: absolute; left: 2px; top: .55em; width: 13px; height: 13px;
  border: 1px solid var(--rule); border-radius: 3px; background: var(--card);
}
.ingredients li.done { color: var(--muted); text-decoration: line-through; }
.ingredients li.done::before { background: var(--accent); border-color: var(--accent); }
.ingredients li.sub { cursor: default; padding-left: 0; margin-top: 10px; font-style: italic; color: var(--muted); }
.ingredients li.sub::before { display: none; }
.steps { padding-left: 1.4em; margin: 0; }
.steps li { margin-bottom: 10px; padding-left: 4px; }
.steps.single { list-style: none; padding-left: 0; }
.notes { background: var(--accent-soft); border-radius: 8px; padding: 12px 16px; margin-top: 20px; font-style: italic; }
.notes strong { font-style: normal; }
.tags { margin-top: 18px; display: flex; gap: 6px; flex-wrap: wrap; }
.tags a { font-size: .8rem; border: 1px solid var(--rule); border-radius: 999px; padding: 1px 10px; text-decoration: none; color: var(--muted); }
.originals { margin-top: 26px; }
.originals .thumbs { display: flex; gap: 10px; flex-wrap: wrap; }
.originals img { height: 120px; width: auto; border-radius: 6px; border: 1px solid var(--rule); cursor: zoom-in; background: #eee; }

/* Forms */
.form { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 24px; }
.form h1 { font-family: var(--serif-display); font-weight: 500; margin: 0 0 14px; font-size: 2rem; }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 500; margin-bottom: 4px; }
.req { color: var(--accent); }
.field .hint { font-size: .85rem; color: var(--muted); margin-top: 3px; }
.field input[type=text], .field input[type=email], .field select, .field textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--rule); border-radius: 8px; background: var(--paper);
}
.field textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
.field textarea.tall { min-height: 220px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.photo-list { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.photo-list .ph { position: relative; }
.photo-list img { height: 96px; border-radius: 6px; border: 1px solid var(--rule); display: block; }
.photo-list button { position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%; border: none; background: var(--ink); color: #fff; cursor: pointer; line-height: 1; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.actions .spacer { flex: 1; }
.msg { padding: 10px 14px; border-radius: 8px; background: var(--accent-soft); margin: 12px 0; }
.msg.err { background: #fbe9e9; color: #8a1c1c; }

/* Lightbox */
#lightbox { position: fixed; inset: 0; background: rgba(20,16,12,.92); z-index: 20; display: flex; align-items: center; justify-content: center; padding: 20px; }
#lightbox img { max-width: 100%; max-height: 100%; border-radius: 4px; }
#lightbox button { position: absolute; top: 12px; right: 16px; font-size: 2rem; color: #fff; background: none; border: none; cursor: pointer; }

@media (max-width: 640px) {
  body { font-size: 18px; }
  .brand { font-size: 1.2rem; }
  .site-header { padding: 10px 14px; }
  .toolbar .btn { padding: 5px 11px; font-size: .88rem; }
  main { padding: 16px 14px 60px; }
  .hero h1 { font-size: 1.9rem; }
  article.recipe { padding: 20px 18px 26px; }
  .recipe h1 { font-size: 1.85rem; }
  .ingredients { columns: 1; }
  .row { grid-template-columns: 1fr; }
  .list .by { display: none; }
}

@media print {
  .site-header, .toolbar, .originals, .tags, #lightbox { display: none !important; }
  body { background: #fff; font-size: 12pt; }
  main { padding: 0; max-width: none; }
  article.recipe { border: none; padding: 0; }
  .ingredients li { padding-left: 0; }
  .ingredients li::before { display: none; }
  .ingredients li.done { text-decoration: none; color: inherit; }
  .notes { background: none; padding: 0; border-left: 2px solid #ccc; padding-left: 10px; }
}
