/* Light is the base palette. Dark applies when the OS asks for it *and* the
   viewer hasn't explicitly chosen light, or when they've explicitly chosen
   dark — so the picker wins in both directions. */
:root {
  color-scheme: light;
  --bg: #fbfaf8;
  --panel: #ffffff;
  --ink: #1d1c1a;
  --muted: #6d6a64;
  --line: #ddd9d2;
  --product: #f3ede1;
  --product-edge: #c9bda3;
  --process: #e4edf3;
  --process-edge: #9db9cb;
  --dish: #e8e2d2;
  --dish-edge: #8d7a4e;
  --accent: #7a5c2e;
  --meter: #b9a882;
  /* How much of a planned meal's photo shows through behind its own text. The
     ink is dark here and light in the dark palette, so the two need different
     amounts of picture to stay legible over it. */
  --shot-veil: .22;
  /* How strongly today's row is washed with the accent. Same bind as the veil
     above: the accent is dark on a light ground here and light on a dark one
     there, so the two palettes need different amounts of it to read as a tint
     rather than as a block. */
  --today-veil: .07;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #191816;
    --panel: #221f1d;
    --ink: #ece8e1;
    --muted: #9a948a;
    --line: #38342f;
    --product: #2e2a24;
    --product-edge: #5e5443;
    --process: #232c33;
    --process-edge: #46606f;
    --dish: #3a3121;
    --dish-edge: #a68d57;
    --accent: #d9b877;
    --meter: #7d6a42;
    --shot-veil: .32;
    --today-veil: .12;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #191816;
  --panel: #221f1d;
  --ink: #ece8e1;
  --muted: #9a948a;
  --line: #38342f;
  --product: #2e2a24;
  --product-edge: #5e5443;
  --process: #232c33;
  --process-edge: #46606f;
  --dish: #3a3121;
  --dish-edge: #a68d57;
  --accent: #d9b877;
  --meter: #7d6a42;
  --shot-veil: .32;
  --today-veil: .12;
}

* { box-sizing: border-box; }

/* The navbar spans both columns above the sidebar and the main panel, so the
   two pages sit under one bar rather than each carrying a link to the other in
   its own furniture. Both of the rows below it scroll on their own, which is
   why the bar takes a row of the grid rather than floating over one. */
body {
  margin: 0;
  display: grid;
  grid-template-columns: 250px 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.nav {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.nav a {
  padding: 9px 12px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  border-bottom: 2px solid transparent;
}
.nav a:hover { color: var(--ink); }
/* The page you're on is marked rather than removed: a bar that drops its own
   entry moves the other one every time you cross over. */
.nav a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--accent);
}
/* The theme belongs to the whole viewer rather than to any one page, so it
   sits in the bar both pages share, pushed to the far end away from the
   links. */
.nav .scale { margin-left: auto; }
.nav .session { margin-left: 8px; font-size: 12px; padding: 4px 10px; }

/* What only a signed-in visitor can use. session.mjs says which this is; the
   server refuses the requests either way, so this is the tidiness, not the
   lock. */
[data-session="out"] .editor-only { display: none !important; }
#plan-locked { padding: 24px 20px; color: var(--muted); }

aside {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 16px;
  overflow-y: auto;
}

/* The filter sits in a page header, one control among several, so it sizes to
   itself rather than spanning anything. */
#filter {
  width: 180px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: inherit;
  font: inherit;
}

/* No page has a sidebar: its content is the whole column. */
body.single { grid-template-columns: 1fr; }

/* A dish is a column of its own so the graph can still claim the height the
   sidebar layout gave it. */
#dish { display: flex; flex-direction: column; min-height: 0; flex: 1; }
#gallery { overflow-y: auto; display: flex; flex-direction: column; min-height: 0; }

/* Cards sized by the picture: wide enough to tell two curries apart, narrow
   enough that a dozen dishes are one screen. */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
  padding: 18px 20px;
  align-content: start;
}

.card {
  display: block;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: inherit;
  text-decoration: none;
}
.card:hover { border-color: var(--dish-edge); }
.card h3 { margin: 8px 0 0; font-size: 15px; }
.card .tags { margin: 7px 0 0; }
.card .photos, .card .photos figure { margin: 0; }
/* One shape whatever the photo is, and the same shape where there is none —
   a row of cards that jostles by picture height is unreadable as a grid. */
.card .shot img, .card .shot .unfetched, .card .shot.empty {
  width: 100%;
  height: 140px;
  border-radius: 7px;
}
.card .shot img { object-fit: cover; }
.card .shot.empty {
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 12px;
}

/* A recipe being added. Same footprint as a dish's card, so the grid doesn't
   jump when one turns into the other — but dashed while it isn't one yet. Its
   stage is `data-stage`, never a class: `.ingredients` is already taken. */
.cards.jobs { padding-bottom: 0; }
.card.job { border-style: dashed; display: flex; flex-direction: column; min-width: 0; }
.card.job[data-stage="ready"] { border-style: solid; border-color: var(--accent); }
.card.job[data-stage="failed"] .shot { opacity: .6; }
.card.job[aria-busy] .shot img { opacity: .8; }
/* An address can be one unbroken word as long as the card; two lines of it say
   which page it is, and the rest is in the draft's Source tab. */
.card.job h3 {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; overflow-wrap: anywhere;
}
.job-stage { display: flex; align-items: center; gap: 6px; margin: 6px 0 0; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.card.job[data-stage="ready"] .job-stage { color: var(--accent); font-weight: 600; }
.job-error { margin: 4px 0 0; font-size: 12px; color: var(--ink); line-height: 1.4; }
.job-steps { display: flex; gap: 4px; list-style: none; margin: 10px 0 0; padding: 0; }
.job-steps li { flex: 1; height: 3px; border-radius: 2px; background: var(--line); }
.job-steps li.done { background: var(--accent); }
.job-steps li.now { background: var(--accent); animation: job-pulse 1.4s ease-in-out infinite; }
.job-do { display: flex; gap: 6px; margin-top: auto; padding-top: 12px; }
.spinner {
  width: 9px; height: 9px; flex: none;
  border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: job-spin .9s linear infinite;
}
@keyframes job-spin { to { transform: rotate(360deg); } }
@keyframes job-pulse { 0%, 100% { opacity: .3; } 50% { opacity: .8; } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  .job-steps li.now { animation: none; opacity: .5; }
}
.badge { font-size: 12px; color: var(--accent); margin-left: 10px; }

/* The list: one dish per line over its own photo, and the figures on the right
   where they line up down the column — reading two dishes against each other is
   the whole reason to be in this mode. */
#cards.rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 20px;
}
#cards.rows .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding: 11px 14px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: inherit;
  text-decoration: none;
}
#cards.rows .row:hover { border-color: var(--dish-edge); }
/* The dish's photo, behind its line, on the same terms the plan's cells take
   it: a layer of its own so the veil is that layer's opacity rather than an
   overlay that would have to know which of the two panel colours it's over.
   Only where the file has been fetched — gallery.mjs sets --shot or leaves the
   row plain, and a plain row is the panel it always was. */
