/* ==========================================================================
   Noctislane stylesheet

   How it is organised:
     1. Settings   - colours, spacing steps and corner sizes, as named values
     2. Basics     - the page, text and links
     3. Header
     4. Shared     - small pieces used on more than one page
     5. Weekly Meals page
     6. Recipes page
     7. Calories details tables
     8. Total Calories page
     9. Food Items page
    10. Login page
    11. Add page (forms)
    12. Editing a day of the plan
    13. Recipe builder
    14. The method: editor and recipe page
    15. Label photos
    16. Motion: soft page changes, hovers and pop-ups
    17. Glass: frosted cards and top bar
    18. Charts: macro split and the daily target
    19. Icons
    20. The warm accent
    21. Phone layout: bottom menu and Food Items cards
    22. Colours: sections, meals, macros, title stripe, buttons
    23. Shopping list and stores
    24. Account button and Settings
    25. Today, and the checks on Weekly Meals
    26. Cooking view
    27. Menu groups and the Plan switch
    28. Today: the four bars, spacing, and the phone layout

   Every gap on the site uses one of the spacing steps from section 1.
   That is what keeps the spacing even: to make the whole site airier or
   tighter, change the steps there and everything follows.
   ========================================================================== */


/* ---- 1. Settings -------------------------------------------------------- */

:root {
  /* The palette: five colours, darkest to lightest. Every colour on the
     site is one of these, or two of them mixed. */
  --navy-900: #0D1321;
  --navy-800: #1D2D44;
  --steel-600: #3E5C76;
  --steel-400: #748CAB;
  --cream: #F0EBD8;
  /* A deeper shade of the darkest navy, for the page itself, so the cards
     stand out from it. */
  --navy-950: #040A1A;

  /* Colours for the charts: one per macro, and a warm amber kept for
     calories. They are the same as the recipe editor's text colours, so
     the site keeps one small family of accents. */
  --protein: #8EC5E8;     /* sky */
  --carbs: #9CCB8F;       /* green */
  --fat: #C9A7E0;         /* lilac */
  --calories: #F0C674;    /* amber */
  --peach: #F2A68A;       /* a warm extra, for the meals of the day */

  /* What each colour is used for. Change a role here and the whole site
     follows. "color-mix" blends two palette colours, for in-between shades
     such as the thin lines. */
  --page: var(--navy-950);         /* page background */
  /* Cards are frosted glass: navy at about a third strength (68% see-
     through), with what is behind them blurred (see section 17). The glows
     on the page show softly through them. */
  --card: color-mix(in srgb, var(--navy-800) 30%, transparent);
  --header: color-mix(in srgb, var(--navy-800) 38%, transparent);  /* the top bar, glass too */
  /* Glass: how much the background is blurred, and the thin light edge
     around each card, as if light catches the glass. A light frost.
     Tried so far: 18px (heavy haze), 6px, none (clear glass), 3px, 1px, 8px. */
  --glass-blur: blur(2px) saturate(150%);
  --glass-edge: color-mix(in srgb, var(--steel-400) 20%, transparent);
  --text: var(--cream);            /* main text and headings */
  --link: var(--cream);            /* links */
  --muted: var(--steel-400);       /* labels, units, small print */
  /* The thin lines around the tables and between rows and sections:
     steel blue made mostly see-through, so they stay faint on any card.
     (Until 2026-11-15 they were a solid blue-grey, and the card edge
     above was 26%. Tried so far: 30%, 10%.) */
  --line: color-mix(in srgb, var(--steel-600) 50%, transparent);
  /* The edge of boxes you type in and of outlined buttons: clearer than
     the thin lines, so they stay easy to find (end of section 22). */
  --line-box: color-mix(in srgb, var(--steel-600) 45%, var(--navy-800));
  --accent: var(--steel-400);      /* buttons, focus rings */
  --on-accent: var(--navy-900);    /* text on a button */
  /* Highlights inside cards (day headers, total rows, boxes, active pills):
     steel blue softened into navy, also 20% see-through to match. */
  --accent-soft: color-mix(in srgb,
                   color-mix(in srgb, var(--steel-600) 60%, var(--navy-800)) 80%,
                   transparent);
  /* A deep, soft shadow under each card, plus a faint bright line along
     its top edge (the "inset" part), like light on the edge of glass. */
  --shadow: 0 18px 48px rgb(0 0 0 / 0.45), inset 0 1px 0 rgb(240 235 216 / 0.07);

  /* Tells the browser the site is dark, so its own parts (scroll bars,
     dropdown lists, the search box's clear button) are drawn dark too. */
  color-scheme: dark;

  /* Spacing steps, small to large. 1rem is 16px. */
  --space-1: 0.25rem;   /*  4px */
  --space-2: 0.5rem;    /*  8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.5rem;    /* 24px */
  --space-6: 2rem;      /* 32px */
  --space-7: 3rem;      /* 48px */
  --space-8: 4rem;      /* 64px */

  /* Rounded corners: large for cards, small for things inside cards. */
  --radius: 16px;
  --radius-small: 10px;

  /* The widest the page content is allowed to get. */
  --page-width: 80rem;
}

/* ---- 2. Basics ---------------------------------------------------------- */

/* The two typefaces, stored on this server (static/vendor/fonts), so no
   other website is involved. Both are "variable" fonts: one file holds
   every weight.
     Plus Jakarta Sans  friendly, rounded and very readable, for all
                        ordinary text (since 2026-11-15; Inter before).
                        Weights 200 to 800.
     Fraunces           a warm serif with a cookbook feel, for headings
   "swap" shows the text straight away in a standard font while the file
   loads, then switches. Both are free (SIL Open Font License). */
@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("vendor/fonts/plus-jakarta-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Fraunces";
  src: url("vendor/fonts/fraunces-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-text: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

/* Reserve the scrollbar's width on every page, including short pages.
   Centred content and the header therefore stay still during navigation. */
html { scrollbar-gutter: stable; }

/* The background, drawn in static/waves.svg: a very dark blue gradient
   and a band of thin wavy dotted lines running diagonally from top right
   to bottom left. All dim on purpose, to make the page less flat without
   drawing the eye. No glows for now. "fixed" keeps it still while the
   page scrolls. The fabric grain is a separate layer, just below. */
body {
  min-height: 100vh;
  margin: 0;
  background-color: var(--page);
  background-image: url("waves.svg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* The fabric grain: a small tile (static/grain.svg) repeated over the
   whole screen, behind everything on the page. The tile is drawn at
   double density and shown at 180px, so each speck is half a page pixel:
   as fine as a sharp screen can show. The specks are dark, so they sink
   into the background like shadows between threads. "opacity" is its
   strength: raise it for more texture, lower it for less (dark specks on
   a dark page need a higher number than light ones to show at all). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: url("grain.svg");
  background-size: 180px 180px;
  background-repeat: repeat;
  opacity: 0.6;
  pointer-events: none;
}

/* No underline on any link, anywhere on the site. Links are cream, like
   the text; pointing at one turns it light steel. */
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--accent); }

/* Page titles and section headings (and the site name, in section 3) use
   the serif; everything else is in Plus Jakarta Sans. */
h1,
h2 {
  font-family: var(--font-display);
  font-weight: 600;
}

h1 {
  margin: 0 0 var(--space-6);
  font-size: 2.1rem;
  line-height: 1.15;
  letter-spacing: -0.015em;
}

h2 { margin: 0; font-size: 1.05rem; line-height: 1.3; }

/* Numbers that sit next to each other (boxes, kcal, totals) use digits of
   equal width, so they line up and don't shift as they change. */
.facts dd,
.kcal,
.overview-figure,
.overview-foot,
.macro-legend { font-variant-numeric: tabular-nums; }

/* h3 is used everywhere as a small label above a group of things. */
h3 {
  margin: 0 0 var(--space-3);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* The header's contents and the page under it share one maximum width and
   sit in the middle. "margin: 0 auto" is what does the centring: the
   leftover space is split equally between left and right. */
.site-header .inner,
main {
  max-width: var(--page-width);
  margin: 0 auto;
}

main { padding: var(--space-7) var(--space-5) var(--space-8); }


/* ---- 3. Header ---------------------------------------------------------- */

/* The background runs the full width of the window; the contents do not. */
.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--header);
}

.site-header .inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-7);
  padding: var(--space-4) var(--space-5);
}

.site-name {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);    /* 12px between the mark and the name */
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
}

/* The mark beside the name: the app icon, small, with a soft shadow so it
   sits on the glass top bar like a tile. */
.site-mark {
  display: block;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.35);
}

.site-name:hover { color: var(--text); }

.site-header nav { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* Each link is a rounded "pill". The page you are on is filled in.
   A pill never breaks its words across two lines; if the menu runs out
   of room, the whole pill moves to the next line instead. */
.site-header nav a {
  padding: var(--space-2) var(--space-4);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

/* On a phone the pills are a little smaller, so more fit on one line. */
@media (max-width: 30rem) {
  .site-header nav a { padding: var(--space-2) var(--space-3); font-size: 0.88rem; }
}

/* Log out sits at the far right of the header, quieter than the menu.
   "margin-left: auto" pushes it as far right as it can go. */
.site-header .logout {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.88rem;
}

.site-header .logout:hover { color: var(--text); }

.site-header nav a:hover { color: var(--text); }

.site-header nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--text);
}


/* ---- 4. Shared ---------------------------------------------------------- */

.kcal { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.empty { margin: 0; color: var(--muted); font-size: 0.85rem; }


/* ---- 5. Weekly Meals page ----------------------------------------------- */

/* Seven equal columns. Each is at least 10rem wide, so on a narrow screen
   the row scrolls sideways instead of squashing the days.
   (7 x 10rem plus the gaps fits inside the page width.) */
.week {
  display: grid;
  grid-template-columns: repeat(7, minmax(10rem, 1fr));
  gap: var(--space-4);
  overflow-x: auto;
  /* A box that scrolls sideways cuts off anything outside its edges,
     including the cards' soft shadow (which reaches about 66px below
     them). So the box gets room for the shadow on every side, and the
     same amount of negative margin, so the cards stay exactly where they
     were. Sideways it only grows into the page's own side margin. The
     bottom keeps the old small gap for the scroll bar. */
  --shadow-room: 4.5rem;
  padding: var(--space-5) var(--space-5) calc(var(--space-3) + var(--shadow-room));
  margin: calc(-1 * var(--space-5)) calc(-1 * var(--space-5)) calc(-1 * var(--shadow-room));
}

.day {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.day h2 {
  padding: var(--space-4);
  background: var(--accent-soft);
}

/* Each meal is its own block with a thin line under it, so Breakfast,
   Lunch and the rest read as separate sections. The last meal has no
   line, because the bottom of the card is right below it. */
.meal {
  padding: var(--space-4);
  border-bottom: 1px solid var(--line);
}

.meal:last-child { border-bottom: 0; padding-bottom: var(--space-5); }

.meal h3 { margin-bottom: var(--space-2); }

.meal ul { margin: 0; padding: 0; list-style: none; font-size: 0.92rem; }
.meal li { line-height: 1.4; }
.meal li + li { margin-top: var(--space-2); }


/* ---- 6. Recipes page ---------------------------------------------------- */

/* Compact rows with a line between them, and a modest gap before the
   opened recipe. */
.recipe-list {
  max-width: 34rem;
  margin: 0 0 var(--space-6);
  padding: 0;
  list-style: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.recipe-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-4);
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--line);
}

.recipe-list li:last-child { border-bottom: 0; }
.recipe-list a[aria-current="true"] { font-weight: 700; }

/* The opened recipe. */
.recipe {
  padding: var(--space-5);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  /* Leaves room above when the page jumps to #recipe. */
  scroll-margin-top: var(--space-5);
}

/* More room inside the recipe on anything wider than a phone. */
@media (min-width: 40rem) {
  .recipe { padding: var(--space-7); }
}

.recipe-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-4);
}

.recipe-header h2 { font-size: 1.6rem; letter-spacing: -0.02em; }
.recipe .close { font-size: 0.85rem; }

