:root {
  --bg: #faf8f5;
  --panel: #fff;
  --ink: #22201d;
  --muted: #6d6660;
  --line: #e5dfd7;
  --accent: #3f6f4f;
  --accent-soft: #eaf1ec;
  --warn: #9a6512;
  --warn-soft: #fdf3e2;
  --radius: 10px;
  --wrap: 1120px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614; --panel: #201e1b; --ink: #ece7e0; --muted: #a49c93;
    --line: #332f2b; --accent: #7fb08d; --accent-soft: #24302a;
    --warn: #d9a441; --warn-soft: #2a2317;
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.22; letter-spacing: -0.015em; margin: 0 0 .4em; }
h1 { font-size: clamp(1.6rem, 3.4vw, 2.3rem); font-weight: 640; }
h2 { font-size: 1.02rem; font-weight: 620; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
a { color: inherit; }
img { max-width: 100%; display: block; }

button, select, input {
  font: inherit; color: inherit;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: .5rem .7rem;
}
button { cursor: pointer; transition: border-color .15s, background .15s; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 560; }
button.primary:hover { filter: brightness(1.1); }
button.ghost { background: transparent; }
button.danger:hover { border-color: #b4483a; color: #b4483a; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- chrome ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1.5rem;
  padding: .7rem max(1rem, (100vw - var(--wrap)) / 2);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 680; font-size: 1.12rem; text-decoration: none; letter-spacing: -0.02em; }
.brand span { color: var(--accent); }
.topbar nav { margin-left: auto; display: flex; gap: 1.1rem; }
.topbar nav a { text-decoration: none; color: var(--muted); font-size: .94rem; padding: .2rem 0; border-bottom: 2px solid transparent; }
.topbar nav a:hover { color: var(--ink); }
.topbar nav a.on { color: var(--ink); border-bottom-color: var(--accent); }
.pill {
  background: var(--accent); color: #fff; border-radius: 99px;
  padding: 0 .42rem; font-size: .76rem; font-weight: 640; margin-left: .2rem;
}
main { padding: 1.6rem max(1rem, (100vw - var(--wrap)) / 2) 4rem; min-height: 70vh; }
.foot {
  border-top: 1px solid var(--line); color: var(--muted); font-size: .86rem;
  padding: 1.6rem max(1rem, (100vw - var(--wrap)) / 2) 2.2rem;
  display: flex; flex-wrap: wrap; gap: .5rem 2rem; align-items: baseline;
}
.foot p { margin: 0; }
.foot-brand { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem 1rem; }
.foot-name { font-weight: 680; font-size: 1rem; color: var(--ink); letter-spacing: -0.02em; }
.foot-name span { color: var(--accent); }
.foot-slogan { font-style: italic; }
.foot-meta { margin-left: auto; }
.foot-meta a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; }
.foot-meta a:hover { border-bottom-color: currentColor; }
@media (max-width: 620px) { .foot-meta { margin-left: 0; } }

/* ---------- browse ---------- */
.search-row { display: flex; gap: .6rem; margin-bottom: .8rem; }
#q { flex: 1; font-size: 1.02rem; padding: .7rem .9rem; }
.filters { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; margin-bottom: 1rem; }
.chk { display: inline-flex; align-items: center; gap: .4rem; font-size: .92rem; color: var(--muted); }
.chk input { width: auto; padding: 0; }
.count { color: var(--muted); font-size: .88rem; margin: 0 0 1rem; }

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; text-decoration: none; display: flex; flex-direction: column;
  transition: transform .14s, box-shadow .14s, border-color .14s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.09); border-color: var(--muted); }
/* Generated tile — no photographs. Hue comes from the course, the angle and
   second stop from the recipe id, so the grid groups by eye without any two
   tiles matching. The text is the ingredients that identify the dish. */