#cards.rows .row.shot::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--shot);
  background-size: cover;
  background-position: center;
  opacity: var(--shot-veil);
  pointer-events: none;
}
/* Everything the row holds sits over it. */
#cards.rows .row > * { position: relative; z-index: 1; }
#cards.rows .row h3 { margin: 0; font-size: 15px; }
#cards.rows .row .tags { margin: 6px 0 0; }
#cards.rows .row .what { min-width: 180px; }
#cards.rows .per { text-align: right; font-size: 12px; color: var(--muted); }
#cards.rows .basis { font-variant: small-caps; letter-spacing: .03em; }
#cards.rows .pending { margin: 3px 0 0; }
/* Label over figure, so the columns read across the rows even where a name
   wraps. */
#cards.rows .figures {
  display: flex;
  gap: 16px;
  margin: 4px 0 0;
  justify-content: flex-end;
  flex-wrap: wrap;
}
#cards.rows .figures .figure { text-align: right; }
#cards.rows .figures dt { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; }
#cards.rows .figures dd { margin: 1px 0 0; color: var(--ink); font-variant-numeric: tabular-nums; }

.empty-list { padding: 0 20px; color: var(--muted); }

/* The way back out of a dish. It sits above the title rather than beside it:
   the title is the heading of the page, and the crumb is how you left. */
.crumbs { display: flex; flex-direction: column; gap: 2px; }
#back {
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  width: fit-content;
}
#back:hover { color: var(--accent); }

/* The dish's own properties, on the title's own line — they're a caption to
   the name rather than a section of their own, and they wrap under it when the
   header runs out of room. */
.heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 14px; }
#meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 14px;
}
#meta:empty { display: none; }
#meta a { color: var(--accent); }
/* Pairs on one line: each dt sits a gap away from the previous dd, and its own
   dd right beside it, so "serves: 2  source: …" reads as pairs rather than as
   an evenly spaced row of unrelated words. */
#meta dl { display: flex; flex-wrap: wrap; row-gap: 3px; margin: 0; }
#meta dt { color: var(--muted); margin-left: 18px; }
#meta dt:first-of-type { margin-left: 0; }
#meta dt::after { content: ":"; }
#meta dd { margin: 0 0 0 5px; color: var(--ink); overflow-wrap: anywhere; }

/* The bookkeeping — slug, the page it was read from, the day it was read —
   behind one mark, since it answers a question about the recipe rather than
   telling you anything about cooking it. */
.info {
  width: 17px;
  height: 17px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--muted);
  font: 600 11px/1 system-ui, serif;
  font-style: italic;
  cursor: pointer;
  align-self: center;
}
.info:hover { color: var(--ink); border-color: var(--accent); }

#provenance {
  position: fixed;
  margin: 0;
  width: min(320px, calc(100vw - 16px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--ink);
  font-size: 12px;
  box-shadow: 0 8px 24px rgb(0 0 0 / .18);
}
#provenance h3 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
/* Two columns rather than the header's one line: there's room here, and a
   label above its value is easier to scan than pairs run together. */
#provenance dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 0; }
#provenance dt { color: var(--muted); }
#provenance dt::after { content: ":"; }
#provenance dd { margin: 0; overflow-wrap: anywhere; }
#provenance a { color: var(--accent); }

.tag {
  display: inline-block;
  padding: 1px 7px;
  margin: 0 4px 4px 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 11px;
}

main { display: flex; flex-direction: column; min-width: 0; }

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

h2 { margin: 0; font-size: 18px; }

[hidden] { display: none !important; }

.legend {
  position: absolute;
  top: 10px; right: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  font-size: 12px;
  color: var(--muted);
}
.key::before {
  content: "";
  display: inline-block;
  width: 10px; height: 10px;
  margin-right: 5px;
  border-radius: 3px;
  vertical-align: -1px;
}
.key.product::before { background: var(--product); border: 1px solid var(--product-edge); }
.key.process::before { background: var(--process); border: 1px solid var(--process-edge); }

#reset {
  border: 1px solid var(--line);
  background: var(--panel);
  color: inherit;
  border-radius: 6px;
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

#canvas { position: relative; flex: 1; overflow: hidden; }
#graph { width: 100%; height: 100%; display: block; cursor: grab; }
#graph.dragging { cursor: grabbing; }

#status { margin: 0; padding: 8px 20px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }

/* --- graph --- */
.node rect { stroke-width: 1; }
.node.product rect { fill: var(--product); stroke: var(--product-edge); }
.node.process rect { fill: var(--process); stroke: var(--process-edge); }
.node.dish rect { fill: var(--dish); stroke: var(--dish-edge); stroke-width: 2; }

.node .title { font-size: 12.5px; font-weight: 600; fill: var(--ink); }
.node .metaline { font-size: 10.5px; fill: var(--muted); }
.node.process .title { font-variant: small-caps; letter-spacing: .03em; }

.edge { fill: none; stroke: var(--product-edge); stroke-width: 1.4; }
.edge.optional { stroke-dasharray: 4 3; }
.edgelabel { font-size: 10px; fill: var(--muted); }
.edgelabel-bg { fill: var(--bg); }

@media (max-width: 700px) {
  body { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; height: auto; }
  aside { border-right: none; border-bottom: 1px solid var(--line); max-height: 40vh; }
  #canvas { height: 60vh; }
}

/* --- header controls --- */
.controls { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }

.views { display: flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.views button {
  border: none;
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  padding: 5px 13px;
  cursor: pointer;
}
.views button[aria-selected="true"] { background: var(--dish); color: var(--ink); font-weight: 600; }

.scale { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.scale input {
  width: 62px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: inherit;
  font: inherit;
  font-size: 12px;
}
.scale .step {
  width: 22px; height: 22px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: inherit;
  font: inherit;
  line-height: 1;
  cursor: pointer;
}
.scale .step:hover { background: var(--dish); color: var(--ink); }
.scale input { text-align: center; }

#yield { color: var(--ink); }

#theme {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  padding: 4px 6px;
}

/* --- the views --- */
#panes { display: flex; flex-direction: column; flex: 1; min-height: 0; }
/* Editing: the fields on the left, the recipe they make on the right, each
   scrolling on its own. The recipe is the preview's own rendering, so an edit
   shows up there as soon as the server has compiled it. */
#panes.split { flex-direction: row; }
#panes.split > #edit { flex: 1.25; min-width: 0; }
#panes.split > #recipe { flex: 1; min-width: 0; border-left: 1px solid var(--line); }
#panes.split #recipe .columns { grid-template-columns: 1fr; }
@media (max-width: 1099px) {
  #panes.split > #recipe { display: none; }
}

/* --- recipe view --- */
#recipe {
  flex: 1;
  overflow-y: auto;
  padding: 22px 26px 40px;
  /* The method's measurements, but held one level up: the timer gutter is
     where the method's column starts, and the servings control above it has to
     line up with that column rather than with the gutter beside it. */
  --gutter: 72px; --marker: 24px; --icon: 23px;
}
#recipe .columns { display: grid; grid-template-columns: 2fr minmax(230px, 1fr); gap: 34px; align-items: start; }
/* Ingredients sit in the right-hand column, but stay first when the columns
   stack, where reading them before the method is the natural order. */
#recipe .columns > .sidebar { order: 2; }
/* On the left, where the reading starts: how many this makes is the first thing
   to settle. Indented by the timer gutter, so it starts where the method's
   headings and step numbers do rather than out in the margin the countdowns
   hang in. */
#recipe > .scale {
  justify-content: flex-start;
  margin: 0 0 16px var(--gutter);
}

#recipe h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
#recipe .equipment { margin-top: 26px; }
#recipe .equipment p { margin: 0; }