.recipe > p {
  max-width: 44rem;
  margin: var(--space-3) 0 0;
  color: var(--muted);
  font-size: 1.02rem;
}

/* Each main part of the recipe starts a clear step below the one before:
   the row of boxes, the calories details, and the ingredients and steps. */
.summary,
.recipe > h3,
.recipe-body { margin-top: var(--space-7); }

.recipe > h3 { margin-bottom: var(--space-4); }

/* The row of small boxes: two groups side by side. */
.summary { display: flex; flex-wrap: wrap; gap: var(--space-5) var(--space-6); }

/* On a screen wide enough for both groups on one line, every group after
   the first gets a vertical line on its left. On a phone the groups stack,
   where a line down the side would mean nothing. */
@media (min-width: 40rem) {
  .summary-group + .summary-group {
    padding-left: var(--space-6);
    border-left: 1px solid var(--line);
  }
}

.facts { display: flex; flex-wrap: wrap; gap: var(--space-3); margin: 0; }

.facts div {
  min-width: 6.5rem;
  padding: var(--space-3) var(--space-4);
  background: var(--accent-soft);
  border-radius: var(--radius-small);
}

.facts dt { color: var(--muted); font-size: 0.75rem; }
.facts dd { margin: 2px 0 0; font-size: 1.1rem; font-weight: 600; }

/* Ingredients beside steps on a wide screen, stacked on a narrow one. */
.recipe-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-7);
}

@media (min-width: 48rem) {
  .recipe-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); }
}

.ingredients { margin: 0; padding: 0; list-style: none; }

/* Each ingredient: the quantity in its own column, then the name. */
.ingredients li {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--line);
}

.ingredients li:first-child { padding-top: 0; }
.ingredients li:last-child { border-bottom: 0; }

/* The quantity stands out from the name: in the Recipes colour (lavender,
   as in the menu), bold, right-aligned in a column of its own with
   same-width digits, so the amounts line up and every name starts at the
   same place. A longer one ("1,360 g") just widens its row a little. */
.ingredients .qty {
  flex: 0 0 auto;
  min-width: 4.5rem;
  color: var(--fat);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}



/* ---- 7. Calories details tables ------------------------------------------ */

/* The two tables. On a phone they are stacked. On a wide screen they sit
   side by side and together fill the width of the recipe, with a gap
   between them. "3fr 2fr" shares the width three parts to two, because
   the first table has more columns than the second. */
.nutrition-tables {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5);
}

