:root {
  --paper: #f6f0e1;
  --card: #fffdf8;
  --ink: #1e2a52;
  --ink-soft: #4a5378;
  --muted: #7a7f95;
  --rule: #e2d7bf;
  --rule-strong: #cdbf9f;
  --accent: #24346b;
  --warm: #a8492a;
  --check: #8a5a00;
  --check-bg: #fff4d6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(30, 42, 82, .06), 0 4px 14px rgba(30, 42, 82, .06);
  --display: "Fraunces", Georgia, serif;
  --type: "Courier Prime", "Courier New", monospace;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.55 var(--ui);
}
a { color: inherit; }
button { font: inherit; color: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }

/* ---------- masthead ---------- */
.masthead {
  position: sticky; top: 0; z-index: 20;
  background: rgba(246, 240, 225, .94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--rule);
}
.masthead-inner {
  max-width: 1120px; margin: 0 auto; padding: 12px 20px 8px;
  display: flex; gap: 16px; align-items: center;
}
.brand { display: flex; gap: 10px; align-items: center; text-decoration: none; flex: none; }
.brand-mark { font-size: 22px; color: var(--warm); }
.brand-name { font: 600 22px/1.1 var(--display); letter-spacing: -.01em; }
.search {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--rule-strong); border-radius: 999px;
  padding: 0 14px; min-width: 0;
}
.search:focus-within { border-color: var(--ink-soft); box-shadow: 0 0 0 3px rgba(36, 52, 107, .12); }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; flex: none; }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font: 16px var(--ui); color: var(--ink); padding: 9px 0; }
.btn-ghost {
  flex: none; background: none; border: 1px solid var(--rule-strong); border-radius: 999px;
  padding: 7px 14px; font-size: 14px; cursor: pointer;
}
.btn-ghost:hover { background: var(--card); }