/* Per-serving nutrition: a label/figure pair per row, so the numbers line up
   as a column the eye can run down without reading the labels again. */
#recipe .nutrition { margin-top: 26px; }
#recipe .nutrition ul { list-style: none; margin: 0; padding: 0; }
#recipe .nutrition li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
}
#recipe .nutrition .qty { font-variant-numeric: tabular-nums; color: var(--ink); }
/* The micronutrients are a second block under the macros, and their heading
   sits lighter than the panel's own — it divides one panel rather than starting
   a new section, the same as a shopping category over the ingredients. */
#recipe h4.micros {
  margin: 16px 0 4px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}

/* Each row is name / amount / bar / share of a day, so 17 of them can be
   scanned rather than read. The bar sits in a column of its own, between the
   two numbers it restates: drawn along the row's edge instead, it reads as an
   underline of one row and a rule above the next. It's a single recessive
   fill, and every figure it stands for is written out beside it, so nothing is
   carried by colour alone. */
/* A notch down from the macros above: seventeen rows of secondary detail
   shouldn't weigh more than the five figures they qualify. */
#recipe .micronutrients { font-size: 12.5px; }
#recipe .micronutrients li {
  display: grid;
  /* Fixed tracks for everything but the name: an auto column sized to its own
     row would step the bars in and out down the panel, and a column of bars
     that doesn't start at one x is no faster to read than the numbers. */
  grid-template-columns: 1fr 62px 46px 46px;
  gap: 10px;
  align-items: center;
  padding: 3px 0;
}
#recipe .micronutrients .amount {
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
/* The empty part of the track stays visible, so a small share reads as a small
   share of something rather than as a stray dash. */
#recipe .micronutrients .meter {
  height: 3px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}
#recipe .micronutrients .meter > span {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--meter);
}
/* Wide enough for "≥ 203%" on one line: the widest reading in the recipes
   wrapping onto two is what a fixed column costs if it's guessed short. */
#recipe .micronutrients .qty {
  text-align: right;
  white-space: nowrap;
}

/* What had to be assumed. Plainly subordinate to the figures above it — the
   same relationship a step's `detail` has to the step. */
#recipe .nutrition .caveats {
  margin-top: 10px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
}
#recipe .nutrition .caveats li { display: list-item; padding: 0 0 4px; }

/* Group labels sit lighter than the "Ingredients" heading above them — they
   divide one list, they don't start a new section. */
#recipe h4.category, .shopping h4.category {
  margin: 16px 0 5px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}
#recipe h4.category:first-of-type, .shopping h4.category:first-of-type { margin-top: 0; }

.ingredients { list-style: none; margin: 0; padding: 0; }
.ingredients li { display: grid; grid-template-columns: auto 5.5em 1fr; gap: 10px; padding: 3px 0; }
.ingredients .qty { color: var(--accent); font-variant-numeric: tabular-nums; text-align: right; }

/* The picture of the ingredient, at the size a list can carry one: enough to
   recognise garlic at a glance down the column, not enough to look at. It's a
   fixed circle whether or not there's a photograph behind it, so the names
   stay in one line and a half-photographed list doesn't look ragged. */
.thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  object-fit: cover;
  align-self: center;
  background: var(--bg);
  border: 1px solid var(--line);
  flex: none;
}
.thumb.empty { background: var(--bg); }
/* A framed picture zooms, and a scaled <img> would scale its own circle with
   it, so the circle is a span that clips and the picture is inside it. */
.thumb.framed { display: block; overflow: hidden; }
.thumb.framed img, .photos .frame img {
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
  border: 0; border-radius: 0;
}
.note { color: var(--muted); font-size: 12px; font-style: normal; }

/* Timers sit in a gutter of their own, outside the prose; the list's own left
   padding is that gutter plus the space the step numbers take, and the method's
   headings clear the gutter too, so the column starts at the numbers. Both are
   px, not em: the chip that reads them sets its own smaller font size, and an
   em there would mean something different from an em here. */
.method {
  /* Wide enough for "until fragrant but not coloured" in two or three lines,
     narrow enough that it reads as a margin rather than a second column of
     instructions. */
  --aside: 23ch;
  --aside-gap: 22px;
  /* The aside appears when the method has room for it, which is a question
     about this column and not about the window: the ingredients panel beside
     it takes a share of the width that the viewport can't be asked about. */
  container: method / inline-size;
}
/* Indented by margin, not padding, so the heading's rule starts where its text
   does instead of running back across the gutter. */
#recipe .method h3 { margin-left: var(--gutter); }
/* A dish written as text: the prose under the same heading indent, line breaks
   kept, since what's written is often a list of things on lines of their own. */
.method.freetext > p {
  margin-left: var(--gutter);
  max-width: 62ch;
  white-space: pre-line;
}
.steps {
  margin: 0;
  padding-left: calc(var(--gutter) + var(--marker));
  max-width: calc(62ch + var(--gutter) + var(--marker));
}
/* The glyph gets a column of its own by hanging indent, so everything in a step
   starts at one left edge: the first line of the sentence, the lines it wraps
   onto, the phase lines and the note. `--icon` is the glyph's 16px plus the gap
   after it. Block children reset the indent, which only the first line wants. */
.steps > li {
  position: relative;
  margin-bottom: 13px;
  padding-left: calc(5px + var(--icon));
  line-height: 1.55;
}
/* Only the step's own sentence hangs: a phase line has no glyph to hang. */
.steps > li > .row > .says { text-indent: calc(-1 * var(--icon)); }
.steps > li::marker { color: var(--muted); font-size: 12px; }
.chip {
  display: inline-block;
  margin-left: 7px;
  /* The step's hanging indent is inherited, and inside an inline-block it
     pulls the chip's own first line out through its left border. */
  text-indent: 0;
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 20px;
  font: 11px/1.5 system-ui, sans-serif;
  font-variant: normal;
  letter-spacing: 0;
  color: var(--muted);
  vertical-align: 2px;
}
.chip.warn { border-color: var(--dish-edge); color: var(--accent); }


.unresolved .qty { color: var(--accent); }
.steps > li.unresolved { color: var(--accent); }

/* A step's glyph: the kit it needs, or the verb where it needs none. It leads
   the sentence rather than sitting in the timer's gutter, so a timed step
   doesn't have to choose between the two, and it's muted enough to scan past
   when reading the prose straight through. */
.icon {
  margin-right: 7px;
  vertical-align: -3px;
  color: var(--muted);
}
.steps > li.unresolved .icon { color: var(--accent); }

/* --- sub-steps and notes ---

   What goes into a step part-way through is its own instruction, so it gets its
   own line rather than trailing off the end of the sentence. The indent is all
   it needs to read as part of the step above: each line opens with "Then", so a
   bullet or a rule in the margin would only repeat that. */
.additions {
  margin: 9px 0 0;
  padding-left: 0;
  list-style: none;
}
/* Each phase line carries its own countdown, in the same gutter as the step's.
   The line is its own positioning context so the chip lands beside it, and the
   offset backs out the indent the step's own text column adds. */
.additions > li { position: relative; line-height: 1.5; }
/* Each phase line carries a timer in the gutter, and two chips a line-height
   apart touch — so the phases are spaced by the thing in the margin rather
   than by the prose, which would sit closer if it were on its own. */
.additions > li + li { margin-top: 11px; }
.additions > li > .chip.timer {
  left: calc(-1 * (var(--gutter) + var(--marker) + 5px + var(--icon)));
}