@media (min-width: 70rem) {
  /* The other nutrients take just the room their numbers need; the macros
     table, with the item names, gets all the rest. (A fixed 3 : 2 split
     left the macros short of room while the nutrients spread out.) */
  .nutrition-tables {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  /* A long name wraps onto a second line instead of making the table
     scroll (never narrower than 9rem). The script in _nutrition.html then
     keeps each row the same height in both tables, so they still line up. */
  .nutrition th.item {
    min-width: 9rem;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  /* Side by side, the rows of the two tables line up, so the second table
     does not need to repeat the item names. Stacked on a narrower screen,
     it keeps them. */
  .nutrition.repeat-items .item { display: none; }
}

/* The box around each table. A table wider than a phone screen scrolls
   sideways inside this box instead of stretching the whole page, and the
   box also trims the table's square corners to its rounded ones. */
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
}

.nutrition {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  /* Makes every digit the same width, so numbers line up in columns. */
  font-variant-numeric: tabular-nums;
}

/* Less padding above and below than left and right, which keeps the rows
   short while the columns stay roomy. */
.nutrition th,
.nutrition td {
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.nutrition .num { text-align: right; }

.nutrition thead th {
  padding-top: var(--space-3);
  padding-bottom: var(--space-3);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.nutrition .unit { font-weight: 400; }
.nutrition tbody th { font-weight: 400; }

/* The Total and Per serving rows. */
.nutrition tfoot th,
.nutrition tfoot td {
  background: var(--accent-soft);
  font-weight: 600;
}

/* The line between the Total row and the Per serving row. The usual line
   colour disappears against the green shading of these rows, so this one
   is the accent colour made mostly see-through, which shows on the
   shading in both light and dark mode. */
.nutrition tfoot th,
.nutrition tfoot td {
  border-bottom-color: color-mix(in srgb, var(--accent) 30%, transparent);
}

/* The very last row has no line under it: the box's own border is right
   below it. */
.nutrition tfoot tr:last-child th,
.nutrition tfoot tr:last-child td { border-bottom: 0; }

.nutrition tbody tr:last-child th,
.nutrition tbody tr:last-child td { border-bottom: 0; }


/* ---- 8. Total Calories page --------------------------------------------- */

/* The row of day buttons: the same rounded pills as the main menu. On a
   narrow screen they wrap onto a second line. */
.day-picker {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}

.day-picker a {
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
}

.day-picker a:hover { color: var(--text); }

.day-picker a[aria-current="page"] {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--text);
}

/* The card holding the day's table. Five columns do not need the full
   page width, so the card stops at a comfortable reading width. */
.calories-card {
  max-width: 56rem;
  padding: var(--space-5);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

@media (min-width: 40rem) {
  .calories-card { padding: var(--space-6); }
}

.calories-card h2 { margin-bottom: var(--space-5); font-size: 1.4rem; }

/* Each meal's rows sit in their own group. The meal name heads the group,
   in the same small label style used on the other pages. Inside a table
   every group would otherwise run straight into the next, so each label
   row after the first gets a little room above it. */
.day-calories .meal-label th {
  padding-top: var(--space-3);
  padding-bottom: var(--space-1);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.day-calories tbody:first-of-type .meal-label th { padding-top: var(--space-3); }

/* Rows are separated by meal group, not by a line under every item. */
.day-calories tbody tr:not(:last-child) th,
.day-calories tbody tr:not(:last-child) td { border-bottom: 0; }

/* The items: close together, so a meal reads as one group. */
.day-calories tbody tr:not(.meal-label) th,
.day-calories tbody tr:not(.meal-label) td {
  padding-top: var(--space-1);
  padding-bottom: var(--space-1);
  line-height: 1.45;
}

.day-calories tbody tr:last-child th,
.day-calories tbody tr:last-child td {
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

/* The meal names in the rows are ordinary weight; the label row and the
   total stay bold. */
.day-calories tbody th { font-weight: 400; }
.day-calories tbody .meal-label th { font-weight: 600; }

.day-calories .not-counted,
.day-calories td.empty { color: var(--muted); }

.day-calories td.empty { font-size: 0.85rem; }

.footnote {
  margin: var(--space-4) 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}


/* ---- 9. Food Items page -------------------------------------------------- */

/* The same card as an opened recipe. The tables inside it are the shared
   ones from section 7. */
.foods-card {
  padding: var(--space-5);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

@media (min-width: 40rem) {
  /* 30px above the Search row, 35px on the left, right and bottom. */
  .foods-card { padding: 30px 35px 35px; }
}

.foods-card .intro {
  margin: 0 0 var(--space-5);
  color: var(--muted);
}

/* Zebra stripes: every other row a shade lighter, so the eye can follow
   a row across both tables. The script on the page marks every second
   row still showing ("stripe"), so the pattern stays even while the
   search box hides rows. */
.foods-card .nutrition tbody tr.stripe th,
.foods-card .nutrition tbody tr.stripe td {
  background: color-mix(in srgb, var(--cream) 5%, transparent);
}

/* Arriving from a link such as /foods#food-3 highlights that food's row.
   ":target" means "the element named after the # in the address". It
   wins over the stripes. */
.nutrition tr:target th,
.nutrition tr:target td,
.foods-card .nutrition tbody tr:target th,
.foods-card .nutrition tbody tr:target td { background: var(--accent-soft); }

.nutrition tr:target { scroll-margin-top: var(--space-7); }

/* ---- 10. Login page ----------------------------------------------------- */

/* A small card in the middle of the page. */
.login-card {
  max-width: 24rem;
  margin: var(--space-6) auto 0;
  padding: var(--space-6);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-card h1 { margin-bottom: var(--space-5); font-size: 1.6rem; }

.login-card form { display: grid; gap: var(--space-2); }

.login-card label {
  margin-top: var(--space-2);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

/* "font: inherit" makes the boxes use the site's own font and size. */
.login-card input {
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--page);
  color: var(--text);
  font: inherit;
}

.login-card input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.login-card button {
  margin-top: var(--space-4);
  padding: var(--space-3);
  border: 0;
  border-radius: var(--radius-small);
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.login-card button:hover { opacity: 0.9; }

.login-error {
  margin: 0 0 var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-small);
  background: color-mix(in srgb, #c0392b 15%, transparent);
  color: var(--text);
  font-size: 0.9rem;
}


/* ---- 11. Add page (forms) ------------------------------------------------- */

/* One-time messages ("Recipe saved.", "Added Apple."): small glass notices
   floating in the bottom-right corner, stacked when there are several. On
   a phone they span the bottom of the screen. The script in base.html
   fades each one away after a few seconds. */
.toasts {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  z-index: 50;
  display: grid;
  gap: var(--space-2);
  width: min(24rem, calc(100vw - 2 * var(--space-4)));
}

@media (max-width: 30rem) {
  .toasts { left: var(--space-4); right: var(--space-4); bottom: var(--space-4); width: auto; }
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-2) var(--space-3) var(--space-4);
  border: 1px solid var(--glass-edge);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-small);
  background: color-mix(in srgb, var(--navy-800) 88%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 500;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast p { flex: 1; margin: 0; }

.toast-close {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 1.9rem;
  height: 1.9rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.toast-close:hover { background: var(--accent-soft); color: var(--text); }

/* Leaving: it fades and sinks a little. */
.toast.leaving { opacity: 0; transform: translateY(8px); }

.form-card {
  max-width: 44rem;
  padding: var(--space-5);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

@media (min-width: 40rem) {
  .form-card { padding: var(--space-6); }
}

.form-card h2 { font-size: 1.3rem; }

.form-card .intro {
  margin: var(--space-2) 0 var(--space-5);
  color: var(--muted);
  font-size: 0.92rem;
}

/* A fieldset is a labelled group of boxes; the legend is its label, in the
   same small style as the other section labels on the site. */
.form-card fieldset {
  margin: var(--space-5) 0 0;
  padding: 0;
  border: 0;
}

.form-card legend {
  margin-bottom: var(--space-3);
  padding: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field { display: grid; gap: var(--space-1); }

.field label { font-size: 0.85rem; font-weight: 500; }
.field .unit { color: var(--muted); font-weight: 400; }

/* Boxes and the dropdown share one look. "font: inherit" makes them use the
   site's own font and size instead of the browser's. */
.form-card input,
.form-card select {
  width: 100%;
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--page);
  color: var(--text);
  font: inherit;
}

.form-card input:focus,
.form-card select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

/* Amount and unit side by side; the unit gets more room for its words. */
.measure-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: var(--space-3);
  max-width: 28rem;
}

/* The nutrient boxes: as many per row as fit, each at least 9rem wide.
   Four on a wide screen, two on a phone. */
.number-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: var(--space-4) var(--space-3);
}

/* A box that needs fixing gets a red outline and its message under it. */
.has-error input,
.has-error select { border-color: #d0574a; }

.field-error {
  margin: var(--space-1) 0 0;
  color: #e07a6e;
  font-size: 0.82rem;
}

.form-error {
  margin: 0 0 var(--space-4);
  padding: var(--space-3);
  border-radius: var(--radius-small);
  background: color-mix(in srgb, #c0392b 15%, transparent);
  font-size: 0.9rem;
}

.form-card button {
  margin-top: var(--space-6);
  padding: var(--space-3) var(--space-6);
  border: 0;
  border-radius: var(--radius-small);
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.form-card button:hover { opacity: 0.9; }

/* Save, Cancel and Delete in one row. Delete sits at the far right, apart
   from the others, so it is not clicked by accident. */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-5);
  margin-top: var(--space-6);
}

.form-actions button { margin-top: 0; }
.form-actions .secondary { color: var(--muted); }
.form-actions .secondary:hover { color: var(--text); }

.danger-link {
  margin-left: auto;
  color: #e07a6e;
  font-size: 0.9rem;
}

.form-card button.danger { background: #c0574a; color: #fff; }

/* "Used in: ..." on the Edit and Delete pages. */
.usage {
  margin: 0 0 var(--space-5);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-small);
  background: var(--accent-soft);
  font-size: 0.9rem;
}

.usage p { margin: 0 0 var(--space-1); }
.usage ul { margin: 0; padding-left: 1.2rem; }

/* The unit of a food in use: shown, but not a dropdown. */
.locked-unit {
  margin: 0;
  padding: var(--space-3);
  border: 1px dashed var(--line);
  border-radius: var(--radius-small);
  color: var(--muted);
}

.hint {
  margin: var(--space-2) 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

/* Food Items: the introduction and the search box side by side; on a
   phone the search box goes under it. */
.foods-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4) var(--space-6);
  margin-bottom: var(--space-5);
}

.foods-top .intro { flex: 1 1 24rem; margin: 0; }

.search { display: grid; gap: var(--space-1); flex: 0 1 18rem; }
.search label { color: var(--muted); font-size: 0.85rem; font-weight: 500; }

.search input {
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--page);
  color: var(--text);
  font: inherit;
}

.search input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.no-matches { margin-top: var(--space-4); }


/* ---- 12. Editing a day of the plan ------------------------------------------ */

/* The small Edit link beside each day's name on Weekly Meals. */
.day h2 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.day-edit {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.day-edit:hover { color: var(--text); }

/* Today's column on Weekly Meals: a warm amber edge and glow, and the
   day's name in amber with a small glowing dot before it. The page's
   script picks the column, by this device's clock. ", today" after the
   name is for screen readers only, so the header stays one line and the
   meals still line up across the week. */
.today-tag {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.day.today {
  border-color: color-mix(in srgb, var(--calories) 55%, transparent);
  box-shadow: var(--shadow), 0 0 28px color-mix(in srgb, var(--calories) 14%, transparent);
}

.day.today .day-name { color: var(--calories); }

.day.today .day-name::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--calories);
  box-shadow: 0 0 8px var(--calories);
  vertical-align: 0.15em;
}

/* Read by screen readers, but not shown: labels for boxes whose purpose is
   already clear on screen. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.plan-card {
  max-width: 52rem;
  padding: var(--space-5);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

@media (min-width: 40rem) {
  .plan-card { padding: var(--space-6); }
}

.plan-header h2 { font-size: 1.4rem; }
.plan-total { margin: var(--space-1) 0 0; color: var(--muted); font-size: 0.9rem; }
.plan-total .calories-figure { margin-right: 0.35em; }
.plan-total a { color: var(--muted); text-decoration: underline; text-underline-offset: 0.2em; }
.plan-total a:hover { color: var(--text); }

/* Each meal: its label, its entries, then the Add row, with a line
   between meals as on Weekly Meals. */
.plan-meal {
  padding: var(--space-5) 0;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: var(--space-5);
}

.plan-meal:last-child { border-bottom: 0; padding-bottom: 0; }
.plan-meal h3 { margin-bottom: var(--space-2); }

/* One planned entry: name, amount box and Save, calories, Remove. On a
   phone the parts wrap onto a second line. */
.plan-entry {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  padding: 0 0 var(--space-2);
}

.plan-meal:has(.plan-entry) .plan-add { margin-top: 0; }

.entry-name { flex: 1 1 12rem; font-size: 0.92rem; font-weight: 500; }
.entry-kcal { color: var(--muted); font-size: 0.85rem; min-width: 5rem; text-align: right; }

@media (min-width: 40rem) {
  .plan-card .plan-entry .entry-amount {
    box-sizing: border-box;
    flex: 0 0 17.5rem;
    flex-wrap: nowrap;
    justify-content: flex-end;
    padding-right: 2.75rem;
  }
}

.entry-amount,
.plan-add {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.plan-add { flex-wrap: wrap; margin-top: var(--space-3); }

.plan-card input,
.plan-card select,
.today-add input,
.today-add select {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--page);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
}

.entry-amount input,
.plan-add .add-amount { width: 5.5rem; text-align: right; }

.plan-add select { flex: 1 1 14rem; min-width: 0; }

.plan-card input:focus,
.plan-card select:focus,
.today-add input:focus,
.today-add select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.plan-card .unit,
.today-add .unit { color: var(--muted); font-size: 0.85rem; min-width: 4.5rem; }

/* Small buttons: Save and Add filled, Remove quiet. (Also Today's Add.) */
.plan-card button.small,
.today-add button.small {
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-small);
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.plan-card button.small:hover,
.today-add button.small:hover { opacity: 0.9; }

.plan-card button.quiet {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}

.plan-card button.quiet:hover { color: #e07a6e; border-color: #e07a6e; opacity: 1; }


/* ---- 13. Recipe builder --------------------------------------------------- */

/* A page title with a button beside it (Recipes + New recipe). */
.page-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  max-width: 34rem;
}

.page-title h1 { margin-bottom: var(--space-6); }

/* Food Items: the title row spans the whole page, so its button lines up
   with the right edge of the table card below. */
.page-title.wide { max-width: none; }

.button-link {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-small);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.9rem;
  font-weight: 600;
}

.button-link:hover { color: var(--on-accent); opacity: 0.9; }

.recipe-links { display: flex; gap: var(--space-4); }

.form-card textarea,
.plan-card textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--page);
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.form-card textarea:focus,
.plan-card textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.field.wide { margin-bottom: var(--space-4); }
.facts-grid { max-width: 30rem; }

/* The builder: details, ingredients and steps, each a part of one card. */
.builder .plan-card { max-width: 60rem; }

.builder-part {
  padding: var(--space-5) 0;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: var(--space-5);
}

.builder-part h3 { margin-bottom: var(--space-4); }
.builder .facts-form .form-actions { margin-top: var(--space-4); }

/* On the builder the details boxes fill their column, as on New recipe.
   Without this each box keeps the browser's default width (about 20
   letters), which is wider than its column, so Servings, Prep and Cook
   ran into each other. */
.facts-form input { width: 100%; }
.facts-grid .field { min-width: 0; }

.note-box { flex: 1 1 9rem; min-width: 7rem; }
.plan-card .entry-amount { flex-wrap: wrap; flex: 2 1 22rem; }

/* A note is words, not a number, so it lines up on the left. */
.plan-card .entry-amount input.note-box { width: auto; text-align: left; }

.row-buttons { display: flex; gap: var(--space-1); }
.row-buttons form { margin: 0; }

/* On wider screens each ingredient sits on one line, in columns:
   name | amount, unit, note, Save | kcal | Up, Down, Remove.
   On a phone the row still wraps onto two lines. */
@media (min-width: 48rem) {
  .builder .plan-entry {
    display: grid;
    grid-template-columns: minmax(6rem, 1fr) auto 4.5rem auto;
    gap: var(--space-3);
  }
  .builder .plan-card .entry-amount { flex-wrap: nowrap; }
  .builder .plan-card .entry-amount input.note-box { flex: 0 1 9rem; width: 9rem; min-width: 0; }
  .builder .plan-card .unit { min-width: 2.5rem; }
  .builder .entry-kcal { min-width: 0; }
}

.plan-card button.small:disabled { opacity: 0.35; cursor: default; }
.plan-card button.danger-quiet:hover { color: #e07a6e; border-color: #e07a6e; }

.builder-end { padding-top: var(--space-5); }


/* ---- 14. The method: editor and recipe page -------------------------------- */

/* The method as shown on the Recipes page, and inside the editor, look
   the same: what you write is what you get. */
.recipe .method,
.method-editor .ql-editor { line-height: 1.65; }

.recipe .method > :first-child,
.method-editor .ql-editor > :first-child { margin-top: 0; }

.recipe .method p,
.method-editor .ql-editor p { margin: 0 0 var(--space-3); }

.recipe .method h2,
.method-editor .ql-editor h2 { margin: var(--space-5) 0 var(--space-2); font-size: 1.15rem; }

.recipe .method h3,
.method-editor .ql-editor h3 { margin: var(--space-4) 0 var(--space-2); font-size: 1rem; color: var(--muted); }

.recipe .method ol,
.recipe .method ul { margin: 0 0 var(--space-3); padding-left: 1.4rem; }
.recipe .method li { padding-left: var(--space-2); }
.recipe .method li + li,
.method-editor .ql-editor li + li { margin-top: var(--space-3); }
.recipe .method li::marker,
.method-editor .ql-editor li > .ql-ui::before { color: var(--muted); font-weight: 600; }

.method-editor .ql-editor ol { margin-bottom: var(--space-3); }

/* Links in a method: a light sky blue, so they stand out from the text. */
.recipe .method a,
.method-editor .ql-snow a { color: #8EC5E8; }

/* Highlighted words get a little room and soft corners. */
.recipe .method [style*="background"],
.method-editor .ql-editor [style*="background"] { padding: 0 0.2em; border-radius: 4px; }

/* Photos in a written recipe: as wide as the text at most, soft corners.
   Height follows the width, so a photo is never squashed. */
.recipe .method img,
.method-editor .ql-editor img {
  display: block;
  max-width: 100%;
  max-height: 32rem;
  width: auto;
  height: auto;
  margin: var(--space-3) 0;
  border-radius: var(--radius-small);
}

/* A recipe's pictures open in the photo viewer (recipes.html). */
.recipe .method img.opens-viewer { cursor: zoom-in; }
.recipe .method img.opens-viewer:hover { outline: 1px solid var(--accent); }
.recipe .method img.opens-viewer:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The editor: toolbar on top, writing box below, one rounded frame. */
.method-editor { margin-bottom: var(--space-4); }

.method-editor .ql-toolbar.ql-snow {
  /* It stays at the top of the screen while a long method scrolls. */
  position: sticky;
  top: 0;
  z-index: 2;
  padding: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-small) var(--radius-small) 0 0;
  background: var(--navy-800);
  font-family: inherit;
  /* Faded until the editor is in use, then fully there. */
  opacity: 0.55;
  transition: opacity 0.15s;
}

.method-editor:focus-within .ql-toolbar.ql-snow,
.method-editor .ql-toolbar.ql-snow:hover,
.method-editor .ql-toolbar.ql-snow:has(.ql-expanded) { opacity: 1; }

.method-editor .ql-container.ql-snow {
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 var(--radius-small) var(--radius-small);
  background: var(--page);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}

.method-editor:focus-within .ql-container.ql-snow { border-color: var(--accent); }

.method-editor .ql-editor { min-height: 16rem; padding: var(--space-4); }

.method-editor .ql-editor.ql-blank::before {
  left: var(--space-4);
  right: var(--space-4);
  color: var(--muted);
  font-style: normal;
}

/* Toolbar icons: steel blue, turning cream when pointed at or switched on. */
.method-editor .ql-snow .ql-stroke { stroke: var(--muted); }
.method-editor .ql-snow .ql-fill,
.method-editor .ql-snow .ql-stroke.ql-fill { fill: var(--muted); }
.method-editor .ql-snow .ql-picker { color: var(--muted); }

.method-editor .ql-snow.ql-toolbar button:hover .ql-stroke,
.method-editor .ql-snow.ql-toolbar button.ql-active .ql-stroke,
.method-editor .ql-snow.ql-toolbar .ql-picker-label:hover .ql-stroke,
.method-editor .ql-snow.ql-toolbar .ql-picker-label.ql-active .ql-stroke { stroke: var(--text); }

.method-editor .ql-snow.ql-toolbar button:hover .ql-fill,
.method-editor .ql-snow.ql-toolbar button.ql-active .ql-fill,
.method-editor .ql-snow.ql-toolbar .ql-picker-label:hover .ql-fill,
.method-editor .ql-snow.ql-toolbar .ql-picker-label.ql-active .ql-fill { fill: var(--text); }

.method-editor .ql-snow.ql-toolbar button:hover,
.method-editor .ql-snow.ql-toolbar button.ql-active,
.method-editor .ql-snow.ql-toolbar .ql-picker-label:hover,
.method-editor .ql-snow.ql-toolbar .ql-picker-label.ql-active,
.method-editor .ql-snow.ql-toolbar .ql-picker-item:hover,
.method-editor .ql-snow.ql-toolbar .ql-picker-item.ql-selected { color: var(--text); }

.method-editor .ql-snow.ql-toolbar button { border-radius: 6px; }
.method-editor .ql-snow.ql-toolbar button.ql-active { background: var(--accent-soft); }

/* The Text style list: plain names instead of "Heading 2". */
.method-editor .ql-snow .ql-picker.ql-header .ql-picker-label::before,
.method-editor .ql-snow .ql-picker.ql-header .ql-picker-item::before { content: "Normal"; }
.method-editor .ql-snow .ql-picker.ql-header .ql-picker-label[data-value="2"]::before,
.method-editor .ql-snow .ql-picker.ql-header .ql-picker-item[data-value="2"]::before { content: "Heading"; }
.method-editor .ql-snow .ql-picker.ql-header .ql-picker-label[data-value="3"]::before,
.method-editor .ql-snow .ql-picker.ql-header .ql-picker-item[data-value="3"]::before { content: "Subheading"; }
.method-editor .ql-snow .ql-picker.ql-header .ql-picker-item[data-value="2"]::before { font-size: 1.15rem; }
.method-editor .ql-snow .ql-picker.ql-header .ql-picker-item[data-value="3"]::before { font-size: 1rem; }

/* Drop-down lists (text style, colours) in navy. */
.method-editor .ql-snow .ql-picker-options {
  background: var(--navy-800);
  border-radius: var(--radius-small);
  box-shadow: var(--shadow);
}

.method-editor .ql-toolbar.ql-snow .ql-picker.ql-expanded .ql-picker-label,
.method-editor .ql-toolbar.ql-snow .ql-picker.ql-expanded .ql-picker-options { border-color: var(--line); }

/* Colour swatches: a little bigger, with soft corners. "Default" and
   "No highlight" have no colour of their own, so they get an outline. */
/* Four swatches to a row: each is 20px wide plus 3px margin on each side
   and a 1px border on each side = 28px. */
.method-editor .ql-snow .ql-color-picker .ql-picker-options {
  width: calc(4 * 28px + 2 * var(--space-2));
  padding: var(--space-2);
}
.method-editor .ql-snow .ql-color-picker .ql-picker-item {
  width: 20px;
  height: 20px;
  margin: 3px;
  border: 1px solid transparent;
  border-radius: 5px;
}
.method-editor .ql-snow .ql-color-picker .ql-picker-item:not([data-value]) { border-color: var(--muted); }
.method-editor .ql-snow .ql-color-picker .ql-picker-item:hover,
.method-editor .ql-snow .ql-color-picker .ql-picker-item.ql-selected { border-color: var(--text); }

/* The small box for typing a link's address. */
.method-editor .ql-snow .ql-tooltip {
  background: var(--navy-800);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  box-shadow: var(--shadow);
}

.method-editor .ql-snow .ql-tooltip input[type="text"] {
  background: var(--page);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.method-status { color: var(--muted); font-size: 0.85rem; }

/* Under "Add a food item…": what the last ingredient change did, or what
   needs fixing (in red). Empty, it takes no room. */
.ingredients-status { margin: var(--space-2) 0 0; color: var(--muted); font-size: 0.85rem; }
.ingredients-status:empty { display: none; }
.ingredients-status.problem { color: #e07a6e; }


/* ---- 15. Label photos --------------------------------------------------------- */

/* Thumbnails in a grid: as many as fit, each at least 9rem wide. Each one
   shows the whole label (contain), on a dark tile. */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: var(--space-4);
  margin: 0 0 var(--space-4);
  padding: 0;
  list-style: none;
}

.photo-grid li { display: grid; gap: var(--space-2); }

.photo-grid img {
  display: block;
  width: 100%;
  height: 11rem;
  object-fit: contain;
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
}

.photo-grid a:hover img { border-color: var(--accent); }

/* "Delete" under each photo on Edit: a tick box dressed as a quiet button.
   Ticked, the photo fades and the button turns red and offers Undo; the
   photo is deleted when the form is saved. */
.photo-upload .photo-remove {
  position: relative;
  display: flex;
  justify-content: center;
  margin: 0;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
}

.photo-remove input { position: absolute; opacity: 0; pointer-events: none; }
.photo-remove:hover,
.photo-remove:has(input:checked) { color: #e07a6e; border-color: #e07a6e; }
.photo-remove:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.photo-remove .remove-on,
.photo-remove:has(input:checked) .remove-off { display: none; }
.photo-remove:has(input:checked) .remove-on { display: inline; }
.photo-grid li:has(input:checked) img { opacity: 0.3; }

/* A quiet Delete under each photo, turning red when pointed at. */
.form-card button.quiet-button {
  margin: 0;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.form-card button.quiet-button:hover { color: #e07a6e; border-color: #e07a6e; opacity: 1; }

/* "Add photos": the file chooser and Upload side by side. */
.photo-upload label { display: block; margin-bottom: var(--space-2); font-size: 0.85rem; font-weight: 500; }

.photo-upload-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.photo-upload-row input[type="file"] { flex: 1 1 16rem; width: auto; cursor: pointer; }
.photo-upload-row input[type="file"]::file-selector-button {
  margin-right: var(--space-3);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--accent-soft);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.photo-upload-row button { margin-top: 0; }
.photo-upload .hint.field-error { color: #e07a6e; }

/* Food Items: the small camera and count after a name with label photos. */
.photo-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  margin-left: var(--space-2);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  vertical-align: middle;
}

.photo-badge:hover { color: var(--text); }

/* The lightbox on Food Items: a navy window over the page, which is
   darkened and softly blurred behind it. The photo is as big as the
   screen allows, never cropped. */
.lightbox {
  width: min(94vw, 64rem);
  max-height: 94vh;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--navy-800);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.lightbox::backdrop {
  background: rgb(13 19 33 / 0.82);
  backdrop-filter: blur(3px);
}

.lightbox-top {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--line);
}

.lightbox-title { flex: 1; margin: 0; font-weight: 600; }
.lightbox-count { margin-left: var(--space-2); color: var(--muted); font-weight: 400; font-size: 0.85rem; }

.lightbox-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  white-space: nowrap;
  cursor: pointer;
}
.lightbox-link:hover { color: var(--text); }
.lightbox-link[hidden] { display: none; }

.lightbox-close {
  width: 2.2rem;
  height: 2.2rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox-close:hover { background: var(--accent-soft); color: var(--text); }

.lightbox-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: var(--page);
}

.lightbox-stage img {
  display: block;
  max-width: 100%;
  max-height: calc(94vh - 6rem);
  object-fit: contain;
  border-radius: var(--radius-small);
  cursor: zoom-in;
}

/* Full size: the photo at its real size; the area around it scrolls (or
   drags, on a phone). The arrows step aside until it is fitted again. */
.lightbox.zoomed .lightbox-stage {
  display: block;
  height: calc(94vh - 4rem);
  overflow: auto;
  padding: 0;
}

.lightbox.zoomed .lightbox-stage img {
  max-width: none;
  max-height: none;
  margin: 0 auto;
  border-radius: 0;
  cursor: zoom-out;
}

.lightbox.zoomed .lightbox-nav { display: none; }

/* Round arrow buttons over the photo's left and right edges. */
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgb(29 45 68 / 0.85);
  color: var(--text);
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox-nav:hover { background: var(--steel-600); }
.lightbox-nav[hidden] { display: none; }
.lightbox-prev { left: var(--space-3); }
.lightbox-next { right: var(--space-3); }

/* On a narrow phone the top bar tightens up so everything fits. */
@media (max-width: 30rem) {
  .lightbox-top { gap: var(--space-3); padding-left: var(--space-4); }
  .lightbox-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}


/* "×2" next to a meal that is eaten twice over. */
.portions {
  margin-left: var(--space-1);
  color: var(--muted);
  font-size: 0.85em;
  white-space: nowrap;
}


/* ---- 16. Motion: soft page changes, hovers and pop-ups ---------------------- */
/* Small, quick movements so the site feels smooth rather than stiff.
   Colour changes (hovers, focus) ease in everywhere. Anything that moves
   only happens when the device has not asked for less motion: phones and
   computers have a "reduce motion" setting, and it is respected here. */

/* Hovers and focus: colours, backgrounds, borders and shadows ease in over
   0.18 s instead of snapping. */
a,
button,
input,
select,
textarea,
.ql-picker-label {
  transition: color 0.18s ease, background-color 0.18s ease, border-color 0.18s ease,
              box-shadow 0.18s ease, opacity 0.18s ease, outline-color 0.18s ease;
}

/* The lightbox photo fades while the next one loads (set by the script). */
.lightbox-stage img { transition: opacity 0.2s ease; }
.lightbox-stage img.changing { opacity: 0; }

@media (prefers-reduced-motion: no-preference) {

  /* Moving between pages: the old page fades out and the new one fades
     in, while the top bar stays put. The browser does this itself (Chrome,
     Edge and Safari); others simply change page as before. */
  @view-transition { navigation: auto; }
  .site-header { view-transition-name: site-header; }
  ::view-transition-old(root) { animation: 0.14s ease-in both fade-out; }
  ::view-transition-new(root) { animation: 0.24s ease-out both fade-in; }

  /* A page's content rises gently into place as it appears. "backwards"
     (not "both"): once it has risen, nothing is left on <main>, so the
     sticky editor toolbar and everything else behave as before.
     It only moves, it doesn't fade: while something is fading, browsers
     switch off the frosted-glass blur inside it, which made the cards
     flash clear for a moment. (The page change itself still fades.) */
  main { animation: rise-in 0.35s cubic-bezier(0.2, 0.7, 0.2, 1) backwards; }

  /* Notices such as "Recipe saved." float up into place; when several
     arrive together, each follows the one before by a moment. */
  .toast { animation: toast-in 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) 0.15s backwards; }
  .toast:nth-child(2) { animation-delay: 0.25s; }
  .toast:nth-child(n + 3) { animation-delay: 0.35s; }

  /* Buttons dip a pixel when pressed, like a real button. */
  button:not(:disabled):not(.lightbox-nav):active,
  .button-link:active { transform: translateY(1px); }
  button,
  .button-link { transition-property: color, background-color, border-color, box-shadow, opacity, transform; }
  .lightbox-nav:active { transform: translateY(-50%) scale(0.94); }

  /* The lightbox: opens by fading in and growing from just smaller, and
     closes the same way in reverse; the dark backdrop fades with it.
     "@starting-style" is where it starts from when opening. */
  .lightbox {
    transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.2, 0.7, 0.2, 1),
                overlay 0.22s allow-discrete, display 0.22s allow-discrete;
  }
  .lightbox:not([open]) { opacity: 0; transform: scale(0.97) translateY(6px); }
  @starting-style {
    .lightbox[open] { opacity: 0; transform: scale(0.97) translateY(6px); }
  }

  .lightbox::backdrop {
    transition: background-color 0.22s ease, backdrop-filter 0.22s ease,
                overlay 0.22s allow-discrete, display 0.22s allow-discrete;
  }
  .lightbox:not([open])::backdrop { background-color: transparent; backdrop-filter: blur(0); }
  @starting-style {
    .lightbox[open]::backdrop { background-color: transparent; backdrop-filter: blur(0); }
  }
}

@keyframes fade-out { to { opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise-in { from { transform: translateY(6px); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.98); } }


/* ---- 17. Glass: frosted cards and top bar ---------------------------------- */
/* Every main card, and the top bar, is frosted glass: half-see-through
   navy that blurs whatever is behind it (the glows in the background),
   with a thin light edge. Only the outer cards are glass; what is inside
   them is not blurred again, which keeps scrolling smooth on a phone. */
.site-header,
.day,
.recipe-list,
.recipe,
.calories-card,
.foods-card,
.login-card,
.form-card,
.plan-card {
  border-color: var(--glass-edge);
  -webkit-backdrop-filter: var(--glass-blur);   /* Safari's name for it */
  backdrop-filter: var(--glass-blur);
}

.site-header { background: var(--header); }

/* The nutrition tables keep a darker, more solid backing, so their
   numbers always sit on a calm surface rather than on moving colour. */
.table-scroll { background: color-mix(in srgb, var(--navy-950) 45%, transparent); }

/* The lightbox: glass too, a little more solid since a photo sits on it. */
.lightbox {
  background: color-mix(in srgb, var(--navy-800) 78%, transparent);
  border-color: var(--glass-edge);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}


/* ---- 18. Charts: macro split ----------------------------------------------- */

/* The macro split: one thin rounded bar in three colours, with a small
   gap between the parts, and a key under it. */
.macro-split { margin-top: var(--space-4); max-width: 30rem; }

.macro-bar {
  display: flex;
  gap: 2px;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--steel-600) 30%, transparent);
}

.macro-bar span { display: block; height: 100%; }

.macro-protein { background: var(--protein); }
.macro-carbs { background: var(--carbs); }
.macro-fat { background: var(--fat); }

.macro-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-5);
  margin: var(--space-2) 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.82rem;
}

.macro-legend li { display: flex; align-items: center; gap: var(--space-2); }
.macro-legend strong { color: var(--text); font-weight: 600; }
.macro-legend .grams { font-size: 0.78rem; }
.macro-dot { width: 8px; height: 8px; border-radius: 50%; }

/* Total Calories: the macro split at a glance, above the table. */
.day-overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  column-gap: var(--space-7);
  row-gap: var(--space-5);
  margin-bottom: var(--space-6);
}

@media (min-width: 44rem) {
  .day-overview:has(.overview-panel + .overview-panel) {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.overview-panel {
  display: grid;
  grid-row: span 3;
  grid-template-rows: subgrid;
  row-gap: var(--space-2);
  align-content: start;
}

/* Top row: "CALORIES ........ 2,208 / 2,200 kcal". */
.overview-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-1) var(--space-3);
  margin: 0;
  align-self: end;
  color: var(--muted);
  font-size: 0.85rem;
}

.overview-label {
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.overview-figure strong {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1;
}

/* Middle row: the bar. Both the same: 8px, rounded, on the same track. */
.overview-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--steel-600) 30%, transparent);
}