/* book toggle */
.books-inner {
  max-width: 1120px; margin: 0 auto; padding: 4px 20px 12px;
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
}
.books-inner::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--rule-strong); background: var(--card);
  border-radius: 999px; padding: 6px 14px 6px 10px; cursor: pointer;
  font-size: 15px; white-space: nowrap;
}
.chip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--ink)); }
.chip .n { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--c, var(--ink)); border-color: var(--c, var(--ink)); color: #fff; }
.chip[aria-pressed="true"] .dot { background: #fff; }
.chip[aria-pressed="true"] .n { color: rgba(255, 255, 255, .8); }
.chip:focus-visible, .tab:focus-visible, .card:focus-visible { outline: 3px solid rgba(36, 52, 107, .35); outline-offset: 2px; }
.chip-label { font-size: 13px; color: var(--muted); align-self: center; padding-right: 2px; flex: none; }

/* ---------- layout ---------- */
main { max-width: 1120px; margin: 0 auto; padding: 24px 20px 48px; outline: none; }

.intro { display: flex; justify-content: space-between; gap: 24px; align-items: end; margin: 8px 0 20px; flex-wrap: wrap; }
.intro h1 { font: 600 clamp(28px, 4vw, 40px)/1.1 var(--display); margin: 0 0 6px; letter-spacing: -.015em; }
.intro p { margin: 0; color: var(--ink-soft); }
.quote {
  max-width: 420px; margin: 0; padding: 10px 0 10px 16px; border-left: 3px solid var(--warm);
  font: italic 16px/1.5 var(--display); color: var(--ink-soft);
}
.quote cite { display: block; font: 13px var(--ui); font-style: normal; color: var(--muted); margin-top: 4px; }

.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; border-bottom: 1px solid var(--rule); margin-bottom: 18px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tab {
  background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 12px; cursor: pointer;
  color: var(--ink-soft); font-size: 15px; white-space: nowrap;
}
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.sort { font-size: 14px; color: var(--muted); display: flex; gap: 6px; align-items: center; padding-bottom: 6px; }
.sort select { font: 14px var(--ui); color: var(--ink); background: var(--card); border: 1px solid var(--rule-strong); border-radius: 6px; padding: 4px 6px; }

.count { font-size: 14px; color: var(--muted); margin: 0 0 12px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card {
  display: flex; flex-direction: column; gap: 8px; text-decoration: none;
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 16px 18px 14px; box-shadow: var(--shadow); position: relative; overflow: hidden;
  transition: transform .12s ease, box-shadow .12s ease;
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(30, 42, 82, .08), 0 10px 24px rgba(30, 42, 82, .1); }
.card h3 { font: 600 19px/1.25 var(--display); margin: 0; }
.card .ing { font: 14px/1.45 var(--type); color: var(--ink-soft); margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { display: flex; gap: 6px 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: auto; }
.badge { display: inline-flex; align-items: center; gap: 6px; color: var(--c); font-weight: 600; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }

.empty { text-align: center; padding: 56px 20px; color: var(--ink-soft); }
.empty h2 { font: 600 24px var(--display); color: var(--ink); margin: 0 0 8px; }
mark { background: #ffe7a3; color: inherit; border-radius: 2px; padding: 0 1px; }

/* ---------- recipe page ---------- */
.back { display: inline-flex; gap: 6px; align-items: center; font-size: 15px; color: var(--ink-soft); text-decoration: none; margin-bottom: 14px; }
.back:hover { color: var(--ink); }
.recipe-head { border-bottom: 1px solid var(--rule); padding-bottom: 18px; margin-bottom: 24px; display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: end; }
.recipe-head h1 { font: 600 clamp(30px, 5vw, 46px)/1.08 var(--display); margin: 8px 0 10px; letter-spacing: -.02em; }
.recipe-head .note { font: italic 18px/1.4 var(--display); color: var(--ink-soft); margin: 0 0 10px; }
.facts { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; color: var(--ink-soft); }
.facts b { color: var(--ink); font-weight: 600; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.btn {
  display: inline-flex; gap: 6px; align-items: center; cursor: pointer;
  background: var(--card); border: 1px solid var(--rule-strong); border-radius: 8px;
  padding: 7px 12px; font-size: 14px; text-decoration: none;
}
.btn:hover { border-color: var(--ink-soft); }
.btn[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

.recipe-body { display: grid; grid-template-columns: minmax(260px, 5fr) 7fr; gap: 40px; align-items: start; }
.panel h2 { font: 600 13px var(--ui); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
.ingredients { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); position: sticky; top: 132px; }
.ingredients h3 { font: 600 15px var(--display); margin: 16px 0 6px; color: var(--warm); }
.ingredients h3:first-of-type { margin-top: 0; }
.ingredients ul { list-style: none; margin: 0; padding: 0; }
.ingredients li { font: 16px/1.4 var(--type); }
.ingredients label { display: flex; gap: 10px; padding: 6px 0; cursor: pointer; border-bottom: 1px dashed var(--rule); }
.ingredients li:last-child label { border-bottom: 0; }
.ingredients input { appearance: none; flex: none; width: 18px; height: 18px; margin-top: 1px; border: 1.5px solid var(--rule-strong); border-radius: 4px; background: #fff; cursor: pointer; display: grid; place-content: center; }
.ingredients input::after { content: "✓"; font: 700 13px var(--ui); color: #fff; opacity: 0; }
.ingredients input:checked { background: var(--ink); border-color: var(--ink); }
.ingredients input:checked::after { opacity: 1; }
.ingredients input:checked + span { color: var(--muted); text-decoration: line-through; }
.ingredients .hint { font: 13px var(--ui); color: var(--muted); margin: 12px 0 0; }
.ingredients a { color: var(--accent); }

.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 34px 1fr; gap: 12px; margin-bottom: 18px; font-size: 18px; line-height: 1.6; }
.steps li::before { content: counter(step); font: 600 16px/34px var(--display); width: 34px; height: 34px; text-align: center; border-radius: 50%; border: 1.5px solid var(--rule-strong); color: var(--warm); }
.steps.single li { grid-template-columns: 1fr; }
.steps.single li::before { display: none; }

.aside-notes { margin-top: 24px; display: grid; gap: 12px; }
.callout { border-radius: 8px; padding: 12px 14px; font-size: 15px; }
.callout.check { background: var(--check-bg); border: 1px solid #f0d98c; color: #5c4300; }
.callout.check b { color: var(--check); }
.callout.editor { background: #eef1f8; border: 1px solid #d5dcee; color: var(--ink-soft); }
.callout.quote { background: none; border-left: 3px solid var(--warm); border-radius: 0; font: italic 17px/1.5 var(--display); color: var(--ink-soft); }

.original { margin-top: 28px; display: flex; gap: 16px; align-items: center; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 12px; }
.original button { border: 0; padding: 0; background: none; cursor: zoom-in; flex: none; }
.original img { width: 84px; height: 112px; object-fit: cover; border-radius: 4px; border: 1px solid var(--rule); display: block; }
.original p { margin: 0; font-size: 15px; color: var(--ink-soft); }
.original strong { color: var(--ink); font-family: var(--display); font-weight: 600; font-size: 17px; display: block; }

/* community (design only for now) */
.community { margin-top: 48px; border-top: 1px solid var(--rule); padding-top: 28px; }
.community h2 { font: 600 26px var(--display); margin: 0 0 4px; }
.community > p { margin: 0 0 18px; color: var(--ink-soft); }
.made-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.made-slot { aspect-ratio: 1; border: 2px dashed var(--rule-strong); border-radius: var(--radius); display: grid; place-content: center; text-align: center; color: var(--muted); font-size: 14px; padding: 10px; background: rgba(255, 253, 248, .6); }
.made-slot span { font-size: 28px; display: block; color: var(--rule-strong); }

/* header user area */
.userbar { display: flex; gap: 8px; align-items: center; flex: none; }
.btn-ghost, .btn-solid { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn-solid { background: var(--ink); color: #fff; border: 1px solid var(--ink); border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.btn-solid:hover { background: #2c3c78; }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); background: var(--card); border: 1px solid var(--rule-strong); border-radius: 10px; box-shadow: var(--shadow); min-width: 180px; padding: 6px; display: grid; z-index: 30; }
.menu-list a, .menu-list button { text-align: left; background: none; border: 0; padding: 9px 12px; border-radius: 6px; text-decoration: none; font-size: 15px; cursor: pointer; }
.menu-list a:hover, .menu-list button:hover { background: var(--paper); }
.pill { background: var(--warm); color: #fff; border-radius: 999px; font-size: 12px; padding: 0 7px; font-weight: 700; }

/* status tags */
.tag { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 1px 9px; background: #eee; color: #555; text-transform: capitalize; }
.tag.wait, .tag.pending { background: var(--check-bg); color: var(--check); }
.tag.no, .tag.blocked { background: #fbe3e0; color: #9c2f22; }
.tag.active { background: #e2f1e4; color: #2f6b3a; }

/* cards with a picture */
.card.has-photo { padding: 0; }
.card .card-body { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card.has-photo .card-body { padding: 12px 18px 14px; }
.card-img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; background: var(--rule); }

/* recipe hero picture */
.hero { display: block; width: 100%; border: 0; padding: 0; margin: 0 0 18px; cursor: zoom-in; background: none; }
.hero img { width: 100%; max-height: 420px; object-fit: cover; border-radius: var(--radius); display: block; box-shadow: var(--shadow); }

/* community */
.made { margin: 0; }
.made button { border: 0; padding: 0; background: none; cursor: zoom-in; display: block; width: 100%; }
.made img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); display: block; border: 1px solid var(--rule); }
.made figcaption { font-size: 13px; color: var(--ink-soft); margin-top: 4px; display: flex; gap: 8px; }
.comments { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 12px; max-width: 680px; }
.comment { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 12px 14px; }
.comment-head { display: flex; gap: 10px; align-items: baseline; font-size: 14px; color: var(--muted); }
.comment-head b { color: var(--ink); font-size: 15px; }
.comment p { margin: 4px 0 0; white-space: pre-wrap; }
.comment-photo { border: 0; padding: 0; background: none; cursor: zoom-in; margin-top: 8px; }
.comment-photo img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; display: block; }
.link-del { margin-left: auto; background: none; border: 0; color: #9c2f22; font-size: 13px; cursor: pointer; padding: 0; text-decoration: underline; }
.signin-note { background: var(--card); border: 1px dashed var(--rule-strong); border-radius: var(--radius); padding: 14px; max-width: 680px; }
.comment-box { display: grid; gap: 10px; max-width: 680px; }
.comment-box textarea { font: 16px var(--ui); border: 1px solid var(--rule-strong); border-radius: 8px; padding: 10px 12px; min-height: 84px; background: var(--card); resize: vertical; color: var(--ink); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn-primary { background: var(--ink); color: #fff; border: 0; border-radius: 8px; padding: 9px 16px; cursor: pointer; font-weight: 600; font-size: 15px; text-decoration: none; }
.btn-primary[disabled], .btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.danger { color: #9c2f22; border-color: #e6b7b0; }
.btn.danger:hover { background: #fbe3e0; }

/* forms */
.form-page { max-width: 460px; margin: 8px auto; }
.form-page.wide { max-width: 860px; }
.form-page h1 { font: 600 34px/1.1 var(--display); margin: 6px 0 12px; }
.form-page h2 { font: 600 22px var(--display); margin: 32px 0 12px; }
.lead { color: var(--ink-soft); margin: 0 0 18px; }
.stack { display: grid; gap: 14px; }
.stack label { display: grid; gap: 5px; font-weight: 600; font-size: 15px; }
.stack small { font-weight: 400; color: var(--muted); font-size: 13px; }
.stack input:not([type=file]), .stack select, .stack textarea { font: 16px var(--ui); color: var(--ink); background: var(--card); border: 1px solid var(--rule-strong); border-radius: 8px; padding: 10px 12px; width: 100%; font-weight: 400; }
.stack textarea { font-family: var(--type); line-height: 1.5; resize: vertical; }
.stack input:focus, .stack select:focus, .stack textarea:focus { outline: none; border-color: var(--ink-soft); box-shadow: 0 0 0 3px rgba(36, 52, 107, .12); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-page > .callout { margin-bottom: 16px; }
.loading { text-align: center; color: var(--muted); padding: 60px 0; }
.form-error { color: #9c2f22; margin: 0; font-weight: 600; }
.form-error:empty { display: none; }
.bookform { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 4px 18px 18px; }
.bookform h2 { margin-top: 14px; }

/* approvals */
.queue { display: grid; gap: 10px; }
.queue-item { display: flex; justify-content: space-between; gap: 14px; align-items: center; flex-wrap: wrap; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 12px 14px; }
.queue-item a { color: var(--ink); }
table.users { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; font-size: 15px; }
.users th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--rule); }
.users td { padding: 10px 12px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.users tr:last-child td { border-bottom: 0; }
.users .right { text-align: right; white-space: nowrap; }

/* lightbox */
#lightbox { border: 0; padding: 0; background: transparent; max-width: 96vw; max-height: 96vh; }
#lightbox::backdrop { background: rgba(15, 20, 40, .82); }
#lb-img { display: block; max-width: 92vw; max-height: 86vh; border-radius: 6px; }
#lb-cap { color: #fff; text-align: center; margin: 8px 0 0; font-size: 14px; }
.lb-close { position: fixed; top: 14px; right: 18px; background: rgba(255, 255, 255, .15); color: #fff; border: 0; width: 40px; height: 40px; border-radius: 50%; font-size: 18px; cursor: pointer; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 15px; opacity: 0; pointer-events: none; transition: all .2s ease; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.foot { border-top: 1px solid var(--rule); text-align: center; font-size: 14px; color: var(--ink-soft); padding: 20px; }

/* ---------- small screens / controller landscape ---------- */
@media (max-width: 820px) {
  .recipe-body { grid-template-columns: 1fr; gap: 28px; }
  .ingredients { position: static; }
  .recipe-head { grid-template-columns: 1fr; }
  .actions { justify-content: flex-start; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .masthead-inner { flex-wrap: wrap; gap: 10px; padding: 10px 14px 6px; }
  .brand-name { font-size: 19px; }
  .search { order: 3; flex-basis: 100%; }
  .userbar { margin-left: auto; }
  .btn-ghost, .btn-solid { padding: 5px 11px; }
  .cols { grid-template-columns: 1fr; }
  .users thead { display: none; }
  .users td { display: block; border: 0; padding: 4px 12px; }
  .users tr { display: block; border-bottom: 1px solid var(--rule); padding: 8px 0; }
  .users .right { text-align: left; }
  .books-inner { padding: 2px 14px 10px; }
  main { padding: 16px 14px 40px; }
  .steps li { font-size: 17px; }
  .quote { display: none; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .masthead { position: static; }
}

@media print {
  .masthead, .foot, .actions, .community, .back, .original, .ingredients .hint, .hero { display: none !important; }
  body { background: #fff; }
  .ingredients { box-shadow: none; position: static; }
  .recipe-body { grid-template-columns: 2fr 3fr; }
}