/* `detail` is the recipe's own aside, not something assembled from the graph —
   "off heat", "stir occasionally", "until smooth" — so it's set in a lighter
   colour, readable but plainly not part of the instruction. Under its step
   when that's all there's room for, and beside it when there's more: an aside
   in the flow is one more thing to step over on the way to the next
   instruction, and the method is meant to be read straight down. */
.detail {
  margin: 5px 0 0;
  font-size: 13px;
  color: var(--muted);
}
@container method (min-width: 700px) {
  .steps { max-width: calc(62ch + var(--gutter) + var(--marker) + var(--aside) + var(--aside-gap)); }
  .row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--aside);
    column-gap: var(--aside-gap);
    /* The first lines of the two sit on one line, however many lines each of
       them runs to. */
    align-items: baseline;
  }
  .row > .detail { margin-top: 0; line-height: 1.45; }
}
.steps > li.unresolved .detail { color: var(--accent); opacity: 0.75; }

.warnings { margin-top: 30px; font-size: 12px; color: var(--muted); }
.warnings ul { margin: 0; padding-left: 1.2em; }

@media (max-width: 860px) {
  #recipe .columns { grid-template-columns: 1fr; gap: 26px; }
  #recipe .columns > .sidebar { order: 0; }
}

/* The "Method" heading follows the prep list rather than opening the column. */
#recipe h3.after-list { margin-top: 26px; }

/* A step's countdown: a clickable chip pulled out of the flow into the gutter
   the list reserves at its left, so the timers read as a column and the prose
   stays unbroken. Tabular figures keep it from twitching as the digits change. */
.chip.timer {
  position: absolute;
  left: calc(-1 * (var(--gutter) + var(--marker)));
  /* Sits on the step's first line rather than the top of the block. */
  top: 2px;
  width: calc(var(--gutter) - 12px);
  margin: 0;
  padding: 2px 0;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  background: var(--bg);
}
.chip.timer:hover { border-color: var(--dish-edge); color: var(--ink); }
.chip.timer.running { border-color: var(--accent); color: var(--accent); }
.chip.timer.done {
  border-color: var(--accent);
  background: var(--dish);
  color: var(--accent);
  animation: timer-done 1s ease-in-out 3;
}
@keyframes timer-done { 50% { opacity: 0.35; } }

@media (prefers-reduced-motion: reduce) {
  .chip.timer.done { animation: none; }
}

/* --- selected product ---

   A Product is one node shared by every step that touches it, so selecting a
   name is a way of asking "where does this go?". The mention itself takes the
   accent; the steps and the ingredient row containing one take a quieter bar,
   which is the same thing as its upstream and downstream steps — the step that
   makes it, and the ones that use it. */
.product {
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: none;
  border: 0;
  border-radius: 4px;
  padding: 0 1px;
  margin: 0 -1px;
  cursor: pointer;
  text-align: left;
}
.product:hover { box-shadow: inset 0 -1px 0 var(--product-edge); }
.product:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.product.selected {
  color: var(--accent);
  background: var(--dish);
  box-shadow: 0 0 0 1px var(--dish-edge);
}

/* Bars, not backgrounds: the rows they mark are already carrying prose, and a
   tint behind a step would fight the accent on the name inside it. */
.steps > li::before, .ingredients li::before {
  content: "";
  position: absolute;
  top: 2px;
  bottom: 2px;
  width: 2px;
  border-radius: 1px;
  background: var(--accent);
  opacity: 0;
  transition: opacity .12s ease-out;
}
.steps > li.touches::before, .ingredients li.touches::before { opacity: .85; }
/* Clear of the step number, not wedged between it and the prose: the bar
   belongs to the whole item, so it sits at the left edge of the marker column,
   in the gap the timer gutter already leaves. */
.steps > li::before { left: calc(-1 * var(--marker) - 6px); }
.ingredients li { position: relative; }
.ingredients li::before { left: -11px; }
.ingredients li.touches .qty { color: var(--accent); font-weight: 600; }

/* The way to the ingredient's own page: there on hover or focus, and holding
   its place otherwise so the row doesn't reflow as the pointer crosses it. */
.ingredient-link {
  display: inline-flex;
  vertical-align: -2px;
  margin-left: 4px;
  color: var(--muted);
  opacity: 0;
  transition: opacity .12s ease-out;
}
.ingredient-link .icon { width: 13px; height: 13px; }
.ingredients li:hover .ingredient-link, .ingredient-link:focus-visible { opacity: 1; }
.ingredient-link:hover { color: var(--accent); }
@media (hover: none) { .ingredient-link { opacity: .6; } }

/* The unresolved step already paints its prose in the accent; keep its product
   names distinguishable from the rest of the sentence there. */
.steps > li.unresolved .product { color: var(--accent); }

.node.selectable { cursor: pointer; }
.node.selected rect { stroke: var(--accent); stroke-width: 2.5; }
.node.selected .title { fill: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .steps > li::before, .ingredients li::before { transition: none; }
}

/* --- the ingredients page -------------------------------------------------- */

/* The table scrolls under a header that doesn't, and the detail panel stays put
   beside it: reading a row against the column it sorted by is the whole
   interaction, and both halves have to stay on screen for it. */
#page { flex: 1; overflow: hidden; padding: 18px 20px; min-height: 0; }
#page .columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 28px;
  height: 100%;
  min-height: 0;
}
/* Each half keeps a gutter for its scrollbar, so the bar never sits on a
   column of figures and nothing shifts when one appears. */
#page .table { overflow: auto; min-width: 0; scrollbar-gutter: stable; }
#page .detail {
  overflow-y: auto;
  scrollbar-gutter: stable;
  border-left: 1px solid var(--line);
  padding: 0 8px 0 22px;
}

/* Too narrow to read a row against a panel beside it, so the panel goes under
   the table and the divider turns with it. */
@media (max-width: 700px) {
  #page { overflow: visible; }
  #page .columns { grid-template-columns: minmax(0, 1fr); height: auto; gap: 18px; }
  #page .detail { border-left: none; border-top: 1px solid var(--line); padding-left: 0; padding-top: 18px; }
}

#page table { border-collapse: collapse; width: 100%; font-size: 13px; }

/* The head stays visible while the body scrolls — a column of numbers with the
   heading scrolled off is a column of numbers about nothing. */
#page thead th {
  position: sticky;
  top: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 0;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  z-index: 1;
}
#page thead th button {
  width: 100%;
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  text-align: inherit;
  padding: 7px 8px;
  cursor: pointer;
}
#page thead th button:hover { color: var(--ink); }
#page thead th[aria-sort="none"] button { color: var(--muted); }
#page thead th:not([aria-sort="none"]) button { color: var(--ink); }

#page tbody td { padding: 5px 8px; border-bottom: 1px solid var(--line); }
/* The last column keeps clear of the scrollbar beside it. */
#page tbody td:last-child, #page thead th:last-child button { padding-right: 12px; }
#page td.num, #page th.num { text-align: right; font-variant-numeric: tabular-nums; }
#page td.cat { color: var(--muted); font-size: 12px; }
#page tbody tr:hover td { background: var(--panel); }
#page tbody tr.selected td { background: var(--dish); }

#page td.name button {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
#page td.name button:hover { color: var(--accent); }
/* The hover underline is the name's, not the picture's beside it. */
#page td.name .product:hover { box-shadow: none; }
#page td.name .product:hover .label { box-shadow: inset 0 -1px 0 var(--product-edge); }