/* Bottom row: the macro key, in the same small type. */
.overview-foot {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.day-overview .macro-legend { margin: 0; column-gap: var(--space-4); }
.day-overview .macro-legend li { gap: 0.3em; }
.day-overview .macro-dot { margin-right: 0.15em; }

/* The bars grow in from the left as the page appears. */
@media (prefers-reduced-motion: no-preference) {
  .macro-bar span {
    transform-origin: left center;
    animation: grow-in 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) 0.1s backwards;
  }
}

@keyframes grow-in { from { transform: scaleX(0); } }


/* ---- 19. Icons ------------------------------------------------------------- */
/* The line icons from templates/_icons.html. The hidden set at the top of
   each page takes no space; each icon shown is drawn in the colour of the
   text around it, a little bigger than a letter, with rounded 1.8px lines. */
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 1.05em;
  height: 1.05em;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.17em;
}

/* An icon and its word, side by side with a small gap. */
.site-header nav a,
.site-header .logout,
.button-link,
.recipe-links a,
.day-edit,
.danger-link,
.lightbox-link,
.photo-upload label,
.photo-upload-row button {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

/* The menu's icons are a touch quieter than its words. */
.site-header nav .icon { opacity: 0.85; }

/* On a narrow phone the menu already runs onto two lines; its icons step
   aside there to keep it compact. */
@media (max-width: 30rem) {
  .site-header nav .icon { display: none; }
}

.day-edit .icon { width: 0.95em; height: 0.95em; }
.photo-badge .icon { width: 14px; height: 14px; }

/* Buttons that are only an icon: centred in their round or square shape. */
.lightbox-close,
.lightbox-nav,
.row-buttons button {
  display: inline-grid;
  place-items: center;
}

.lightbox-close .icon { width: 1.2rem; height: 1.2rem; }
.lightbox-nav .icon { width: 1.35rem; height: 1.35rem; }
.row-buttons .icon { width: 1rem; height: 1rem; }


/* ---- 20. The warm accent ------------------------------------------------- */
/* Amber is the one warm colour on a blue-and-cream site, so it is kept for
   the figures the eye should land on first: a recipe's calories per
   serving, its total and per-serving calorie rows, a day's calorie total,
   the planned calories when editing a day, and today's column on Weekly
   Meals (section 12). Everything else stays blue and cream. */
.calories-figure { color: var(--calories); }

/* The recipe list's kcal: amber softened towards the quiet label colour,
   since every row has one. */
.recipe-list .kcal { color: color-mix(in srgb, var(--calories) 70%, var(--muted)); }


/* ---- 21. Phone layout: bottom menu and Food Items cards -------------------- */
/* Two things only exist on a phone (up to 40rem, 640px, wide): the menu as
   a bar along the bottom, and Food Items as cards. On a wider screen they
   are hidden and everything is as before. */
.tab-bar,
.food-cards { display: none; }

/* Phones with rounded corners or a notch: keep the content clear of them
   (the "safe area"); on other screens these come to the usual spacing. */
.site-header .inner,
main {
  padding-left: max(var(--space-5), env(safe-area-inset-left));
  padding-right: max(var(--space-5), env(safe-area-inset-right));
}

@media (max-width: 40rem) {
  /* The top bar keeps the name and Log out; the menu moves to the bottom.
     (".site-header" in front so this wins over the menu's own layout.) */
  .site-header .top-menu { display: none; }

  .tab-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));   /* Today, Shopping, Recipes, Plan */
    gap: var(--space-1);
    /* Room under the buttons for the iPhone's home bar. */
    padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    border-top: 1px solid var(--glass-edge);
    background: color-mix(in srgb, var(--navy-800) 86%, transparent);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    box-shadow: 0 -10px 30px rgb(0 0 0 / 0.35);
    /* Stays put while the page changes, like the top bar. */
    view-transition-name: tab-bar;
  }

  /* Each button: the icon over its name; the page you are on is filled in. */
  .tab-bar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 7px 2px 6px;
    border-radius: 12px;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
  }

  .tab-bar a:hover { color: var(--text); }
  .tab-bar a[aria-current="page"] { background: var(--accent-soft); color: var(--text); }
  .tab-bar .icon { width: 1.4rem; height: 1.4rem; }

  /* Keep the end of every page clear of the bar, and notices just above it. */
  main { padding-bottom: calc(var(--space-8) + 4.5rem + env(safe-area-inset-bottom)); }
  .toasts { bottom: calc(5.25rem + env(safe-area-inset-bottom)); }

  /* Food Items: cards instead of the wide tables. */
  .foods-card .nutrition-tables { display: none; }

  .food-cards {
    display: grid;
    gap: var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .food-card {
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    background: color-mix(in srgb, var(--navy-950) 45%, transparent);
    scroll-margin: var(--space-7);
  }

  .food-card[hidden] { display: none; }

  /* Arrived at from a recipe's link: highlighted, as the table row would be. */
  .food-card.targeted { border-color: var(--accent); background: var(--accent-soft); }

  .food-card-top {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
  }

  .food-card-name { font-weight: 600; }
  .food-card-top .photo-badge { margin-left: 0; }
  .food-card-qty { margin-left: auto; color: var(--muted); font-size: 0.8rem; white-space: nowrap; }

  /* Calories and the macros in one row of four; the other nutrients in a
     smaller row of four under a thin line. */
  .food-card-main,
  .food-card-more {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-2);
    margin: 0;
  }

  /* The label carries the unit, on a small second line under it, so each
     number stands on its own and every column stays narrow enough to fit
     four across a phone. */
  .food-card dt { color: var(--muted); font-size: 0.68rem; line-height: 1.25; }
  .food-card dt .unit { display: block; }
  .food-card dd { margin: 2px 0 0; font-variant-numeric: tabular-nums; white-space: nowrap; }

  /* A little less padding around and inside the cards, for wider columns. */
  .foods-card { padding: var(--space-4); }
  .food-card { padding: var(--space-3); }
  .food-card-main dd { font-size: 0.95rem; font-weight: 600; }

  .food-card-more {
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid var(--line);
  }

  .food-card-more dd { font-size: 0.8rem; }
  .food-card dt .unit { opacity: 0.7; }
}