.tile {
  aspect-ratio: 5 / 3; border-bottom: 1px solid var(--line);
  position: relative; display: flex; align-items: flex-end;
  padding: .8rem .85rem;
  background:
    linear-gradient(var(--a),
      hsl(var(--h) 42% 88%) 0%,
      hsl(calc(var(--h) + 18) 34% 80%) 100%);
}
@media (prefers-color-scheme: dark) {
  .tile {
    background:
      linear-gradient(var(--a),
        hsl(var(--h) 26% 22%) 0%,
        hsl(calc(var(--h) + 18) 22% 15%) 100%);
  }
}
.tile-glyph {
  position: absolute; top: .5rem; right: .65rem;
  font-size: 1.9rem; opacity: .82; line-height: 1;
}
.tile-ing {
  font-size: .82rem; font-weight: 600; line-height: 1.35;
  color: hsl(var(--h) 45% 22%);
  text-transform: lowercase; letter-spacing: .005em;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
@media (prefers-color-scheme: dark) { .tile-ing { color: hsl(var(--h) 38% 86%); } }
.card .body { padding: .75rem .85rem .9rem; display: flex; flex-direction: column; gap: .3rem; flex: 1; }
.card h3 { font-size: 1rem; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.card p { margin: 0; font-size: .86rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .tags { margin-top: auto; padding-top: .45rem; display: flex; gap: .35rem; flex-wrap: wrap; }
.tag { font-size: .72rem; padding: .1rem .45rem; border-radius: 99px; background: var(--accent-soft); color: var(--accent); border: 1px solid var(--line); }
.tag.plain { background: transparent; color: var(--muted); }
.card.chosen { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

/* ---------- planner ---------- */
.planner {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1rem; margin-bottom: 1rem;
}
.planner-lead { margin: 0 0 .6rem; font-weight: 600; }
.planner-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.planner-row label { display: inline-flex; align-items: center; gap: .35rem; font-size: .9rem; color: var(--muted); }
.planner-row select { padding: .35rem .5rem; }
.planner-note { margin: .7rem 0 0; font-size: .88rem; color: var(--muted); }
.week-sum { margin: 0 0 .9rem; font-size: .95rem; color: var(--muted); }
.week-sum b { color: var(--ink); }

/* ---------- staples ---------- */
.staples .lead { max-width: 62ch; color: var(--muted); margin-bottom: 1.4rem; }
.staples .lead b { color: var(--ink); }
.staple-add { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.6rem; }
.staple-add #sItem { flex: 1 1 14rem; }
.staple-add #sQty { width: 5rem; }
.staple-add #sUnit { width: 9rem; }
.staple-rows { list-style: none; padding: 0; margin: 0; }
.staple-rows li {
  display: flex; align-items: center; gap: .6rem;
  padding: .4rem 0; border-bottom: 1px dashed var(--line); font-size: .95rem;
}
.staple-rows li:last-child { border-bottom: none; }
.staple-rows li.off { opacity: .45; }
.staple-rows input[type="checkbox"] { accent-color: var(--accent); width: auto; }
.staple-rows .sq { width: 4.2rem; padding: .25rem .4rem; text-align: right; font-variant-numeric: tabular-nums; }
.staple-rows .su { color: var(--muted); font-size: .86rem; min-width: 4.5rem; }
.staple-rows .sn { flex: 1; font-weight: 550; }
.staple-rows button { margin-left: auto; font-size: .82rem; padding: .25rem .55rem; }

/* ---------- recipe ---------- */
.back { display: inline-block; color: var(--muted); text-decoration: none; font-size: .9rem; margin-bottom: 1rem; }
.back:hover { color: var(--ink); }
.recipe-head { max-width: 62ch; }
.recipe-head .desc { font-size: 1.06rem; color: var(--ink); margin: .4rem 0 .6rem; }
.recipe-head .meta { color: var(--muted); font-size: .9rem; margin: 0 0 1rem; }
.actions { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; margin-bottom: 2rem; }
.scale { font-size: .9rem; color: var(--muted); display: inline-flex; align-items: center; gap: .4rem; }
.scale select { padding: .35rem .5rem; }

.recipe-body { display: grid; grid-template-columns: minmax(230px, 1fr) 1.7fr; gap: 2.4rem; align-items: start; }
@media (max-width: 720px) { .recipe-body { grid-template-columns: 1fr; gap: 1.6rem; } }
.component + .component { margin-top: 1.1rem; }
.component h3 { font-size: .9rem; font-weight: 620; color: var(--accent); margin-bottom: .3rem; }
ul.ing { list-style: none; padding: 0; margin: 0; }
ul.ing li { padding: .32rem 0; border-bottom: 1px dashed var(--line); font-size: .95rem; }
ul.ing li:last-child { border-bottom: none; }
ul.ing .q { font-weight: 600; }
ul.ing .note { color: var(--muted); }
ul.ing .flag { font-size: .74rem; color: var(--warn); display: block; }
ol#rSteps { padding-left: 1.3rem; margin: 0; }
ol#rSteps li { margin-bottom: .85rem; padding-left: .25rem; }
#rNotes .note-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; margin-top: 1.4rem; font-size: .93rem; }
#rNotes h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .3rem; }

.provenance { margin-top: 3rem; border-top: 1px solid var(--line); padding-top: 1.4rem; }
.provenance summary { cursor: pointer; color: var(--muted); font-size: .92rem; }
.prov-body { margin-top: 1rem; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.prov-body img { border: 1px solid var(--line); border-radius: var(--radius); }
.edit { background: var(--accent-soft); border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; font-size: .88rem; margin-bottom: .5rem; }
.edit b { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); }

/* ---------- plan ---------- */
.plan-row {
  display: flex; align-items: center; gap: .8rem; padding: .7rem .9rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .5rem;
}
.plan-row a { flex: 1; text-decoration: none; font-weight: 550; }
.plan-row select { padding: .3rem .45rem; font-size: .86rem; }
.list-opts { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin: 1.6rem 0 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.list-opts button { margin-left: auto; }
.list-opts button + button { margin-left: 0; }

.aisle { margin-bottom: 1.5rem; break-inside: avoid; }
.aisle h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); margin-bottom: .45rem; padding-bottom: .25rem; border-bottom: 1px solid var(--line); }
.buy { list-style: none; padding: 0; margin: 0; }
.buy li { display: flex; gap: .6rem; align-items: baseline; padding: .3rem 0; font-size: .96rem; }
.buy input { margin: 0; width: auto; accent-color: var(--accent); }
.buy .qty { font-weight: 640; min-width: 6.5rem; }
.buy .detail { color: var(--muted); font-size: .82rem; }
.buy li.got { opacity: .42; text-decoration: line-through; }
.marks { font-size: .8rem; letter-spacing: .1em; }
.groceries-cols { columns: 2; column-gap: 2.4rem; }
@media (max-width: 720px) { .groceries-cols { columns: 1; } }
.why { display: block; font-size: .78rem; color: var(--muted); padding-left: 1.6rem; }

.callout { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; padding: .8rem 1rem; margin: 1.2rem 0; font-size: .92rem; }
.callout h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin-bottom: .35rem; }
.empty { text-align: center; padding: 4rem 1rem; color: var(--muted); }
.legend { color: var(--muted); font-size: .82rem; margin-top: 1.5rem; }

@media print {
  .topbar, .foot, .list-opts, .back, .actions, .legend { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  main { padding: 0; }
  .aisle { break-inside: avoid; }
  .groceries-cols { columns: 2; }
  .buy li.got { display: none; }
}