/* The detail panel reuses the dish panel's rows outright: same label/figure
   pairs, same meter, same reference intakes — only the basis differs, and the
   heading says which. */
#page .nutrition h3 { margin: 0 0 2px; font-size: 15px; }
#page .nutrition .sub { margin: 0 0 6px; color: var(--muted); font-size: 12px; }
#page .nutrition ul { list-style: none; margin: 0; padding: 0; }
#page .nutrition .macros li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
}
#page .nutrition .qty { font-variant-numeric: tabular-nums; color: var(--ink); }
#page h4.micros {
  margin: 16px 0 4px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}
#page .micronutrients { font-size: 12.5px; }
#page .micronutrients li {
  display: grid;
  grid-template-columns: 1fr 74px 46px 40px;
  gap: 10px;
  align-items: center;
  padding: 3px 0;
}
#page .micronutrients .amount {
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
#page .micronutrients .meter {
  height: 3px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}
#page .micronutrients .meter > span {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--meter);
}
#page .micronutrients .qty { text-align: right; white-space: nowrap; }
/* An unmeasured row keeps its place and loses its weight: it's absent, not
   zero, and a row missing from the list entirely would read as neither. */
#page .micronutrients li.absent { color: var(--muted); }
#page .micronutrients li.absent .amount { font-style: italic; }

#page .dishes li { padding: 2px 0; font-size: 12.5px; }
#page .dishes a { color: var(--accent); text-decoration: none; }
#page .dishes a:hover { text-decoration: underline; }

/* The form for what this clone knows about an ingredient: small, under the
   figures it changes, a label over each box. */
#page .edit-facts { margin-top: 14px; }
#page .edit-facts .fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; margin: 6px 0 10px; }
#page .edit-facts label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); }
#page .edit-facts input, #page .edit-facts select {
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink);
  font: inherit; font-size: 12.5px; padding: 4px 7px; min-width: 0;
}
#page .edit-facts .status:empty { display: none; }

/* Choosing an ingredient's picture: a search, a grid of what came back, and
   the one picked with a box to say what's in it. Under the picture it
   replaces, so the old and the candidates are read together. */
#page .picture-do { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 14px; }
/* Tucked up under a picture, which keeps a gap below itself for the figures. */
#page .photos + .picture-do { margin-top: -8px; }
#page .picker .picture-do { margin: 8px 0 0; }
#page .picture-do button:not(.primary), #page .picture-search button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: inherit;
  border-radius: 6px;
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
#page .picture-do button:hover, #page .picture-search button:hover { border-color: var(--dish-edge); }
#page .picture-do .status:empty, #page .picker .status:empty { display: none; }
#page .photos + .picker { margin-top: -8px; }
#page .picker {
  margin: 10px 0 16px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
#page .picture-search { display: flex; gap: 6px; }
#page .picture-search input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  padding: 4px 7px;
}
#page .picker .status { margin: 6px 0 0; }
#page .picture-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 6px;
  margin-top: 8px;
}
#page .picture-result {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  font: inherit;
  font-size: 10.5px;
  cursor: pointer;
  overflow: hidden;
}
#page .picture-result:hover, #page .picture-result:focus-visible { border-color: var(--accent); }
#page .picture-result img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--product); }
#page .picture-result span { padding: 0 5px 3px; text-align: left; }
#page .picture-chosen { margin-top: 8px; }
#page .picture-chosen img {
  display: block;
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--product);
}
#page .picture-chosen a { color: var(--accent); }
/* On the Add form the picture sits between the name and the figures, so it
   keeps the gap a section would rather than tucking under a heading. */
#page .adding-picture { margin: 10px 0 14px; }
#page .adding-picture .picture-do { margin: 8px 0 0; }
#page .adding-picture .picker { margin: 0; }

/* Framing an ingredient's picture: the picture in the list's circle, large
   enough to drag, with the circle at the list's own size beside it. The
   surface takes every touch, so a drag on a phone moves the picture rather
   than the page. */
#page .framer { margin: 0 0 14px; }
#page .framer-stage { display: flex; align-items: flex-end; gap: 12px; }
#page .framer-surface {
  width: min(220px, 100%);
  aspect-ratio: 1;
  flex: 0 1 auto;
  overflow: hidden;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
#page .framer-surface:active { cursor: grabbing; }
#page .framer-surface:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#page .framer-surface img {
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
  pointer-events: none;
}
#page .framer-preview { flex: none; }
#page .framer-zoom { display: flex; align-items: center; gap: 8px; max-width: 280px; margin-top: 10px; font-size: 12px; color: var(--muted); }
#page .framer-zoom input { flex: 1; min-width: 0; accent-color: var(--accent); }
#page .framer .picture-do { margin: 8px 0 0; }
#page .framer .status:empty { display: none; }

#page .caveats {
  margin-top: 14px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
}
#page .caveats li { padding: 0 0 4px; }
#page .caveats a { color: var(--accent); }

#page .empty { color: var(--muted); font-size: 12.5px; }

@media (max-width: 900px) {
  #page .columns { grid-template-columns: 1fr; height: auto; }
  #page { overflow: auto; }
  #page .detail { border-left: none; border-top: 1px solid var(--line); padding: 18px 0 0; }
}

/* --- pictures -------------------------------------------------------------- */

/* A Product's photos. The file is fetched rather than committed, so a picture
   the graph knows about may not be on this disk — which is a state to draw,
   not an error to hide. */
.photos { margin: 0 0 18px; }
.photos figure { margin: 0 0 10px; }
.photos img {
  display: block;
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
}
/* An ingredient's picture, framed: square, so it shows what the list's circle
   does with the corners left on (images.mjs). Capped, since a square the width
   of a panel is a picture taller than the figures it's there to introduce. */
.photos .frame {
  overflow: hidden;
  aspect-ratio: 1;
  max-width: 280px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
}
/* Not a broken image: it hasn't failed, it hasn't been fetched. It holds the
   space the picture will take and names what it would show. */
.photos .unfetched {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  min-height: 92px;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
}
.photos .unfetched .hint { font-size: 11px; opacity: .8; }

/* Whose picture it is. Somebody else's, under a licence that asks to be named,
   so the line is part of showing it rather than a detail beside it — small,
   but never absent where the graph has one. */
.photos .credit { margin: 4px 0 0; font-size: 11px; color: var(--muted); }
.photos .credit a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* In the recipe sidebar the photo leads the column, so it sits flush with the
   ingredients heading under it rather than floating in its own margin. */
#recipe .dish-photo { margin-top: 2px; }

/* --- adding a recipe ------------------------------------------------------ */

/* The one button on the page that starts something rather than filtering or
   switching between things, so it's the one that doesn't look like a chip. */