/* ---- 22. Colours: sections, meals, macros, title stripe, buttons ----------- */
/* The site's colour comes from one small family of accents, and each colour
   means the same thing everywhere:
     sky     protein
     green   carbs, and the Food Items icon
     lilac   fat, and the Recipes icon
     amber   calories, today, and the Total Calories icon
     peach   the meals of the day, and the Weekly Meals icon
   The dark navy base and the glass stay as they are; the colour sits on
   top, in small, clear doses. */

/* The menu: each section's icon has its own colour. The page you are on
   is highlighted the same way for every section (the usual soft steel
   pill, from section 3). */
.menu-week { --section: var(--peach); }
.menu-recipes { --section: var(--fat); }
.menu-foods { --section: var(--carbs); }
.menu-calories { --section: var(--calories); }
.menu-shopping { --section: var(--protein); }

.top-menu a .icon,
.tab-bar a .icon { color: var(--section); opacity: 1; }

/* The meals of the day: all labels in one warm colour (peach) on Weekly
   Meals, editing a day and Total Calories. Change --meal here to use
   another colour for all of them. */
.meal,
.plan-meal,
.day-calories .meal-label { --meal: var(--peach); }

.meal h3,
.plan-meal h3,
.day-calories .meal-label th {
  color: color-mix(in srgb, var(--meal) 85%, var(--muted));
}


/* A recipe's Per serving boxes: each tinted in its macro's colour, with a
   coloured line along its top, matching the bar under them. */
.fact-calories { --tint: var(--calories); }
.fact-protein { --tint: var(--protein); }
.fact-carbs { --tint: var(--carbs); }
.fact-fat { --tint: var(--fat); }

.facts .fact-calories,
.facts .fact-protein,
.facts .fact-carbs,
.facts .fact-fat {
  background: color-mix(in srgb, var(--tint) 13%, var(--accent-soft));
  box-shadow: inset 0 2px 0 color-mix(in srgb, var(--tint) 75%, transparent);
}

.facts .fact-calories dt,
.facts .fact-protein dt,
.facts .fact-carbs dt,
.facts .fact-fat dt { color: color-mix(in srgb, var(--tint) 80%, var(--muted)); }

/* Column titles in the nutrition tables, and labels on the phone cards:
   protein, carbs, fat and calories each in their colour. */
.col-protein_g { --tint: var(--protein); }
.col-carbs_g { --tint: var(--carbs); }
.col-fat_g { --tint: var(--fat); }
.col-calories { --tint: var(--calories); }

.nutrition th.col-protein_g,
.nutrition th.col-carbs_g,
.nutrition th.col-fat_g,
.nutrition th.col-calories,
.food-card .col-protein_g dt,
.food-card .col-carbs_g dt,
.food-card .col-fat_g dt,
.food-card .col-calories dt { color: color-mix(in srgb, var(--tint) 85%, var(--muted)); }

/* The main buttons (New recipe, Add food item, Save changes, Upload, Log
   in): a soft gradient from sky to lilac instead of flat steel, with a
   gentle glow when pointed at. Delete and the quiet buttons keep their own
   look. */
.button-link,
.form-card button:not(.danger):not(.quiet-button),
.login-card button {
  /* The gradient is twice the button's width (sky, lilac, sky again), so
     sliding it along makes the colours flow without a visible edge. */
  background: linear-gradient(135deg, var(--protein) 0%, var(--fat) 50%, var(--protein) 100%);
  background-size: 200% 100%;
  background-position: 0% 50%;
  color: var(--on-accent);
}

.button-link:hover,
.form-card button:not(.danger):not(.quiet-button):hover,
.login-card button:hover {
  opacity: 1;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--fat) 18%, transparent);
}

/* The sleek part: pointing at one of these buttons makes its gradient
   glide slowly across and lifts it by a pixel; pressing it settles it
   back. Skipped when the device asks for less motion. */
