/* color-scheme lets the browser draw its own controls -- checkboxes, number
   spinners, a select's list, scrollbars -- in the theme the page is showing,
   rather than white ones on a dark page. */
:root {
  color-scheme: light dark;
  --bg: #f7f7f5;
  --card: #ffffff;
  --ink: #1f2328;
  --muted: #6b7280;
  --line: #e3e3e0;
  --accent: #2f6f4e;
  --warn-bg: #fdf3d8;
  --warn-ink: #6b5310;
  /* Text on an accent background. White on the light accent, but the dark
     theme's accent is a pale green that white text all but disappears on
     (2:1), so there it is near-black instead (8:1). */
  --on-accent: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181c;
    --card: #1f2227;
    --ink: #e8e8e6;
    --muted: #9aa1ab;
    --line: #30343b;
    --accent: #6fc79a;
    --warn-bg: #3a3320;
    --warn-ink: #e8d9a4;
    --on-accent: #12241a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

main { max-width: 1000px; margin: 0 auto; padding: 28px 16px 64px; }

.topbar {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 650; text-decoration: none; color: var(--ink); }
.topbar nav { display: flex; gap: 16px; }
.topbar nav a { color: var(--muted); text-decoration: none; }
.topbar nav a:hover { color: var(--ink); }
.whoami { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* A link nobody styled took the browser's own blue, which is made for a white
   page: on the dark theme it came out at under 2:1, and a recipe's "source"
   could hardly be seen. The accent reads on both themes. Visited links keep
   the same colour -- purple on dark grey is no better. */
a { color: var(--accent); }

/* A page heading big enough to be the first thing read, and tighter than body
   text so a recipe title over two lines still reads as one heading. A step
   smaller on a phone, where two lines of 1.6rem is a third of the screen. */
h1 { font-size: 1.6rem; line-height: 1.2; letter-spacing: -0.01em; margin: 0; }
@media (max-width: 599px) {
  h1 { font-size: 1.4rem; }
}
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

.linkish {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--muted); text-decoration: none; font: inherit; font-size: 0.9rem;
}
.linkish:hover { color: var(--ink); }

/* name picker */
.picker { display: grid; gap: 10px; max-width: 420px; margin-top: 20px; }
.person {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 14px 16px; text-align: left; cursor: pointer;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; font: inherit;
}
.person:hover { border-color: var(--accent); }
.person-name { font-weight: 600; }
.person .muted { margin-left: auto; }

/* week board */
.weeknav { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
/* Sized to sit level with the buttons either side rather than tower over them. */
.weeknav h1 { white-space: nowrap; font-size: 1.4rem; }
.navstep { padding: 6px 12px; font-size: 1.1rem; line-height: 1.2; }
.navstep .wide { font-size: 0.9rem; }
.thisweek { margin-left: auto; }
/* On a phone the words go and the title shrinks a step, so that "This week"
   still fits on the same line rather than taking one of its own. */
@media (max-width: 599px) {
  .weeknav { gap: 6px; }
  .weeknav h1 { font-size: 1.1rem; }
  .navstep .wide { display: none; }
}

.banner {
  background: var(--warn-bg); color: var(--warn-ink);
  padding: 10px 14px; border-radius: 8px; margin-bottom: 16px;
}

.board { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
/* A week reads as a week only when all seven days sit on one row. */
@media (min-width: 1120px) {
  .board { grid-template-columns: repeat(7, 1fr); }
}
.day {
  --cook: var(--line);
  position: relative; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; display: flex; flex-direction: column; gap: 6px; min-height: 140px;
}
.day header { display: flex; flex-direction: column; gap: 1px; }
/* The date never breaks, but the badge may drop below it: seven cards across a
   laptop leave too little room for both, and a clipped badge says nothing. */
.day header .nowrap { white-space: nowrap; }
.weekday { font-weight: 650; }
/* On the date's line, where there is room for it: beside the weekday it did
   not fit a phone's half-width card and fell onto a line of its own. */
.todaybadge {
  display: inline-block; padding: 1px 7px; border-radius: 999px; vertical-align: 1px;
  background: var(--ink); color: var(--card); font-size: 0.72rem; font-weight: 650;
  letter-spacing: 0.02em; text-transform: uppercase;
}
.day.today { box-shadow: 0 4px 16px rgb(0 0 0 / 0.10); }
.day.past { opacity: 0.55; }
.day.unassigned { background: transparent; border-style: dashed; }
.day p { margin: 0; }
.cook { display: flex; align-items: center; gap: 7px; font-size: 0.9rem; color: var(--muted); }
/* Dutch and Swedish make long single words -- boerenkoolstamppot -- that no
   space would ever break, and a card half a phone wide cannot fit them. */
.chosen { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; hyphens: auto; }
.chosen a { color: var(--ink); text-decoration: none; }
.chosen a:hover { text-decoration: underline; }
.pending { color: var(--muted); font-style: italic; }
.choose { margin-top: auto; align-self: flex-start; }
.dish { display: flex; align-items: flex-start; gap: 8px; }
.dish > div { min-width: 0; display: grid; gap: 2px; }
.daythumb {
  flex: none; width: 40px; height: 40px; margin-top: 2px;
  border-radius: 7px; object-fit: cover; border: 1px solid var(--line);
}
/* Seven cards across a laptop are narrower than two across a phone, and a
   thumbnail beside the name broke it into fragments. There the picture goes
   above the name instead, the card's full width -- the screen has the room
   that a phone does not. */
@media (min-width: 1120px) {
  .dish { flex-direction: column; }
  .daythumb { width: 100%; height: auto; aspect-ratio: 4 / 3; margin: 0 0 2px; }
}

/* The cook's colour down the card's edge, so whose day it is reads from across
   the room. An unowned day keeps its dashed outline all the way round. */
.day { border-left: 5px solid var(--cook); padding-left: 12px; }
.day.unassigned { border-left-style: dashed; border-left-width: 1px; padding-left: 16px; }

.empty { color: var(--muted); }
code { background: var(--bg); padding: 2px 5px; border-radius: 4px; }

/* ---- recipes ---- */

/* Every page opens the same way. A way back, when there is one, sits above the
   heading as a small "‹ Place" -- the same words and the same spot on every
   page, rather than a differently worded grey link somewhere on the right.
   Actions sit to the right of the heading as buttons: filled for what the page
   is for, outlined for anything else. Grey text links are for inside sentences. */
.backlink {
  display: inline-block; margin-bottom: 6px; padding: 2px 0;
  color: var(--muted); text-decoration: none; font-size: 0.9rem;
}
.backlink::before { content: "\2039  "; }
.backlink:hover { color: var(--ink); }
.pagehead { display: flex; align-items: center; gap: 8px 16px; margin-bottom: 20px; flex-wrap: wrap; }
/* The heading wraps beside its buttons rather than pushing them onto a line of
   their own -- a recipe title is often two lines on a phone. */
.pagehead > :first-child { flex: 1 1 12rem; min-width: 0; }
.subtitle { margin: 2px 0 0; color: var(--muted); font-size: 0.9rem; }

/* Tabs across a set of pages (admin). Links underneath, so the current one is
   marked by aria-current rather than a class the page has to remember. */
.tabs {
  display: flex; gap: 4px; margin: -4px 0 20px; border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tabs a {
  padding: 8px 14px; color: var(--muted); text-decoration: none; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }

/* A folded explanation: what a page does, for whoever has not used it yet. */
.explainer { margin: 0 0 16px; }
.explainer summary { cursor: pointer; width: fit-content; color: var(--muted); font-size: 0.9rem; }
.explainer summary:hover { color: var(--ink); }
.explainer[open] summary { margin-bottom: 4px; }
.explainer p { max-width: 70ch; }

/* The Add recipe menu. Anchored to the button's right edge, because the button
   sits at the right of the head and a menu opening rightwards would leave a
   phone's screen. */
.addmenu { position: relative; }
.addmenu summary { list-style: none; }
.addmenu summary::-webkit-details-marker { display: none; }
.addmenu summary::after { content: " \25BE"; }
.addmenu-options {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 10;
  display: grid; min-width: 180px; padding: 6px 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.12);
}
.addmenu-options a { padding: 10px 16px; color: var(--ink); text-decoration: none; }
.addmenu-options a:hover { background: var(--bg); }

.button {
  display: inline-block; padding: 8px 14px; border-radius: 8px; border: none;
  background: var(--accent); color: var(--on-accent); text-decoration: none;
  font: inherit; font-size: 0.95rem; cursor: pointer;
}
.button:hover { filter: brightness(1.08); }

.searchbar { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.searchbar input[type="search"] {
  flex: 1 1 260px; padding: 9px 12px; font: inherit;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
}
.checkline { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.9rem; }

.recipelist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
/* The heading over each half of the recipe list. Quiet on purpose: it labels
   two stacks of the same rows, and a loud one would read as a section of the
   page rather than as a signpost between them. */
.listhead {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); font-weight: 600; margin: 20px 0 8px;
}
.listhead:first-child { margin-top: 0; }
.recipe {
  background: var(--card); border: 1px solid var(--line); border-radius: 9px;
  padding: 12px 14px; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
}
.recipe a { color: var(--ink); text-decoration: none; font-weight: 600; }
.recipe a:hover { color: var(--accent); }
.recipe .muted { margin-left: auto; }
/* "Cook this" on a recipe's own page, reached from the list while choosing. */
.choosehere {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px 16px;
}
.choosehere .cookthis { margin: 0; display: flex; align-items: center; gap: 8px; }
.recipe.archived { opacity: 0.6; }

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

/* A box of the same size whether or not there is a photograph, so the titles
   line up -- but an invisible one where there is none, because most recipes
   are typed in rather than imported and a column of empty frames reads as a
   list of broken images. The row itself stays baseline-aligned; only the
   thumbnail centres against it. */
.thumb {
  flex: none; align-self: center; width: 44px; height: 44px;
  border-radius: 7px; overflow: hidden;
  background: var(--bg); border: 1px solid var(--line);
}
.thumb.blank { background: none; border: none; }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* Capped rather than free: a 3000px press photo would otherwise push the
   ingredients off the bottom of a phone. */
.recipephoto {
  display: block; width: 100%; max-height: 320px; object-fit: cover;
  margin: 0 0 4px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card);
}
.imagenow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.imagenow img {
  width: 96px; height: 72px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--line);
}

/* A stored picture whose file has gone (base.html marks it). Where it was only
   decoration it goes quietly, and a thumbnail keeps its empty space so the
   titles still line up -- exactly as a recipe that never had a picture. On the
   edit form the picture goes but "Remove this picture" stays: that is how the
   missing one is cleared. */
/* !important because every kind of picture sets its own display (the page
   photos further down among them), and this is the one rule meant to win
   over all of them. */
img.broken { display: none !important; }
.imagenow:has(img.broken)::before {
  content: "The picture has gone missing."; color: var(--muted); font-size: 0.9rem;
}
.thumb:has(img.broken) { background: none; border: none; }
/* A photographed page is the recipe's original, so losing one is said rather
   than hidden: the box keeps its place and says what is missing. */
.sourcepages a:has(img.broken) {
  display: flex; align-items: center; justify-content: center;
  width: 150px; height: 220px; border: 1px dashed var(--line); border-radius: 8px;
  color: var(--muted); font-size: 0.85rem; text-decoration: none;
}
.sourcepages a:has(img.broken)::after { content: "Photo missing"; }

/* Room enough between sections that Ingredients and Method read as two parts
   of the page rather than one long list. */
section { margin-top: 36px; }
section h2 { font-size: 1.15rem; line-height: 1.3; margin: 0 0 12px; }

.ingredients { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.ingredients li { display: flex; gap: 7px; align-items: baseline; flex-wrap: wrap; }
.ingredients .qty, .ingredients .unit { color: var(--muted); font-variant-numeric: tabular-nums; }
.ingredients .name { font-weight: 500; }

.prose { white-space: pre-wrap; margin: 0; }

/* The method as numbered steps. The number sits in its own column so a long
   step wraps under its text rather than under the number, and a step's title
   is what the eye finds first when glancing back at the page mid-cook. */
.method { list-style: none; counter-reset: step; margin: 0; padding: 0; }
.method li {
  counter-increment: step;
  display: grid; grid-template-columns: 32px 1fr; column-gap: 12px;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.method li:first-child { border-top: 0; padding-top: 4px; }
.method li::before {
  content: counter(step);
  grid-row: 1 / span 2;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--on-accent);
  font-weight: 650; font-size: 14px;
}
.method .steptitle {
  grid-column: 2; margin: 2px 0 2px; font-size: 16px; font-weight: 650;
  color: var(--accent);
}
.method p { grid-column: 2; margin: 0; }
.method .steptitle + p { margin-top: 0; }
.archiveform { margin-top: 36px; }

/* ---- recipe form ---- */

.recipeform { display: grid; gap: 18px; max-width: 640px; }
.field { display: grid; gap: 5px; }
.field .label { font-weight: 600; font-size: 0.92rem; }
.field .hint { font-weight: 400; line-height: 1.45; }
.field input, .field textarea, .field select {
  padding: 9px 12px; font: inherit;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; width: 100%;
}
/* The rule above is for text: a tick box stretched to the full width pushed its
   label into a column a word wide ("Remove / this / picture"). */
.field input[type="checkbox"] { width: auto; padding: 0; }
.field textarea { resize: vertical; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.92rem; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: 2px solid var(--accent); outline-offset: -1px;
}
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row .field { flex: 1 1 200px; }
.row .field.narrow { flex: 0 0 120px; }
.error { color: #b91c1c; font-size: 0.88rem; }
@media (prefers-color-scheme: dark) { .error { color: #fca5a5; } }
.actions { display: flex; align-items: center; gap: 16px; }

/* ---- planning a day ---- */

.planactions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.planactions form { margin: 0; }
/* Set apart from the buttons that choose something: at the far end of the row
   on a wide screen, and on a line of its own on a phone, where the row wraps
   and would otherwise put it right after "Nothing planned". */
.planactions .clearday { margin-left: auto; }
@media (max-width: 599px) {
  .planactions .clearday { flex-basis: 100%; margin: 4px 0 0; }
}
.button.secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.button.secondary:hover { border-color: var(--accent); filter: none; }
.button.small { padding: 5px 10px; font-size: 0.85rem; }
.chosen.big { font-size: 1.2rem; }
.chosen a { color: inherit; text-decoration: none; }
.chosen a:hover { text-decoration: underline; }
.day .note { font-style: italic; }
.recipe .cookthis { margin: 0; display: flex; align-items: center; gap: 8px; }
/* Not .muted: `.recipe .muted` takes the right-hand margin that pushes the
   ingredient count away from the title, and this label must stay put. */
.servingsbox { display: flex; align-items: center; gap: 5px; }
.servingsbox span { color: var(--muted); }
.servingsbox input {
  width: 3.4rem; padding: 5px 6px; font: inherit; font-size: 0.85rem;
  text-align: center; background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 7px;
}
.recipe .muted { margin-left: auto; }

/* ---- shopping list ---- */

.aisle { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.04em;
         color: var(--muted); margin: 24px 0 8px; }
.shoppinglist { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 2px; }
.item { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item form { margin: 0; flex: 1; }
.item .removeform { flex: 0; }
.item .haveform { flex: 0; }
.item .haveform button { font-size: 0.82rem; white-space: nowrap; }
/* Deliberately quiet and deliberately still a real tap target: it sits beside
   the tick that the whole row is, so it has to be missable by a thumb aiming
   at the row and findable by one aiming at it. */
.item .settings {
  flex: none; color: var(--muted); text-decoration: none; line-height: 1;
  padding: 8px 12px; border-radius: 7px; font-size: 1rem;
}
.item .settings:hover { color: var(--ink); background: var(--card); }
/* Which dinners a line is for. Quiet like the cog beside it, and the same
   size of target for the same reason. The count is there only when there is
   more than one dinner, so a glance down the list shows what is shared. */
.item .whyfor {
  flex: none; display: flex; align-items: center; gap: 3px; cursor: pointer;
  color: var(--muted); padding: 8px 8px; border-radius: 7px; line-height: 1;
  font-size: 0.85rem; font-variant-numeric: tabular-nums; user-select: none;
}
.item .whyfor:hover { color: var(--ink); background: var(--card); }
.item .whyfor:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.item .whyfor .arrow { font-size: 0.75rem; transition: transform 0.15s; }
.item .whyfor:has(input:checked) { color: var(--accent); }
.item .whyfor:has(input:checked) .arrow { transform: rotate(180deg); }
/* The breakdown takes a line of its own under the row, indented to the name
   so it reads as belonging to it. */
.item .sources {
  display: none; flex: 1 0 100%; list-style: none;
  margin: -4px 0 6px; padding: 0 0 0 37px;
  font-size: 0.88rem; color: var(--muted);
}
.item:has(.whyfor input:checked) .sources { display: grid; gap: 3px; }
.item .sources li,
.coveredlist .sources li { display: flex; gap: 8px; align-items: baseline; }
.item .sources .srcday,
.coveredlist .sources .srcday { flex: none; width: 2.4em; }
.item .sources a,
.coveredlist .sources a { color: var(--ink); text-decoration: none; min-width: 0; }
.item .sources a:hover,
.coveredlist .sources a:hover { color: var(--accent); text-decoration: underline; }
.item .sources .share,
.coveredlist .sources .share { margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tick {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; font: inherit; color: var(--ink);
  padding: 9px 6px; cursor: pointer; text-align: left; border-radius: 7px;
}
.tick:hover { background: var(--card); }
.box {
  flex: none; width: 21px; height: 21px; border-radius: 5px;
  border: 1.5px solid var(--line); background: var(--card);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; color: var(--accent);
}
.item.checked .box { border-color: var(--accent); }
.item.checked .amount, .item.checked .what { text-decoration: line-through; color: var(--muted); }
.amount { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.what { font-weight: 500; }

.addextra { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.addextra input[type="text"] {
  flex: 1 1 260px; padding: 9px 12px; font: inherit;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
}
/* Catalogue names offered under the add box. Buttons rather than a datalist:
   a phone renders a datalist as a small arrow beside the field and keeps the
   names behind it, so on the device the list is actually read on there was
   nothing to see. A line of their own -- a long name must not squeeze the box
   it is being typed into -- and hidden entirely when nothing matched, which
   is why the partial renders to nothing at all rather than to whitespace. */
/* The keep-in-stock question and its shelf life. One row of its own below the
   box, because the two belong together and the second appears and disappears
   as the name is typed -- wrapped around the Add button it would move it. */
.keepline { flex: 1 0 100%; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
/* Nothing left to ask: not :empty, which a template's own whitespace defeats. */
.keepline:not(:has(label)) { display: none; }
.weeksline {
  display: flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 0.9rem;
}
.weeksline input {
  width: 4.5em; padding: 6px 8px; font: inherit;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
}

.addextra .suggestions { flex: 1 0 100%; display: flex; flex-wrap: wrap; gap: 8px; }
.addextra .suggestions:empty { display: none; }
.suggestion {
  padding: 8px 14px; min-height: 40px; font: inherit; font-size: 0.95rem;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
}
.suggestion:hover { border-color: var(--accent); }

.doneshopping {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--line);
}
.doneshopping .muted { flex: 1 1 220px; }

/* Buttons rather than the grey links these used to be, so the gap closes to
   what sits between buttons elsewhere: 20px of air between outlined shapes
   reads as three unrelated things. */
.listactions { display: flex; gap: 10px; align-items: center; margin-top: 28px; flex-wrap: wrap; }
.listactions form { margin: 0; }
#list-text { position: absolute; left: -9999px; width: 1px; height: 1px; }

.warnings { margin: 8px 0 0; padding-left: 20px; font-size: 0.9rem; }
.warnings li { margin: 2px 0; }

/* ---- the rota, and swapping two days ---- */

.swapform { display: grid; gap: 18px; max-width: 640px; }
.swapform .row .field { flex: 1 1 220px; }

/* Cards you may trade, while rearranging is switched on. touch-action keeps
   the browser from taking the gesture as a scroll before the drag handler ever
   sees it -- which is also why it cannot apply all the time: it costs a swipe
   that starts on a card, and on a phone that is how the board is read. The
   dashed edge says which cards the mode is acting on. */
.board.swapmode .day.swappable {
  touch-action: none; cursor: grab;
  outline: 1px dashed var(--accent); outline-offset: 3px;
}
.swaptoggle {
  display: flex; align-items: center; gap: 8px;
  width: fit-content; cursor: pointer; font-size: 0.92rem;
}
/* An author display beats the browser's own [hidden] rule, so without this the
   box appears before swap.js has revealed it -- offering a mode that nothing
   has wired up yet, or that has no second day to drag onto. */
.swaptoggle[hidden] { display: none; }
.day.dragging { opacity: 0.5; cursor: grabbing; }
.day.dragover { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

.boardnote { margin-top: 18px; display: grid; gap: 10px; }
.swapfallback summary { cursor: pointer; width: fit-content; }
.swapfallback[open] summary { margin-bottom: 14px; }
.resetform { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }

#swap-dialog {
  border: 1px solid var(--line); border-radius: 12px; padding: 20px;
  background: var(--card); color: var(--ink); max-width: 420px; width: calc(100% - 32px);
}
#swap-dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
.swapdialog { display: grid; gap: 4px; }
.swapquestion { margin: 0 0 10px; font-size: 1.05rem; }
.swapdialog .actions { margin-top: 14px; }

.choices { border: 1px solid var(--line); border-radius: 9px; padding: 12px 14px; margin: 0; }
/* A legend sits *in* the top border, so a long one that wraps to two lines has
   the border struck through it. Floating it makes it an ordinary block above
   the choices, and the border closes up. */
.choices legend { float: left; width: 100%; padding: 0 0 6px; }
.choices::after { content: ""; display: table; clear: both; }
/* clear: the legend above is floated, so without this the first choice would
   wrap into the space beside it. */
.choice { display: flex; clear: both; gap: 10px; align-items: flex-start;
          padding: 7px 0; cursor: pointer; }
.choice input { margin-top: 4px; flex: none; }
.choice span { display: block; }
.choice .small { margin-top: 1px; }

.rota { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; max-width: 420px; }
.rota li { display: flex; align-items: center; gap: 12px; }
/* A fixed label column keeps the seven boxes in one straight line, which is
   what makes a misassigned day easy to spot. */
.rota label { flex: 0 0 96px; font-weight: 600; font-size: 0.92rem; }
.rota select {
  flex: 1; padding: 8px 10px; font: inherit;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
}

/* ---- ingredient catalogue ---- */

.catalogue { list-style: none; margin: 8px 0 0; padding: 0; }
.catrow {
  display: flex; align-items: center; gap: 6px 16px; flex-wrap: wrap;
  padding: 10px 0; border-top: 1px solid var(--line);
}
/* The name takes the slack so the controls line up down the page, which is
   what makes a column of them scannable. */
.catname { flex: 1 1 240px; min-width: 0; display: flex; flex-direction: column; }
/* The name field's padding is pulled back out, so its text starts on the same
   edge as the line count and the controls beneath it. */
.catname .renameform { margin-left: -7px; }
.catcontrols { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; }
.renameform { display: flex; gap: 6px; align-items: center; }
/* The name reads as text until you touch it, so a page of 50 ingredients does
   not look like a page of 50 form fields. */
.renameform input[type="text"] {
  flex: 1 1 auto; min-width: 0; padding: 3px 6px; font: inherit; font-weight: 500;
  color: var(--ink); background: transparent;
  border: 1px solid transparent; border-radius: 6px;
}
.renameform input[type="text"]:hover { border-color: var(--line); }
.renameform input[type="text"]:focus {
  border-color: var(--accent); background: var(--card); outline: none;
}
.renameform button { opacity: 0; flex: none; }
.renameform:focus-within button, .catrow:hover .renameform button { opacity: 1; }
.catrow form { margin: 0; flex: none; }
.catrow.neverbuy .renameform input[type="text"] {
  text-decoration: line-through; color: var(--muted);
}
.mergeform { display: flex; gap: 6px; align-items: center; }
.mergeform select {
  padding: 5px 8px; font: inherit; font-size: 0.88rem;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 7px; max-width: 170px;
}
.linkish.subtle { color: var(--muted); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* "got it" took the row off the list; this offers it back. Fixed to the
   bottom so it is on screen wherever the page came back scrolled to. */
.undobar {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 10;
  max-width: 560px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px 10px 16px;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.18);
}
.undobar form { margin: 0; flex: none; }

/* ---- already at home ---- */

.covered { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 12px; }
/* The heading stays a heading and sits inline beside the marker, so folding it
   costs the page neither its outline nor the triangle that says it folds. The
   summary keeps the browser's own display: giving it flex takes the triangle
   away in Chrome. */
.covered > summary { cursor: pointer; padding: 2px 0; list-style-position: outside; }
.covered > summary:hover h2 { color: var(--accent); }
.covered h2 { font-size: 1rem; margin: 0; display: inline; }
.covered > summary .count { margin-left: 6px; }
.covered > p { margin: 4px 0 10px; max-width: 46ch; }
.coveredlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.coveredrow { display: flex; align-items: baseline; gap: 10px; }
.coveredrow form { margin: 0 0 0 auto; }
.coveredlist .sources {
  list-style: none; margin: 2px 0 0; padding: 0 0 0 12px;
  display: grid; gap: 2px; font-size: 0.88rem; color: var(--muted);
}
.athome { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 12px; }
.athome summary {
  cursor: pointer; color: var(--muted); font-size: 0.9rem;
  list-style-position: outside; padding: 2px 0;
}
.athome summary:hover { color: var(--ink); }
.athome > p { margin: 6px 0 10px; max-width: 46ch; }
.athomelist { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.athomelist li { display: flex; align-items: baseline; gap: 10px; padding: 3px 0; }
.athomelist .what { color: var(--muted); }
.athomelist form { margin: 0 0 0 auto; }
.lastsform { display: flex; gap: 5px; align-items: baseline; font-size: 0.88rem; }
.lastsform label, .lastsform span { color: var(--muted); }
.lastsform input[type="number"] {
  width: 3.6em; padding: 3px 6px; font: inherit; font-size: 0.88rem;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px; text-align: right;
}
/* Hidden rather than transparent: an invisible Save still took its width, and
   that was a gap on every row. It appears once the number has been changed,
   which is the only time there is anything to save (Enter saves too). */
.savedays { display: none; }
.catrow:has(.lastsform[data-dirty]) .savedays { display: inline-block; }

/* An on/off setting on a row: an outline when off, filled when on, so the
   state is visible at a glance down a long list rather than read word by word. */
.chip {
  padding: 3px 10px; border-radius: 999px; font: inherit; font-size: 0.82rem;
  cursor: pointer; white-space: nowrap;
  background: transparent; color: var(--muted); border: 1px solid var(--line);
}
.chip:hover { color: var(--ink); border-color: var(--muted); }
.chip[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent); border-color: var(--accent); font-weight: 600;
}
.chip[aria-pressed="true"]::before { content: "\2713  "; }

/* ---- recipes from photos ---- */

.inboxform { margin-bottom: 8px; }
.inboxnote { flex-basis: 100%; margin: 0; color: var(--muted); font-style: italic; }
.recipe .discard { margin: 0; flex-basis: 100%; }
.recipe .discard .linkish { font-weight: 400; }

/* The photographed pages. A strip across the top on a phone -- each a link to
   the full photo, which is where the small print is actually read -- and a
   column beside the form once there is room, sticky, so the line being
   checked and the page it came from are on screen together. */
.sourcepages { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.sourcepages a { flex: none; }
.sourcepages img {
  display: block; height: 220px; width: auto; max-width: 80vw; object-fit: contain;
  border-radius: 8px; border: 1px solid var(--line); background: var(--card);
}
.transcribe { display: grid; gap: 18px; }
.transcribe > .sourcepages { margin-bottom: 4px; }
@media (min-width: 1000px) {
  .transcribe { grid-template-columns: minmax(0, 1fr) minmax(0, 640px); align-items: start; }
  .transcribe > .sourcepages {
    flex-direction: column; overflow: visible;
    position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto;
  }
  .transcribe > .sourcepages img { height: auto; width: 100%; max-width: none; }
}
/* Room under the list for the undo bar, or it sits over the last row. */
main:has(.undobar) { padding-bottom: 120px; }