button.primary {
  border: 1px solid var(--dish-edge);
  background: var(--dish);
  color: var(--ink);
  border-radius: 6px;
  padding: 5px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
button.primary:hover { border-color: var(--accent); }
button.primary:disabled { opacity: .5; cursor: default; }

#add-dialog, #sign-in {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  padding: 22px 24px;
  width: min(520px, calc(100vw - 32px));
}
#add-dialog::backdrop, #sign-in::backdrop { background: rgb(0 0 0 / .45); }
#add-dialog h2, #sign-in h2 { margin: 0 0 12px; font-size: 16px; }
#add-dialog .views { margin-bottom: 12px; align-self: start; width: fit-content; }
#add-dialog .hint { margin: 0 0 16px; }
#add-dialog #add-status:not(:empty) { margin: 14px 0 0; color: var(--accent); }
#sign-in { width: min(360px, calc(100vw - 32px)); }
#sign-in .hint:not(:empty) { color: var(--accent); margin: 0; }
.dialog-do { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.hint { font-size: 12px; color: var(--muted); line-height: 1.5; }

.field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.field textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  padding: 8px;
  /* A recipe is pasted in whole, so the box is sized for one and grows down
     rather than sideways — a wrapped method in a two-line field is unreadable
     the moment you want to check it. */
  resize: vertical;
  min-height: 120px;
  line-height: 1.5;
}
.field textarea:focus { outline: 1px solid var(--accent); outline-offset: -1px; }

/* The photos as picked, so the wrong one — or the right ones in the wrong
   order — is caught before minutes are spent reading it. */
.photo-list { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; padding: 0; }
.photo-list:empty { display: none; }
.photo-list img { display: block; height: 72px; width: auto; max-width: 120px; object-fit: cover; border: 1px solid var(--line); border-radius: 4px; }

.field input, .field select {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  padding: 5px 8px;
}

/* The draft bar: what this is, and the two things you can do with it. It sits
   between the header and the views, so it's above whichever view is showing —
   a draft is a state of the whole page, not of one tab. */
#draftbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 9px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--dish);
  font-size: 12px;
}
.draft-what { display: flex; align-items: baseline; gap: 10px; }
.draft-what strong { font-size: 12.5px; }
#draft-note { color: var(--muted); }
.draft-do { display: flex; gap: 8px; }
.draft-do button:not(.primary), .job-do button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: inherit;
  border-radius: 6px;
  padding: 5px 12px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

/* The only irreversible button in the viewer, and the only one that says so. */
.draft-do button.danger {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--accent);
  border-radius: 6px;
  padding: 5px 12px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.draft-do button.danger:hover { border-color: var(--accent); }
.job-do button:hover { border-color: var(--dish-edge); }
.job-do button:disabled { opacity: .5; cursor: default; }
.draft-do button.danger:disabled, .draft-do button:not(.primary):disabled { opacity: .5; cursor: default; }

#draft-problems { padding: 12px 20px 0; display: flex; gap: 24px; flex-wrap: wrap; }
.notice { font-size: 12px; max-width: 46em; }
.notice ul { margin: 4px 0 0; padding-left: 1.2em; }
.notice li { margin-bottom: 2px; }
.notice.bad strong { color: var(--accent); }
.notice.warn { color: var(--muted); }

/* --- the source ----------------------------------------------------------- */

#source { flex: 1; overflow-y: auto; padding: 20px 24px 44px; }
.source-head {
  display: flex;
  align-items: baseline;
  gap: 8px 16px;
  flex-wrap: wrap;
  font-size: 12px;
}
.source-head a { color: var(--accent); overflow-wrap: anywhere; }
.source-head .when { color: var(--muted); }
#source .hint { margin: 6px 0 16px; }

/* The photographs a recipe was read from, above what was read off them: big
   enough to tell what's on the page, and a click away from reading it. */
.source-photos { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 16px; }
.source-photos a { display: block; flex: 0 1 260px; }
.source-photos img {
  display: block;
  width: 100%;
  max-height: 340px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
}

/* The page's words, kept as words. Wrapped rather than scrolled sideways, since
   what was stored is prose with the markup already thrown away. */
.source-text {
  margin: 0;
  max-width: 76ch;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  font: inherit;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* --- the editor ----------------------------------------------------------- */

#edit { flex: 1; overflow-y: auto; padding: 20px 24px 44px; }
.editor { max-width: 1000px; }
.editor fieldset {
  /* A fieldset is as wide as its content by default, and a step's summary
     line never wraps. */
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px 16px 16px;
  margin: 0 0 18px;
}
.editor legend { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 5px; }
.editor .hint { margin: 0 0 12px; }
.editor .rows { display: flex; flex-direction: column; gap: 6px; }
.editor .row { display: flex; align-items: center; gap: 6px; }
.editor .row.wrap { flex-wrap: wrap; gap: 6px 14px; }
.editor .field { margin-bottom: 0; }

.editor input[type="text"], .editor input[type="number"], .editor select, .editor textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  padding: 4px 7px;
  min-width: 0;
}
.editor textarea { width: 100%; resize: vertical; line-height: 1.5; }
.editor .grow { flex: 1; min-width: 7em; }
.editor .narrow { width: 5.5em; flex: none; }
.editor .narrow-wide { width: 9em; flex: none; }

.editor .tick { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.editor .ticks { display: flex; align-items: center; gap: 4px 12px; flex-wrap: wrap; }
/* The ingredient rows are one table: the name, and Remove at the right edge.
   A 1fr that ignores content, so a long name can't move one row's Remove off
   the others'. */
.editor .row.ingredient {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 4.5em;
  align-items: center;
  gap: 8px;
}
.editor .row.ingredient > :first-child { min-width: 0; }

/* The ingredient picker: the chosen one's thumbnail, the box, and a list that
   drops over the rows below rather than pushing them down. The list is as wide
   as the box's row, which at phone width is the screen less its gutter. */
.ingredient-picker { position: relative; display: flex; align-items: center; gap: 8px; min-width: 0; }
.ingredient-picker input[role="combobox"] { flex: 1; width: 100%; }
.ingredient-picker .picker-list {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0;
  padding: 4px;
  list-style: none;
  max-height: min(18rem, 50vh);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
}
.ingredient-picker .picker-list[hidden] { display: none; }
.ingredient-picker [role="option"] {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border-radius: 5px;
  font-size: 12.5px;
  cursor: pointer;
}
.ingredient-picker [role="option"] .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ingredient-picker [role="option"]:hover { background: var(--bg); }
.ingredient-picker [role="option"][aria-selected="true"] { background: var(--product); color: var(--ink); }
.ingredient-picker [role="option"].create { color: var(--accent); }
.ingredient-picker .empty-list { padding: 5px 7px; font-size: 12px; color: var(--muted); }
@media (hover: none) {
  /* A finger needs a bigger target than a pointer does. */
  .ingredient-picker [role="option"] { padding: 9px 8px; }
}

.editor .rowlabel { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); width: 4.5em; flex: none; }

.editor button.add, .editor button.remove {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: 6px;
  padding: 3px 9px;
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
  flex: none;
}
.editor button.add { margin-top: 8px; }
.editor button.add:hover, .editor button.remove:hover { color: var(--ink); border-color: var(--dish-edge); }
.editor button.remove.wide { margin-top: 10px; }

/* The dish's own fields: two to a row, the long ones across both. */
.editor .grid-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.editor .grid-fields .field.wide { grid-column: 1 / -1; }
.editor .grid-fields .field input { width: 100%; }

/* What a key or a slug is folded under: there for whoever goes looking. */
.editor details.advanced { margin-top: 10px; }
.editor details.advanced > summary {
  font-size: 11px; color: var(--muted); cursor: pointer; width: max-content;
  list-style-position: inside;
}
.editor details.advanced[open] > summary { margin-bottom: 6px; }

.editor button.quiet {
  border: none; background: none; color: var(--muted); font: inherit; font-size: 11.5px;
  padding: 2px 4px; cursor: pointer; white-space: nowrap; flex: none;
}
.editor button.quiet:hover { color: var(--ink); text-decoration: underline; }