@media (prefers-reduced-motion: no-preference) {
  .button-link,
  .form-card button:not(.danger):not(.quiet-button),
  .login-card button {
    transition: background-position 0.6s cubic-bezier(0.2, 0.7, 0.2, 1),
                box-shadow 0.3s ease, transform 1s cubic-bezier(0.2, 0.7, 0.2, 1);
  }

  .button-link:hover,
  .form-card button:not(.danger):not(.quiet-button):hover,
  .login-card button:hover {
    background-position: 100% 50%;
    transform: translateY(-1px);
  }

  .button-link:active,
  .form-card button:not(.danger):not(.quiet-button):active,
  .login-card button:active { transform: translateY(0); }
}

/* Notices ("Recipe saved."): the same gradient along their left edge. */
.toast { border-left: 0; position: relative; overflow: hidden; }
.toast::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--protein), var(--fat));
}


/* One size for every box and main button on the site, taken from Edit the
   plan: boxes with 8px above and below, 12px at the sides, and text at
   0.92 of the normal size. Before, the Add / Edit food item forms, the
   search box and the login page had larger boxes, which looked uneven. */
.form-card input,
.form-card select,
.form-card textarea,
.plan-card textarea,
.login-card input,
.search input {
  padding: var(--space-2) var(--space-3);
  font-size: 0.92rem;
}

/* The main buttons on forms (Save, Delete, Upload, Log in): the same size
   as New recipe and Add food item. */
.form-card button:not(.quiet-button),
.login-card button {
  padding: var(--space-2) var(--space-4);
  font-size: 0.9rem;
}

/* Drop-down lists (unit, food item, recipe pickers): the browser's own
   arrow sits tight against the right edge, so it is replaced with the
   site's small chevron, in the muted label colour, 14px in from the edge,
   with room kept for it so the text never runs underneath. */
select:not([multiple]) {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 2.6rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23748CAB' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 14px 14px;
  cursor: pointer;
}


/* Boxes you type in, drop-down lists and outlined buttons keep a clearer
   edge than the faint lines around cards and tables: each of them uses
   --line-box as its own --line. (".method-editor" covers the recipe
   editor's toolbar and writing box.) */
input,
select,
textarea,
button,
.day-picker a,
.quiet-pill,
.photo-remove,
.photo-grid img,
.locked-unit,
.method-editor,
.lightbox-nav { --line: var(--line-box); }


/* ---- 23. Shopping list and stores ------------------------------------------ */

/* "Start fresh" beside the title: a quiet outlined button. */
#start-fresh { margin: 0; }
#start-fresh[hidden] { display: none; }
.quiet-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.quiet-pill:hover { color: var(--text); border-color: var(--accent); }

.shop-intro {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2) var(--space-4);
  margin: 0 0 var(--space-5);
  color: var(--muted);
}
.shop-progress { margin-left: auto; font-variant-numeric: tabular-nums; }
.shop-progress strong { color: var(--text); }

/* One glass card per store, as many side by side as fit. */
/* The store cards. The store with the most items (shop-tallest) has its own
   column on the right; the others (shop-rest) flow down the columns on the
   left like a newspaper, each card straight under the one above, so no
   short card leaves a gap next to a long one. Three columns on a wide
   screen (two on the left), two on a medium one (one on the left), and
   everything stacked on a phone, with the tallest card last. */
.shop-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}

.shop-rest { columns: 1; column-gap: var(--space-5); }
.shop-rest .shop-card { break-inside: avoid; margin-bottom: var(--space-5); }
.shop-rest .shop-card:last-child { margin-bottom: 0; }

@media (min-width: 44rem) {
  .shop-grid:not(.single) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

@media (min-width: 70rem) {
  .shop-grid:not(.single) { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
  .shop-rest { columns: 2; }
  /* In two columns, the last card may land at the bottom of either one, so
     every card keeps its space below; the columns end level anyway. */
  .shop-rest .shop-card:last-child { margin-bottom: var(--space-5); }
}

.shop-grid.single { max-width: 34rem; }

.shop-card {
  padding: var(--space-4) var(--space-5) var(--space-2);
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}

.shop-card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}
.shop-card-top h2 { font-size: 1.15rem; }
.shop-count { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }

.shop-list { margin: 0; padding: 0; list-style: none; }
.shop-item + .shop-item { border-top: 1px solid var(--line); }
.tick-form { margin: 0; }

/* A whole row is the tick button: box | name | amount. */
.tick {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.tick:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

.tick-box {
  display: grid;
  place-items: center;
  /* 16px since 2026-11-15 (20px before; all tick boxes made 20% smaller). */
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--muted);
  border-radius: 5px;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
/* The tick inside: 70% of its box, whatever the box's size. */
.tick-box svg {
  width: 70%;
  height: 70%;
  fill: none;
  stroke: var(--on-accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.tick:hover .tick-box { border-color: var(--text); }

.shop-name { font-size: 0.95rem; font-weight: 500; }
.shop-amount { justify-self: end; font-size: 0.9rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Ticked: a green box with a tick, and the name and amount crossed out. */
.shop-item.ticked .tick-box { border-color: var(--carbs); background: var(--carbs); }
.shop-item.ticked .tick-box svg { opacity: 1; transform: none; }
.shop-item.ticked .shop-name,
.shop-item.ticked .shop-amount {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--muted) 70%, transparent);
}

/* Pantry staples: a quiet reminder under the cards. */
.shop-pantry { max-width: 60rem; margin-top: var(--space-6); }
.shop-pantry p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.shop-pantry .footnote { margin-top: var(--space-2); font-size: 0.8rem; }
.shop-amount-quiet { opacity: 0.75; font-size: 0.85em; }

/* Your stores: a small card to add, rename or remove them. */
.stores-card { max-width: 34rem; margin-top: var(--space-7); }
.stores-card h2 { margin-bottom: var(--space-4); }
.store-list { display: grid; gap: var(--space-2); margin: 0 0 var(--space-4); padding: 0; list-style: none; }
.store-list li { display: flex; align-items: center; gap: var(--space-2); }
.store-rename { display: flex; flex: 1; gap: var(--space-2); margin: 0; }
.store-rename input { flex: 1; }
.store-delete { margin: 0; }
.store-delete .icon { width: 1rem; height: 1rem; }
.form-card .store-list button.quiet-button { padding: var(--space-2) var(--space-3); }
.store-add { display: flex; gap: var(--space-2); }
.store-add input { flex: 1; }
.form-card .store-add button { margin-top: 0; white-space: nowrap; display: inline-flex; align-items: center; gap: 0.4em; }

/* On a food's Edit page: the Store list and the new store's name side by
   side, and the pantry tick under them. */
.shop-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-3); }
.new-store[hidden] { display: none; }
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-top: var(--space-4);
  font-size: 0.92rem;
  cursor: pointer;
}
.form-card .check-row input[type="checkbox"] {
  flex: none;
  width: 16px;     /* the same as the Shopping list's boxes (18px before 2026-11-15) */
  height: 16px;
  margin: 3px 0 0;
  padding: 0;
  accent-color: var(--carbs);
}
.hint-inline { color: var(--muted); font-size: 0.85em; }

/* A button asking "Remove?" after its first click (see base.html): red,
   so the second click is clearly the one that deletes. */
button.confirming,
.form-card button.quiet-button.confirming {
  border-color: #e07a6e;
  background: color-mix(in srgb, #e07a6e 16%, transparent);
  color: #f0a59b;
  white-space: nowrap;
}

/* ---- 24. Account button and Settings ---------------------------------------- */

/* The top bar sits above the page, so the account menu that drops out of
   it opens over the cards instead of behind them. */
.site-header { position: relative; z-index: 30; }

.account { position: relative; margin-left: auto; }

/* The avatar: your initial on the sky-to-lilac gradient of the main
   buttons. A soft ring shows when pointed at, when its menu is open, and
   while on Settings. */
.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--protein), var(--fat));
  color: var(--on-accent);
  font-size: 0.95rem;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
  user-select: none;
  transition: box-shadow 0.2s ease;
}
.avatar::-webkit-details-marker { display: none; }
.avatar::marker { content: ""; }
.avatar:hover,
.account[open] .avatar,
.avatar.current {
  box-shadow: 0 0 0 2px var(--page), 0 0 0 4px color-mix(in srgb, var(--fat) 70%, transparent);
}
.avatar:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* The menu under it. */
.account-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 60;
  min-width: 13rem;
  padding: var(--space-2);
  border: 1px solid var(--glass-edge);
  border-radius: 12px;
  background: color-mix(in srgb, var(--navy-800) 94%, transparent);
  box-shadow: var(--shadow);
}

.account-name { margin: 0; padding: var(--space-2) var(--space-3); color: var(--muted); font-size: 0.8rem; }
.account-name strong { color: var(--text); font-weight: 600; }

.account-menu a {
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: var(--space-2) var(--space-3);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.92rem;
}
.account-menu a:hover,
.account-menu a[aria-current="page"] { background: var(--accent-soft); color: var(--text); }
.account-menu .icon { color: var(--muted); }
.account-menu hr { margin: var(--space-1) 0; border: 0; border-top: 1px solid var(--line); }

@media (prefers-reduced-motion: no-preference) {
  .account[open] .account-menu { animation: menu-in 0.18s cubic-bezier(0.2, 0.7, 0.2, 1); }
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }

/* Settings: its cards side by side on a wide screen, stacked on a phone. */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  gap: var(--space-5);
  align-items: start;
  max-width: 60rem;
}
.settings-grid .form-card,
.settings-grid .stores-card { max-width: none; margin-top: 0; }

/* Wide screen: password and stores sit side by side. */
@media (min-width: 50rem) {
  .settings-grid {
    grid-template-columns: 1fr 1fr;
  }
  .settings-grid #password { grid-column: 1; grid-row: 1; }
  .settings-grid #stores   { grid-column: 2; grid-row: 1; }
}
.settings-grid .form-card h2 { margin-bottom: 0; }

.store-foods { color: var(--muted); font-size: 0.78rem; white-space: nowrap; align-self: center; }

/* Change password: each label over its box, the button at the end. */
.password-form { display: flex; flex-direction: column; gap: var(--space-2); }
.password-form label { margin-top: var(--space-2); }
.password-form input { width: 100%; }
.password-form .hint { margin: var(--space-1) 0 0; }
.password-form button { align-self: flex-start; display: inline-flex; align-items: center; gap: 0.4em; }

/* Today: a small line pointing to the detailed calorie view. */
.target-link {
  margin: var(--space-5) 0 0;
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}
.target-link a { color: var(--protein); }

/* ---- 25. Today, and the checks on Weekly Meals ------------------------------- */

/* Today in the menu: the sun, in the calories amber. */
.menu-today { --section: var(--calories); }

/* The title, the date under it, and the arrows to the day before and after. */
.today-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3) var(--space-4);
  max-width: 46rem;
  margin-bottom: var(--space-5);
}

.today-head h1 { margin: 0; }
.today-date { margin: var(--space-6) 0 0; color: var(--muted); }

.today-nav { display: flex; align-items: center; gap: var(--space-2); }

.today-nav a {
  display: inline-grid;
  place-items: center;
  min-width: 2.4rem;
  height: 2.4rem;
  padding: 0 var(--space-3);
  border: 1px solid var(--line-box);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.today-nav a:hover { color: var(--text); }
.today-nav .icon { width: 1.1rem; height: 1.1rem; }

/* The card: the four bars on top, then the day's meals. Not wider than it
   needs to be, so it reads well on a computer too. */
.today-card {
  max-width: 46rem;
  padding: var(--space-5);
  background: var(--card);
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}

@media (min-width: 40rem) {
  .today-card { padding: var(--space-6); }
}

.today-overview { margin-bottom: var(--space-3); }

/* Each meal: its label, then its planned items, a thin line between. */
.today-meal { padding-top: var(--space-4); margin-top: var(--space-4); border-top: 1px solid var(--line); }
.today-meal h3 { margin-bottom: 0; color: color-mix(in srgb, var(--peach) 85%, var(--muted)); }

.today-list { margin: 0; padding: 0; list-style: none; }

/* One item: the tick button (box | name | numbers) and, for a recipe, a
   small book that opens it. A big row, easy to hit with a thumb. */
.today-item { display: flex; align-items: center; gap: var(--space-2); }
.today-item + .today-item { border-top: 1px solid var(--line); }
.today-item .tick-form { flex: 1; min-width: 0; }

.today-tick { padding: var(--space-3) 0; }
.today-tick .tick-box { width: 18px; height: 18px; }   /* 22px before 2026-11-15 */
.today-name { font-weight: 500; }

.today-numbers {
  display: grid;
  justify-items: end;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  white-space: nowrap;
}

.today-protein { color: var(--muted); font-size: 0.78rem; }

/* Eaten: a green box with a tick, and the name and numbers quieter. */
.today-item.ticked .tick-box { border-color: var(--carbs); background: var(--carbs); }
.today-item.ticked .tick-box svg { opacity: 1; transform: none; }
.today-item.ticked .today-name,
.today-item.ticked .today-kcal { color: var(--muted); }

.today-recipe {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-small);
  color: var(--fat);
}