.editor .steps-head { justify-content: space-between; align-items: baseline; gap: 12px; }
.editor .steps-head .hint { margin-bottom: 10px; }

/* A step is a card that closes to the line the method would say. Closed, a
   recipe's steps read as a list; open, one of them is a form. */
.editor .step-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
}
.editor .step-card[open] { padding-bottom: 12px; border-color: var(--product-edge); }
.editor .step-card > :not(summary) { margin-left: 14px; margin-right: 14px; }
.editor .step-card > summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  min-width: 0;
}
.editor .step-card > summary::-webkit-details-marker { display: none; }
.editor .step-card[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.editor .step-card .num {
  flex: none; min-width: 1.6em; height: 1.6em; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: var(--process); color: var(--ink); font-size: 11px; font-weight: 600;
}
.editor .step-card .verb { flex: none; font-weight: 600; }
.editor .step-card .what { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.editor .step-card .arrow { color: var(--muted); }
.editor .step-card .extras { flex: none; font-size: 11.5px; color: var(--muted); }
.editor .step-card .trouble {
  flex: none; font-size: 11px; color: var(--accent); border: 1px solid var(--accent);
  border-radius: 999px; padding: 0 7px;
}

/* Where a problem is, as the preview reported it. */
.editor .has-problem { border-color: var(--accent); box-shadow: -3px 0 0 var(--accent); }

/* Everything in a card hangs off one left edge: the fields, the kit, and both
   lists. The section labels sit above their rows rather than beside them. */
.editor .refs { display: flex; flex-direction: column; gap: 5px; margin-top: 12px; }
.editor .refs > .rowlabel { width: auto; }
.editor .refs .add { align-self: flex-start; margin-top: 2px; }
.editor .vessels { margin-top: 10px; }
.editor .vessels .rowlabel { width: auto; margin-right: 2px; }
.editor .vessels select.adder { font-size: 11.5px; padding: 2px 5px; color: var(--muted); }
.editor .step-acts { margin-top: 12px; justify-content: space-between; }
.editor .step-acts .add { margin-top: 0; }

/* Each list is its own table: the same columns down it, so an amount sits
   under an amount however long the product's name is. Takes above Makes, as a
   before and after: a name needs the width more than the two lists need to be
   side by side. */
.editor .refs .row.ref {
  display: grid;
  /* Fixed tracks for the flags and the buttons, the same in both lists, so a
     Makes amount sits under a Takes amount though their flags differ. */
  grid-template-columns: minmax(8em, 1fr) 4.5em 6.5em 11em 7em;
  align-items: center;
  gap: 6px;
}
/* A grid item won't shrink below its own content otherwise, and a long
   product name would push the amounts off the card. */
.editor .refs .row.ref > * { min-width: 0; }
.editor .refs .row.ref > .flags { display: flex; align-items: center; gap: 8px; }
.editor .refs .row.ref > .acts { display: flex; align-items: center; gap: 4px; justify-content: end; }
.editor .refs .row.ref .ingredient-picker .thumb { display: none; }
.editor .refs .row.ref-output.dish input.makes { font-weight: 600; }
.editor .badge-dish {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--dish-edge); border: 1px solid var(--dish-edge); border-radius: 999px; padding: 0 7px;
}
.editor input.clash { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.ingredient-picker [role="option"] .note { margin-left: auto; flex: none; font-size: 11px; color: var(--muted); }

.editor .product-row .rowlabel { width: auto; text-transform: none; letter-spacing: 0; font-size: 11.5px; }
.editor .hint.inline { margin: 0; font-size: 11.5px; white-space: nowrap; }

/* The field row: labels above their controls, so the controls sit on one line
   whichever of them this verb turned out to need. A field whose control was
   asked to grow grows with it, rather than the input stretching inside a
   wrapper the width of its own label. */
.editor .row.fields { align-items: end; }
.editor .row.fields > .field:has(.grow) { flex: 1; min-width: 11em; }

@media (max-width: 720px) {
  .editor .row { flex-wrap: wrap; }
  .editor .grid-fields { grid-template-columns: 1fr; }
  /* The five columns stop being a table long before this, so the row goes back
     to a line that wraps. */
  .editor .refs .row.ref { display: flex; flex-wrap: wrap; }
  .editor .refs .row.ref > :first-child { flex: 1 1 100%; }
  .editor .step-card .extras { display: none; }
}

/* --- the plan --------------------------------------------------------------

   A fortnight of days down the page, each with its slots across. It's a table
   of two columns and could be one, but the cells hold controls rather than
   values and the whole thing folds to a single column on a phone — which a
   table does badly and a grid does by changing one line. */

#plan { overflow-y: auto; display: flex; flex-direction: column; min-height: 0; }
#plan > header #today {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: 7px;
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
#plan > header #today:hover { color: var(--ink); border-color: var(--dish-edge); }

/* The grid and its consequence, side by side. The list is narrow on purpose —
   it's a column of names and amounts, and it reads like the one in a recipe
   because it is the same list, added up. */
.planning {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  gap: 28px;
  align-items: start;
  padding: 4px 20px 20px;
}

/* The days, and a marker at each end of them. The markers have no height of
   their own to speak of — they exist to be seen scrolling into view, which is
   what asks the page for another week that way — and the scroll they are
   watched against is #plan's, the only thing on this page that scrolls. */
.stream { min-width: 0; }
.edge { height: 1px; }
.fortnight { display: flex; flex-direction: column; gap: 6px; }

/* Sticky, because the grid is fourteen days long and the list is what you're
   holding while you scroll it. */
.shopping {
  position: sticky;
  top: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 14px 16px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}
.shopping h3 { margin: 0; font-size: 13px; }
.shopping .basis {
  margin: 3px 0 12px;
  font-size: 11.5px;
  color: var(--muted);
}
/* A box, the amount, the thing. The row is the hit target — see plan.mjs — so
   it takes the cursor a button would. */
/* How far the shop reaches — the grid can't say, since it's a window and the
   list isn't. */
.shopping .basis.covers { margin: -8px 0 12px; font-style: italic; }

.shopping .ingredients li {
  grid-template-columns: auto auto 5em 1fr;
  font-size: 13px;
  align-items: baseline;
  cursor: pointer;
  border-radius: 6px;
  padding: 3px 4px;
  margin: 0 -4px;
}
.shopping .ingredients li:hover { background: var(--bg); }
.shopping .tick { accent-color: var(--accent); margin: 0; cursor: pointer; }

/* Struck through and faded, but still in its place in the aisle: a list that
   reorders itself under a moving finger is worse than one that doesn't. */
.shopping li.got .what { text-decoration: line-through; }
.shopping li.got { color: var(--muted); }
.shopping li.got .qty { color: var(--muted); }

/* Sits in the summary line it qualifies, rather than being a control of its
   own: it only exists while something is ticked. */
.shopping .clear-ticks {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 11.5px;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}
/* Which meals a line is for: the question a combined list invites. It sits
   under the name in the muted size the notes use, since it qualifies the line
   rather than being part of it. */
.shopping .from { display: block; font-size: 11px; color: var(--muted); }
.shopping .unresolved .qty { color: var(--muted); }

.day {
  display: grid;
  grid-template-columns: 5.5em 1fr;
  gap: 12px;
  align-items: stretch;
  padding: 6px 0;
  border-top: 1px solid var(--line);
}
.day:first-child { border-top: none; }
/* Today is the day the plan is read on, so it's marked rather than merely
   first: the fortnight can be scrolled back over days already eaten, and the
   line between "cooked" and "to cook" is the one thing the grid has to say at a
   glance. */
.day[data-today] { position: relative; }
.day[data-today] .when .dow { color: var(--accent); font-weight: 600; }
/* A wash of the accent behind the whole row, laid on as a layer of its own for
   the reason a photo is: the veil is the layer's opacity, so neither palette
   has to name a blend of accent and panel. The row's own contents sit over it.
   The mark isn't left to the wash alone — the "Today" label below says it in
   words, for a narrow window, a colourblind eye, or a screen reader. */
.day[data-today]::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent);
  opacity: var(--today-veil);
  pointer-events: none;
  border-radius: 9px;
}
.day[data-today] > * { position: relative; z-index: 1; }
/* Small, and in the accent's own ink, so it reads as the row's label rather
   than as something planned in it. */
.day .when .istoday {
  margin-top: 3px;
  align-self: start;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--accent);
  border: 1px solid var(--dish-edge);
  border-radius: 999px;
  padding: 0 5px;
}
/* A day already eaten. It stays on the calendar — scrolling back over last week
   is half of why the scroll goes both ways — but it stops competing with the
   days still to cook.

   Faded rather than greyed out: the ink keeps its own colour and most of its
   contrast, so a past row is still readable at arm's length, and it's the
   photo and the panel that recede. The date column is left alone entirely —
   it's how you find your place scrolling back, and a dim column of dates is a
   calendar you have to squint at. Both palettes get the same treatment because
   both are stated in the same tokens; the numbers are chosen so the text stays
   above the contrast the rest of the muted ink on this page sits at. */
.day[data-past] .slots { opacity: .62; filter: saturate(.75); }
.day[data-past] .slot.shot { --shot-veil: .55; }
.day[data-past] .when .dow,
.day[data-past] .when .date { color: var(--muted); }

.when { display: flex; flex-direction: column; justify-content: center; line-height: 1.3; }
.when .dow { font-size: 13px; color: var(--ink); }
.when .date { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* One track per slot, without the count being written here: auto-fit lays down
   as many as fit and collapses the rest, so adding a slot to slots.mjs grows
   the grid a column and a narrow window folds it back on its own. */
.slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }

.slot {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  padding: 7px 10px;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* The dish's own photo, behind the meal planned on it. It's a layer of its own
   rather than the cell's background so the veil is the layer's opacity: a
   translucent overlay would have to know the panel colour, and there are two of
   those. Only where the file has actually been fetched — plan.mjs sets --shot
   or leaves the cell plain. */
.slot.shot::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--shot);
  background-size: cover;
  background-position: center;
  opacity: var(--shot-veil);
  pointer-events: none;
}
/* Everything the cell holds sits over it. */
.slot > * { position: relative; z-index: 1; }
.slot .slotname {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}
.slot.filled { background: var(--dish); border-color: var(--dish-edge); }

.meal { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.meal .what {
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  flex: 1;
  min-width: 8em;
}
.meal .what:hover { color: var(--accent); }
.meal .for { display: flex; align-items: center; gap: 4px; }
.meal .count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 1.2em; text-align: center; }
.meal .for .step:disabled { opacity: .35; cursor: default; }
/* The only destructive control on the page, and it isn't much: a meal put back
   is one click and the dish is still in the gallery. It stays quiet until the
   cell is hovered rather than sitting there red. */
.meal .clear {
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}
.meal .clear:hover { color: var(--accent); }

/* An empty cell is all button: there's nothing else in it to aim at. */
.slot .pick {
  flex: 1;
  border: 1px dashed var(--line);
  border-radius: 7px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  min-height: 28px;
}
.slot .pick:hover { border-color: var(--dish-edge); color: var(--ink); background: var(--bg); }

#pick-dialog {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  padding: 20px;
  width: min(440px, calc(100vw - 32px));
  font: inherit;
}
#pick-dialog::backdrop { background: rgb(0 0 0 / .45); }
#pick-dialog h2 { margin: 0 0 12px; font-size: 16px; }
#pick-dialog #pick-filter {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  padding: 6px 9px;
}
#pick-dialog ul { list-style: none; margin: 12px 0 0; padding: 0; max-height: 46vh; overflow-y: auto; }
#pick-dialog li + li { margin-top: 4px; }
#pick-dialog li button {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 7px;
  background: none;
  color: var(--ink);
  font: inherit;
  padding: 7px 9px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#pick-dialog li button:hover { background: var(--bg); border-color: var(--dish-edge); }
/* The dish's photo, behind its line, on the same terms the plan's cells and the
   gallery's rows take it: a layer of its own so the veil is that layer's
   opacity rather than an overlay that would have to know what colour it's over.
   Only where the file has been fetched — plan.mjs sets --shot or leaves the
   line plain, and a plain line is the button it always was. */
#pick-dialog li button.shot { position: relative; overflow: hidden; }
#pick-dialog li button.shot::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--shot);
  background-size: cover;
  background-position: center;
  opacity: var(--shot-veil);
  pointer-events: none;
}
/* Everything the line holds sits over it. */
#pick-dialog li button.shot > * { position: relative; z-index: 1; }
#pick-dialog .empty-list { padding: 8px 9px; color: var(--muted); }

/* The list stops being a margin and becomes the next thing down the page. It
   keeps its box but gives up the sticky, which has nothing to stick to once
   it's under a fortnight of days. */
@media (max-width: 860px) {
  .planning { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .shopping { position: static; max-height: none; }
}

@media (max-width: 640px) {
  /* Two slots side by side stop being readable well before this, and so does a
     date column beside them. */
  .day { grid-template-columns: 1fr; gap: 4px; }
  .when { flex-direction: row; gap: 6px; align-items: baseline; }
  .slots { grid-template-columns: 1fr; }
}

/* Adding an ingredient, and looking its figures up: the same small form as
   editing one, with a name above it and a list of FoodData Central records
   to pick from. */
.controls #add { white-space: nowrap; }
#page .new-name { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); margin: 6px 0 4px; }
#page .new-name input, #page .lookup-search input {
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink);
  font: inherit; font-size: 12.5px; padding: 4px 7px; min-width: 0;
}
#page .lookup { margin: 6px 0 4px; }
#page .edit-facts .save-row { display: flex; gap: 8px; align-items: center; }
#page .lookup > button, #page .lookup-search button, #page .adding .cancel {
  border: 1px solid var(--line); background: var(--panel); color: inherit; border-radius: 6px;
  padding: 4px 10px; font: inherit; font-size: 12px; cursor: pointer;
}
#page .lookup-search { display: flex; gap: 6px; }
#page .lookup-search[hidden] { display: none; }
#page .lookup-search input { flex: 1; }
#page .lookup .status:empty { display: none; }
#page .lookup .status { margin: 6px 0 0; }
#page .lookup-results { list-style: none; margin: 6px 0 0; padding: 0; max-height: 260px; overflow-y: auto; }
#page .lookup-results button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%;
  padding: 5px 8px; border: none; border-bottom: 1px solid var(--line); background: none;
  color: var(--ink); font: inherit; font-size: 12.5px; text-align: left; cursor: pointer;
}
#page .lookup-results button:hover { background: var(--product); }
#page .lookup-results .sub { font-size: 11px; color: var(--muted); }