.today-recipe:hover { background: var(--accent-soft); color: var(--text); }
.today-recipe .icon { width: 1.15rem; height: 1.15rem; }

.today-card .target-link a { color: var(--protein); }

/* Each day: its planned calories and protein under its name. The whole
   block opens the day on Total Calories. */
.day-check {
  display: grid;
  gap: 2px;
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

.day-check:hover { background: var(--accent-soft); color: var(--text); }

.day-check-row { display: flex; align-items: baseline; gap: 0.35em; white-space: nowrap; }

/* ---- 26. Cooking view ----------------------------------------------------------- */
/* A recipe for the kitchen: the same text sizes as the rest of the site
   (since 2026-11-16; bigger before), big rows to tap with a wet or floury
   finger, the ingredients and the method side by side on a wide
   screen (the ingredients stay in view while the method scrolls), one
   under the other on a phone. */
.cook { max-width: 70rem; }

.cook-back {
  display: inline-flex;
  align-items: center;
  gap: 0.2em;
  margin-bottom: var(--space-2);
  color: var(--muted);
  font-size: 0.9rem;
}

.cook-back:hover { color: var(--text); }
/* 23px between the title and the servings: the same as between a page
   title and the Weekly Meals | Food Items switch. */
.cook-head h1 { margin-bottom: 23px; }

.cook-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-4); }

/* The servings: − 4 servings +, the same size as the Weekly Meals | Food
   Items switch (section 27): the same strip and edge, 3px inside it, the
   same text size, and round buttons as tall as its pills (33.7px). */
.cook-servings {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 3px;
  border: 1px solid var(--line-box);
  border-radius: 999px;
  background: var(--card);
  font-size: 0.88rem;
}

.cook-servings span { min-width: 5.5rem; text-align: center; color: var(--muted); }
.cook-servings strong { margin-right: 0.2em; color: var(--text); }   /* a little more room before "servings" */

.cook-step {
  display: inline-grid;
  place-items: center;
  width: calc(0.88rem * 1.6 + 0.7rem);    /* the height of a switch pill */
  height: calc(0.88rem * 1.6 + 0.7rem);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1;
}

.cook-step:hover { color: var(--text); background: var(--steel-600); }
.cook-step.disabled { opacity: 0.35; }

.cook-reset-servings { color: var(--protein); font-size: 0.9rem; }
.cook-awake { display: inline-flex; align-items: center; gap: 0.35em; color: var(--calories); font-size: 0.85rem; }
.cook-awake[hidden] { display: none; }
.cook-reset { margin-left: auto; }
/* 12px under the servings row (24px before 2026-11-16). */
.cook-times { margin: var(--space-3) 0 0; color: var(--muted); }

.cook-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
  margin-top: var(--space-5);
}
/* Under "Prep 30 min · Cook 60 min": half that, 12px. */
.cook-head:has(.cook-times) + .cook-body { margin-top: var(--space-3); }

@media (min-width: 56rem) {
  .cook-body { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
  .cook-ingredients { position: sticky; top: var(--space-4); }
}

.cook-card {
  padding: var(--space-5);
  background: var(--card);
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}

.cook-card h2 { margin-bottom: var(--space-3); }

/* Ingredients: box | amount | name, a whole row is the tick. */
.cook-list { margin: 0; padding: 0; list-style: none; }
.cook-list li + li { border-top: 1px solid var(--line); }

.cook-item {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: baseline;
  column-gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

/* The box sits 6px from the amounts' column (half the row's 12px gap),
   and that column is 3.6rem (4.5rem before 2026-11-16), so an amount such
   as "300 g" starts about 21px from its box: half of before. A longer
   amount widens its own row's column a little. */
.cook-item .tick-box { align-self: center; width: 18px; height: 18px; margin-right: -6px; }   /* 22px before 2026-11-15 */
.cook-qty { min-width: 3.6rem; color: var(--fat); font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.cook-note { color: var(--muted); }

.cook-item.done .tick-box { border-color: var(--carbs); background: var(--carbs); }
.cook-item.done .tick-box svg { opacity: 1; transform: none; }
.cook-item.done .cook-qty,
.cook-item.done .cook-name { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 70%, transparent); }

/* The method: the same size and line spacing as on the recipe page. A
   step that is tapped fades and gets a green tick before it. */
.cook-method .method { line-height: 1.65; }

.cook-step-text {
  position: relative;
  border-radius: var(--radius-small);
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.cook-step-text:hover { background: color-mix(in srgb, var(--cream) 3%, transparent); }
.cook-step-text.done { opacity: 0.45; }
.method p.cook-step-text.done::before { content: "✓ "; color: var(--carbs); font-weight: 700; }
.method li.cook-step-text.done::marker { color: var(--carbs); }

/* The Cook button on a recipe page, in the calories amber. */
.recipe .cook-link { color: var(--calories); }

/* ---- 27. Menu groups and the Plan switch ----------------------------------- */
/* The top bar: the "using" links, then a thin line and a small "Plan"
   label before the planning links (Weekly Meals, Food Items). */
.menu-group {
  display: inline-flex;
  align-items: center;
  margin-left: var(--space-2);
  padding: 0 var(--space-2) 0 var(--space-4);
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.8;
  user-select: none;
}

/* The switch under the title of Weekly Meals and Food Items: two pills in
   one rounded strip; the page you are on is filled in. */
.plan-switch {
  display: inline-flex;
  gap: 2px;
  margin: calc(-1 * var(--space-4)) 0 var(--space-5);
  padding: 3px;
  border: 1px solid var(--line-box);
  border-radius: 999px;
  background: var(--card);
}

.plan-switch a {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
}

.plan-switch a:hover { color: var(--text); }
.plan-switch a[aria-current="page"] { background: var(--accent-soft); color: var(--text); }
.plan-switch a:nth-child(1) .icon { color: var(--peach); }
.plan-switch a:nth-child(2) .icon { color: var(--carbs); }

/* Food Items: under the title, one row with the switch on the left and
   "Add food item" on the right, centred on each other. The row keeps the
   switch's usual place under the title (the same as on Weekly Meals). On
   a phone the button moves to the bottom of the page, full width. */
.foods-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  /* -9px: the switch ends up 23px under the title, exactly where it is on
     Weekly Meals (there it sits in a line of text, which adds a little). */
  margin: -9px 0 var(--space-5);
}
.foods-bar .plan-switch { margin: 0; }
.foods-add-bottom { display: none; }
@media (max-width: 40rem) {
  .foods-add-top { display: none; }
  .foods-add-bottom { display: flex; margin: var(--space-5) 0 0; }
  .foods-add-bottom .button-link { flex: 1; justify-content: center; }
}

/* Weekly Meals: the week's summary comes right under the switch. */
/* Between phone and computer width (a tablet, a narrow window): the menu
   gets its own line under the name and the avatar, so it stays one tidy
   row instead of wrapping in pieces. */
@media (min-width: 40.01rem) and (max-width: 64rem) {
  .site-header .top-menu {
    order: 3;
    flex-basis: 100%;
    flex-wrap: nowrap;
    /* If the row is still too long, it scrolls sideways inside the bar
       instead of making the whole page wider. */
    overflow-x: auto;
    scrollbar-width: none;
  }
  .site-header .top-menu::-webkit-scrollbar { display: none; }
  .site-header .top-menu a { padding: var(--space-2) var(--space-3); font-size: 0.88rem; }
}


/* ---- 28. Today: the four bars, spacing, and the phone layout ------------------ */
/* Everything here is inside .today-page (today.html), so it only affects
   Today. The spacings are named values (--today-...), set by eye with a
   spacing tuner on 2026-11-15, with their own values on a phone. */
/* The four bars (calories, protein, carbs, fat), each against the day's
   own plan, each in its own colour. "Over" (more eaten than planned)
   shows in red, "All eaten" in green. */
.today-page .part-calories { --part: var(--calories); }
.today-page .part-protein { --part: var(--protein); }
.today-page .part-carbs { --part: var(--carbs); }
.today-page .part-fat { --part: var(--fat); }

.today-page .against-plan .overview-figure strong { color: var(--part); }

.today-page .plan-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--part) 55%, var(--steel-600)), var(--part));
}
/* After a tick, each bar slides to its new length (the script in
   today.html changes its width) rather than jumping. Skipped when the
   device asks for less motion. */
@media (prefers-reduced-motion: no-preference) {
  .today-page .plan-bar span { transition: width 0.6s cubic-bezier(0.2, 0.7, 0.2, 1); }
}

.today-page .against-plan .reached .overview-foot { color: var(--carbs); }
.today-page .against-plan .over .overview-foot { color: #e07a6e; }
/* The four panels: the gaps between them and inside them (label, bar,
   the line under it) come from the spacing values below. */
.today-page .against-plan { row-gap: var(--today-panels-gap); margin-bottom: var(--today-panels-to-meals); }
.today-page .against-plan .overview-panel { row-gap: var(--today-panel-inner); }
.today-page .against-plan .overview-head,
.today-page .against-plan .overview-foot { line-height: 1.3; }
/* On a phone only: a meal's calories and protein go on a
   second line under its name (kcal · protein), so the name gets the whole
   width. On a wider screen they stay at the right of the name. */
@media (max-width: 40rem) {
  .today-page .today-tick {
    grid-template-columns: auto minmax(0, 1fr);
    row-gap: var(--today-name-to-numbers);
  }
  .today-page .today-tick .tick-box { grid-row: 1; }
  .today-page .today-numbers {
    grid-column: 2;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 0.5em;
    justify-items: start;
  }
  .today-page .today-kcal,
  .today-page .today-protein { font-size: 0.8rem; color: var(--muted); }
  .today-page .today-protein::before { content: "·"; margin-right: 0.5em; }
}
/* The meal sections, their rows and the line at the bottom: all from the
   spacing values below. Rows stay at least 44px tall, easy to tap. */
.today-page .today-meal { margin-top: var(--today-row-to-line); padding-top: var(--today-line-to-label); }
/* The section labels (LUNCH, SNACKS, DINNER, BEFORE BED): their line is
   only as tall as the letters need (1.2 instead of 1.6), so the label sits
   close to the line above it and to its first food. */
.today-page .today-meal h3 { line-height: 1.2; margin-bottom: var(--today-label-to-food); }
.today-page .today-tick { padding: var(--today-row-top) 0 var(--today-row-bottom); }
/* The bottom row (the plan's links and Add food; on a phone Details and
   Add food): a dividing line above it, then --today-line-to-bottom-text
   of space to whatever is in the row. Its items are centred on one line,
   so each sits the same distance from that line. */
.today-page .today-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-4);
  margin-top: var(--today-row-to-line);
  padding-top: var(--today-line-to-bottom-text);
  border-top: 1px solid var(--line);
}
.today-page .today-foot .target-link { margin: 0; padding: 0; border: 0; transform: translateY(-14px); }
.today-page .today-foot .today-add-toggle { flex: none; margin-left: auto; }
/* "Add food" is a <button> (it opens the form), so it starts with the
   browser's own button look: a 3D border (on Android, light on top and
   left, dark on the right and bottom) and the phone's own font. Neither,
   so it matches "Add food item" on Food Items, a link. */
.today-page .today-add-toggle {
  border: 0;
  font-family: inherit;
  line-height: inherit;
  cursor: pointer;
}
.today-page .today-add-toggle[hidden] { display: none; }
/* "Details" is only for a phone (below); a computer has the links. */
.today-page .today-details { display: none; }
/* With nothing planned: no line over the row. */
.today-card > .empty + .today-foot { border-top: 0; padding-top: 0; margin-top: var(--space-4); }

/* On a phone: no links; "Details" (see-through, with a border) and "Add
   food" share the row half and half. */
@media (max-width: 40rem) {
  .today-page .today-foot { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .today-page .today-foot .target-link { display: none; }
  .today-page .today-details {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 0;
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--accent);
    border-radius: var(--radius-small);
    background: transparent;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
  }
  .today-page .today-details:hover { background: var(--accent-soft); color: var(--text); }
  .today-page .today-foot .today-add-toggle { flex: 1 1 0; justify-content: center; margin-left: 0; }
  /* Exactly the same size, side by side. */
  .today-page .today-foot .today-details,
  .today-page .today-foot .today-add-toggle {
    box-sizing: border-box;
    min-width: 0;
    height: 2.5rem;
    padding: 0 var(--space-3);
    line-height: 1;
  }
}

/* Today's spacings, as named values, set by eye with a spacing tuner on
   2026-11-15 (the computer view). A phone overrides some of them (below).
   Change a number here to adjust the page. */
.today-page {
  --today-panels-gap: 12px;          /* between the four panels at the top */
  --today-panel-inner: 4px;          /* inside a panel: label, bar, line under it */
  --today-panels-to-meals: 21px;     /* from the panels to the first meal section */
  --today-line-to-label: 24px;       /* from a section's line to its label (BREAKFAST...) */
  --today-label-to-food: 1px;        /* from the label to its first food row */
  --today-row-top: 5px;              /* above each food row */
  --today-row-bottom: 6px;           /* below each food row */
  --today-row-to-line: 0px;          /* from a section's last row to the next line */
  --today-line-to-bottom-text: 24px; /* from the bottom line to its text */
  --today-name-to-numbers: 2px;      /* phone: from a food's name to its kcal line */
  --today-box-shift: 0px;            /* tick boxes moved down (+) or up (-) from centred */
}

/* Today on a phone (narrower than 640px): its own spacing, set with a
   phone tuner on 2026-11-15. Anything not listed here is the same as on
   a computer (the values above). */
@media (max-width: 40rem) {
  .today-page {
    --today-panels-gap: 5px;
    --today-panels-to-meals: 12px;
    --today-line-to-label: 22px;
    --today-label-to-food: 4px;
    --today-row-bottom: 9px;
    --today-name-to-numbers: 0px;
    --today-box-shift: 3px;
  }
}
/* Wider than a phone: a food's kcal in the same size as its protein under
   it. On a phone both already share one size on their own line. */
@media (min-width: 40.01rem) {
  .today-page .today-kcal { font-size: 0.78rem; }
}

/* The tick boxes' up/down position (--today-box-shift above; 0 means
   centred on the food's name). */
.today-page .today-tick .tick-box { position: relative; top: var(--today-box-shift); }

/* A row's small buttons ("actions"): a recipe's book, and the × that takes
   added food off the day. Each is a square of --today-book-size. */
.today-actions { display: flex; flex: none; align-items: center; }
.today-page { --today-book-size: 2.25rem; }
.today-remove { margin: 0; }
.today-remove button {
  display: inline-grid;
  place-items: center;
  width: var(--today-book-size);
  height: var(--today-book-size);
  padding: 0;
  border: 0;
  border-radius: var(--radius-small);
  background: transparent;
  color: #f0a59b;          /* light pastel red, on every screen (a phone has no pointing) */
  cursor: pointer;
}
.today-remove button:hover { background: color-mix(in srgb, #e07a6e 14%, transparent); color: #e07a6e; }
/* The × icon: a cross in a circle, the same size and line as the book. */
.today-remove .icon { width: 1.15rem; height: 1.15rem; }
/* After the first click it reads "Remove?" (base.html); a second click removes. */
.today-remove button.confirming {
  width: auto;
  padding: 0 var(--space-3);
  background: color-mix(in srgb, #e07a6e 16%, transparent);
  color: #f0a59b;
  font: inherit;
  font-size: 0.8rem;
  white-space: nowrap;
}

/* The small "added" tag after the name of food added to this date only. */
.today-added-tag {
  display: inline-block;
  margin-left: var(--space-1);
  padding: 0 0.45em;
  border: 1px solid color-mix(in srgb, var(--protein) 45%, transparent);
  border-radius: 999px;
  color: var(--protein);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.5;
  vertical-align: 0.1em;
}
.today-item.ticked .today-added-tag { opacity: 0.7; }

/* Wider than a phone: the actions sit just left of the row's kcal and
   protein, which stay at the far right like every other row. They are a
   link and a form, so they can't go inside the row's tick button; they are
   placed over the row instead, pinned to the left edge of that row's
   numbers ("anchor positioning"). The row keeps a gap before its numbers,
   as wide as its buttons (one or two), so a long name never runs under
   them. On a phone they stay at the far right of the row. */
@media (min-width: 40.01rem) {
  .today-page {
    --today-book-gap: 6px;   /* extra space between the buttons and the numbers */
  }
  .today-page .actions-1 { --today-actions-width: var(--today-book-size); }
  .today-page .actions-2 { --today-actions-width: calc(2 * var(--today-book-size)); }
  .today-page .today-item.has-actions { position: relative; }
  .today-page .today-item.has-actions .today-numbers {
    margin-left: calc(var(--today-actions-width) + var(--today-book-gap));
  }
  .today-page .today-item.has-actions .today-actions {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
  }
}
@supports (anchor-scope: all) {
  @media (min-width: 40.01rem) {
    .today-page .today-item { anchor-scope: --today-numbers; }
    .today-page .today-numbers { anchor-name: --today-numbers; }
    .today-page .today-item.has-actions .today-actions {
      position-anchor: --today-numbers;
      right: calc(anchor(left) + var(--today-book-gap));
    }
  }
}
/* Older browsers without anchor positioning: the numbers get a fixed-width
   column (wide enough for "2,600 kcal / 187.5 g protein") and the buttons
   sit just left of that column. */
@supports not (anchor-scope: all) {
  @media (min-width: 40.01rem) {
    .today-page .today-numbers { min-width: 6.5rem; }
    .today-page .today-item.has-actions .today-actions { right: calc(6.5rem + var(--today-book-gap)); }
  }
}
/* Wider than a phone, with the page's script: the buttons of every row
   line up in one column (books and × above each other). The script
   measures the widest kcal/protein on the page (--today-numbers-width,
   set on the card as "numbers-measured"); every row's numbers take that
   width, still right-aligned, and the buttons sit just left of it. This
   replaces the per-row placement above. */
@media (min-width: 40.01rem) {
  .today-page .numbers-measured .today-numbers { min-width: var(--today-numbers-width); }
  .today-page .numbers-measured .today-item.has-actions .today-actions {
    right: calc(var(--today-numbers-width) + var(--today-book-gap));
  }
}

/* "Add food": the button in the bottom row (the same style as "Add food
   item" on Food Items, .button-link) opens the form under that row: item |
   amount and unit | meal | Add (on a phone, a few lines). The boxes look
   like the ones on the plan's edit page (section 12). */
.today-add { margin-top: var(--space-4); }
.today-add[hidden] { display: none; }
.today-add-form { margin-top: 0; }
.today-add-amount { display: inline-flex; align-items: center; gap: var(--space-2); }
.today-add .unit { min-width: 0; }
.today-add select.today-add-meal { flex: 0 0 auto; }


/* ---- 29. The recipe and food picker ----------------------------------------- */
/* static/picker.js: the searchable list that replaces the browser's own
   dropdown wherever a recipe or food item is chosen (Today's Add food, the
   plan's edit page, the recipe builder). The real dropdown stays in the
   page, hidden (.picker-native). On a computer the list drops down under
   the box; on a phone it slides up from the bottom of the screen. */
.picker { position: relative; min-width: 0; }
.plan-add .picker { flex: 1 1 14rem; }
/* A short list without search (the meal on Today's Add food): a box just
   wide enough for its longest choice ("Before Bed"). */
.plan-add .picker-simple { flex: 0 0 9.5rem; }

.picker-native {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* The box: looks like the other boxes on these forms. */
.picker-button {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line-box);
  border-radius: var(--radius-small);
  background: var(--page);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  text-align: left;
  cursor: pointer;
}
.picker-button .picker-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-button .icon { width: 1rem; height: 1rem; color: var(--muted); transition: transform 0.18s ease; }
.picker-button.picker-empty .picker-label { color: var(--muted); }
.picker-button:hover { border-color: var(--accent); }
.picker-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.picker-button:disabled { opacity: 0.55; cursor: default; }
.picker.open .picker-button { border-color: var(--accent); }
.picker.open .picker-button .icon { transform: rotate(180deg); }
.picker-missing .picker-button { border-color: #e07a6e; }

/* The panel: a search box, then the list. It sits at the end of the page
   (not inside the card); on a computer the script places it right under
   its box (top, left and width). */
.picker-panel {
  position: absolute;
  z-index: 70;
  padding: var(--space-2);
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius-small);
  background: var(--navy-900);
  box-shadow: var(--shadow);
  outline: none;
}
.picker-panel[hidden] { display: none; }
.picker-head { display: none; }        /* the title bar is for phones */
.picker-search {
  width: 100%;
  margin: 0 0 var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line-box);
  border-radius: var(--radius-small);
  background: var(--page);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}
.picker-search:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.picker-list {
  max-height: 18rem;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}
.picker-group {
  padding: var(--space-2) var(--space-3) var(--space-1);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.picker-group:not(:first-child) { margin-top: var(--space-1); }
.picker-option {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.92rem;
  cursor: pointer;
}
.picker-option[hidden], .picker-group[hidden] { display: none; }
.picker-name { flex: 1; min-width: 0; }
.picker-unit { color: var(--muted); font-size: 0.78rem; white-space: nowrap; }
.picker-option.active { background: var(--accent-soft); }
.picker-option[aria-selected="true"] { color: var(--protein); }
.picker-option[aria-selected="true"] .picker-name { font-weight: 600; }
.picker-none { margin: var(--space-2) var(--space-3); color: var(--muted); font-size: 0.85rem; }
.picker-backdrop { display: none; }

/* On a phone: a sheet that slides up from the bottom, over the bottom
   menu, with the page dimmed behind it. Big rows for a thumb. */
@media (max-width: 40rem) {
  .picker-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgb(4 10 26 / 0.6);
  }
  .picker-panel {
    position: fixed;
    z-index: 91;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    max-height: 78vh;
    display: flex;
    flex-direction: column;
    padding: var(--space-3) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom));
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: 0;
  }
  .picker-panel[hidden] { display: none; }
  .picker-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2);
  }
  .picker-title { margin: 0; font-weight: 600; }
  .picker-close {
    display: inline-grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    margin: 0 calc(-1 * var(--space-2)) 0 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
  }
  .picker-close .icon { width: 1.2rem; height: 1.2rem; }
  .picker-search { font-size: 1rem; }  /* 16px: a phone doesn't zoom in on it */
  .picker-list { flex: 1; max-height: none; }
  .picker-option { padding: var(--space-3); font-size: 1rem; }
  .picker-unit { font-size: 0.85rem; }
}
/* While the sheet is open, the page behind it doesn't scroll. */
.picker-sheet-open, .picker-sheet-open body { overflow: hidden; }
@media (prefers-reduced-motion: no-preference) and (max-width: 40rem) {
  .picker-panel.open { animation: picker-up 0.22s cubic-bezier(0.2, 0.7, 0.2, 1); }
  .picker-backdrop.open { animation: picker-fade 0.22s ease; }
}
@keyframes picker-up { from { transform: translateY(100%); } }
@keyframes picker-fade { from { opacity: 0; } }
