/* Munch Patch: two themes, both cheerful. Light is the default. Dusk (a garden at blue hour, not a black night
   mode) is used when the phone is set to dark, or when Theme is set to Dusk in settings. theme.js puts
   data-theme="light" or "dusk" on <html>; no attribute means follow the phone.
   Every colour in this file is a token from the lists below, so both themes stay complete: add a token before
   reaching for a new colour. Dusk is written out twice (CSS has no way to share the list): change BOTH lists.
   Text pairs are checked for contrast (4.5 to 1 or better); --bg is also the page colour in theme.js. */
:root {
  /* surfaces */
  --bg: #FBF6EC;              /* the page */
  --bg-glow: #FFEFC2;         /* the warm glow at the top of the opening screens */
  --panel: #F3EBDA;           /* cards, sheets */
  --panel-2: #EFE6D3;         /* chips, rows, secondary buttons */
  --hover: #E6DBC3;           /* a row under the pointer */
  --input-bg: #FFFDF7;        /* fields, steppers, the well behind tabs */
  --track: #E6DAC2;           /* the empty part of the ring and the bars */
  --line: #E3D7BF;            /* borders */
  --line-strong: #CDBD9C;     /* a border under the pointer */
  --photo-bg: #2B261E;        /* behind the camera and a meal photo */
  --overlay: rgba(58, 50, 38, .45);       /* the dim behind a sheet */
  --overlay-soft: rgba(20, 24, 20, .4);   /* the dim over a photo or the camera */
  --shadow: 0 6px 20px rgba(92, 72, 40, .18);
  /* text */
  --text: #2E3A2C;
  --muted: #566251;           /* secondary text */
  /* leaf green */
  --accent: #4E7D49;          /* primary buttons, the ring, marks */
  --accent-ink: #FFFFFF;      /* text on --accent and --accent-deep */
  --accent-text: #3B6337;     /* links and green text on the page, cards and fields */
  --accent-soft: #E4EFD6;     /* a picked option, the "close enough" pill */
  --accent-line: #B9D3A4;     /* the border of an --accent-soft box */
  --accent-deep: #3B6337;     /* the edge under the scan button, the pill on it */
  --accent-glow: rgba(78, 125, 73, .28);
  /* the patch */
  --soil: #C9A878;            /* a planted plot (the same in both themes, so it glows at dusk) */
  --soil-ink: #3A3226;        /* the day number on a planted plot */
  --soil-empty: #E6D6BA;      /* a plot with nothing planted */
  --soil-empty-ink: #5A5243;  /* the day number on an empty plot */
  --bed: #DCC19B;             /* the raised bed around the plots */
  --bed-edge: #C89A6E;        /* the bed's wooden edge */
  --pink: #E58FA8;            /* blooms, small highlights */
  /* marigold */
  --sun: #F3C34B;             /* highlights, the toast, the ring when over budget */
  --sun-ink: #3A2E0A;         /* text on --sun */
  --sun-text: #7A5600;        /* marigold text on the page, cards and --sun-soft */
  --sun-soft: #FBEBC0;        /* the save pill and banner, the sample note */
  --sun-line: #E2C36F;        /* the border of a --sun-soft box */
  --sun-glow: rgba(243, 195, 75, .45);
  /* macros (bars on --track) */
  --protein: #C8553D;
  --carbs: #A06A0A;
  --fat: #7E63B8;
  /* form errors and the delete button ONLY: never for food or the day */
  --warn: #A8442A;
  --warn-soft: #FBE6DB;
  --warn-line: #E0A892;
  --focus: #2E3A2C;           /* the keyboard focus ring: the text colour, so it never blends into today's green ring */
  /* the same in both themes */
  --radius: 16px;
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;   /* the brand and month titles, weight 600 */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #243B53;
    --bg-glow: #54507C;
    --panel: #2D4763;
    --panel-2: #375573;
    --hover: #3E5F81;
    --input-bg: #1F3550;
    --track: #1E3349;
    --line: #4A6A8E;
    --line-strong: #6488B0;
    --photo-bg: #16273A;
    --overlay: rgba(14, 24, 38, .6);
    --overlay-soft: rgba(14, 24, 38, .4);
    --shadow: 0 6px 20px rgba(10, 20, 34, .35);
    --text: #FFF6E3;
    --muted: #D0DBE7;
    --accent: #8FE08A;
    --accent-ink: #14301B;
    --accent-text: #A9EDA0;
    --accent-soft: #2F5A4A;
    --accent-line: #4C8A6A;
    --accent-deep: #5FB563;
    --accent-glow: rgba(143, 224, 138, .3);
    --soil-empty: #6B5843;
    --soil-empty-ink: #E9DCC4;
    --bed: #8A6A47;
    --bed-edge: #B38A5E;
    --pink: #FF9EC0;
    --sun: #FFD166;
    --sun-ink: #3A2E0A;
    --sun-text: #FFD166;
    --sun-soft: #5B4A2B;
    --sun-line: #8A7238;
    --sun-glow: rgba(255, 209, 102, .4);
    --protein: #FF9B7A;
    --carbs: #FFD98A;
    --fat: #C9B1FF;
    --warn: #FFBFA6;
    --warn-soft: #5A3A3A;
    --warn-line: #8A5A52;
    --focus: #FFD166;
    color-scheme: dark;
  }
}
:root[data-theme="dusk"] {
  --bg: #243B53;
  --bg-glow: #54507C;
  --panel: #2D4763;
  --panel-2: #375573;
  --hover: #3E5F81;
  --input-bg: #1F3550;
  --track: #1E3349;
  --line: #4A6A8E;
  --line-strong: #6488B0;
  --photo-bg: #16273A;
  --overlay: rgba(14, 24, 38, .6);
  --overlay-soft: rgba(14, 24, 38, .4);
  --shadow: 0 6px 20px rgba(10, 20, 34, .35);
  --text: #FFF6E3;
  --muted: #D0DBE7;
  --accent: #8FE08A;
  --accent-ink: #14301B;
  --accent-text: #A9EDA0;
  --accent-soft: #2F5A4A;
  --accent-line: #4C8A6A;
  --accent-deep: #5FB563;
  --accent-glow: rgba(143, 224, 138, .3);
  --soil-empty: #6B5843;
  --soil-empty-ink: #E9DCC4;
  --bed: #8A6A47;
  --bed-edge: #B38A5E;
  --pink: #FF9EC0;
  --sun: #FFD166;
  --sun-ink: #3A2E0A;
  --sun-text: #FFD166;
  --sun-soft: #5B4A2B;
  --sun-line: #8A7238;
  --sun-glow: rgba(255, 209, 102, .4);
  --protein: #FF9B7A;
  --carbs: #FFD98A;
  --fat: #C9B1FF;
  --warn: #FFBFA6;
  --warn-soft: #5A3A3A;
  --warn-line: #8A5A52;
  --focus: #FFD166;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
main, .top, .foot { max-width: 520px; margin: 0 auto; padding: 0 16px; }
h2 { font-size: 15px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent-text); }
/* One focus ring for everything you can tab to, in a colour that shows on every surface of both themes. */
a:focus-visible, button:focus-visible, select:focus-visible, summary:focus-visible, input[type="checkbox"]:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
::placeholder { color: var(--muted); opacity: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.top { display: flex; align-items: center; justify-content: space-between; padding-top: 14px; padding-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 22px; font-weight: 600; letter-spacing: .01em; }
.brand b { color: var(--accent-text); }
.icon-btn { background: none; border: 0; font-size: 20px; padding: 6px; border-radius: 10px; line-height: 1; min-width: 44px; min-height: 44px; }
.icon-btn:hover { background: var(--panel-2); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }

/* Today */
.today { display: flex; align-items: center; gap: 16px; }
.ring-wrap { position: relative; flex: none; width: 128px; height: 128px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 12; }
.ring-bg { stroke: var(--track); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring-fg.over { stroke: var(--sun); }
.ring-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-text strong { font-size: 26px; line-height: 1; }
.ring-text small { font-size: 12px; color: var(--muted); }
.macros { flex: 1; min-width: 0; display: grid; gap: 9px; }
.macro { display: flex; align-items: center; gap: 8px; }
.m-ico { font-size: 18px; }
.m-body { flex: 1; min-width: 0; }
.m-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 3px; }
.m-head span:last-child { color: var(--muted); }
.bar { height: 7px; background: var(--track); border-radius: 4px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; border-radius: 4px; transition: width .6s ease; }
.protein .bar span { background: var(--protein); }
.carbs .bar span { background: var(--carbs); }
.fat .bar span { background: var(--fat); }
.eaten { font-size: 12px; color: var(--muted); }
/* Fiber and sugar under Carbs. The Carbs row is a button, 44 px tall to tap; its padding is taken back by the margin,
   so the row sits and looks as it did, plus the small arrow. The rows under it are marked "kc": hidden with the
   calorie numbers. Fiber's bar is the leaf green and simply fills; Sugar has no bar. Neither is ever a warning. */
.carbs-btn { width: calc(100% + 12px); min-height: 44px; margin: -8px -6px; padding: 8px 6px; border: 0; border-radius: 10px; background: none; text-align: left; }
.carbs-btn:disabled { cursor: default; }
/* The focus ring sits inside the row, or it would draw over the Protein and Fat bars next to it. */
.carbs-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
@media (hover: hover) { .carbs-btn:enabled:hover { background: var(--panel-2); } }
.carbs-btn .bar { display: block; }
.sub-arrow { width: 12px; height: 12px; margin-left: 5px; vertical-align: -1px; color: var(--muted); transition: transform .2s ease; }
.carbs-btn[aria-expanded="true"] .sub-arrow { transform: rotate(180deg); }
.subs { display: grid; gap: 6px; margin-left: 10px; padding-left: 20px; border-left: 2px solid var(--line); }
.subs[hidden] { display: none; }
.subs .m-head { font-size: 12px; }
.subs .m-head:last-child { margin-bottom: 0; }
.subs .bar { height: 4px; }
.subs .bar span { background: var(--accent); }
.subs-note { margin: 0; font-size: 11px; color: var(--muted); white-space: pre-line; }

/* Scan button */
.scan-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; margin: 4px 0 16px;
  padding: 18px; border-radius: var(--radius); font-size: 20px; font-weight: 800; color: var(--accent-ink);
  background: var(--accent); box-shadow: 0 5px 0 var(--accent-deep), 0 10px 24px var(--accent-glow);
  cursor: pointer; user-select: none; transition: transform .08s ease, box-shadow .08s ease;
}
.scan-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--accent-deep); }
.scan-btn:focus-visible, .btn:focus-visible, .icon-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Free ways to log */
.quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: -4px 0 16px; }
.quick-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 13px 6px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line); font-weight: 800; font-size: 15px; white-space: nowrap;
}
.quick-btn:hover { background: var(--panel-2); }
/* The narrowest phones (320 px): three buttons side by side need smaller words, or the page scrolls sideways. */
@media (max-width: 350px) { .quick-btn { font-size: 13px; padding: 13px 4px; gap: 4px; } }
.quick-btn:focus-visible, .chip:focus-visible, .results button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.ico { width: 20px; height: 20px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.chip {
  flex: none; display: grid; text-align: left; gap: 1px; max-width: 190px; padding: 9px 12px; border-radius: 12px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.chip:hover { border-color: var(--accent); }
.chip-name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-kcal { font-size: 12px; color: var(--sun-text); }

.text-input {
  width: 100%; font: inherit; color: var(--text); background: var(--input-bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px;
}
.text-input:focus { outline: 2px solid var(--focus); outline-offset: 0; }
.sheet .row label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.results { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; max-height: 50dvh; overflow: auto; }
.results button {
  width: 100%; display: grid; gap: 2px; text-align: left; padding: 10px 12px; border: 0; border-radius: 10px; background: var(--panel-2);
}
.results button:hover { background: var(--hover); }
.r-name { font-weight: 700; font-size: 14px; }
.r-kcal { font-size: 12px; color: var(--muted); }
.r-kcal b { color: var(--sun-text); }
.r-group { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 8px 2px 0; }
.r-group:first-child { padding-top: 0; }
.portion-sub { margin: -4px 0 6px; }
.credit { font-size: 11px; color: var(--muted); margin: 10px 0 0; }

.cam { position: relative; background: var(--photo-bg); aspect-ratio: 4 / 3; max-height: 40dvh; width: 100%; overflow: hidden; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-frame {
  position: absolute; left: 12%; right: 12%; top: 32%; bottom: 32%; border: 3px solid var(--sun); border-radius: 12px;
  box-shadow: 0 0 0 999px var(--overlay-soft);
}
.code-form { display: flex; gap: 8px; margin: 10px 0; }
.code-form .text-input { flex: 1; min-width: 0; }
.code-form .btn { flex: none; }
.photo-link { display: inline-flex; gap: 6px; font-size: 14px; color: var(--accent-text); cursor: pointer; text-decoration: underline; }
#barcode-status.error { color: var(--warn); }

/* Accounts and the upgrade screen */
.top-actions { display: flex; gap: 4px; }
.scan-btn { position: relative; }
.scan-left {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 12px; font-weight: 800;
  background: var(--accent-deep); color: var(--accent-ink); padding: 4px 8px; border-radius: 999px;
}
.scan-left.out { background: var(--panel); color: var(--text); }
.pw { text-align: center; }
.pw-badge { font-size: 46px; line-height: 1; margin: 4px 0 6px; }
.pw-list { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; text-align: left; }
.pw-list li { display: flex; gap: 10px; padding: 10px 12px; background: var(--panel-2); border-radius: 12px; font-size: 14px; }
.plans { display: grid; gap: 8px; margin-bottom: 12px; text-align: left; }
.plan input { position: absolute; opacity: 0; pointer-events: none; }
.plan > span { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--input-bg); cursor: pointer; }
.plan small { flex-basis: 100%; color: var(--muted); }
.plan input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.plan input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.btn.wide { width: 100%; flex: 1 1 100%; }
.btn.danger { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-line); }
.link { background: none; border: 0; padding: 0; color: var(--accent-text); text-decoration: underline; font-weight: 700; }
.center { text-align: center; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--input-bg); padding: 4px; border-radius: 12px; margin: 10px 0 12px; }
.tabs button { border: 0; background: none; padding: 9px; border-radius: 9px; font-weight: 800; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--accent-soft); color: var(--text); }
.acct-form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.acct-form label[hidden] { display: none; }
.acct-form .btn { margin-top: 4px; }
#del-form { margin-top: 14px; }
.acct-email { font-weight: 800; font-size: 18px; margin: 0 0 4px; word-break: break-all; }
.vcode-input { font-family: Consolas, Menlo, monospace; font-size: 22px; letter-spacing: 6px; text-transform: uppercase; text-align: center; }

.wo-kcal small { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.meal { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel-2); border-radius: 12px; }
.meal-main { flex: 1; min-width: 0; display: grid; }
.meal-time { font-size: 11px; color: var(--muted); }
.meal-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meal-macros { font-size: 12px; color: var(--muted); }
.meal-kcal { text-align: right; font-weight: 800; }
.meal-kcal small { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }
.empty { color: var(--muted); margin: 4px 0 0; }
.empty b { color: var(--sun-text); }

.foot { font-size: 12px; color: var(--muted); text-align: center; padding-top: 4px; padding-bottom: 28px; }
.foot-app { display: inline-block; } /* "More from us": each app stays with its few words when the line wraps */

/* Sheets (scan result, goal setup) */
.sheet {
  width: min(520px, 100vw); max-height: 92dvh; margin: auto auto 0; padding: 0; border: 1px solid var(--line);
  border-radius: 22px 22px 0 0; background: var(--panel); color: var(--text); overflow: auto;
}
.sheet::backdrop { background: var(--overlay); }
@media (min-width: 560px) { .sheet { margin: auto; border-radius: 22px; } }
.sheet-body { padding: 16px; }
.sheet h2 { font-size: 20px; text-transform: none; letter-spacing: 0; color: var(--text); margin-bottom: 8px; }
.sheet-photo { position: relative; background: var(--photo-bg); }
.sheet-photo img { display: block; width: 100%; max-height: 34dvh; object-fit: cover; }
.scanning { position: absolute; inset: 0; display: none; overflow: hidden; background: var(--overlay-soft); }
.scanline {
  position: absolute; left: 0; right: 0; height: 40%; top: -40%;
  background: linear-gradient(180deg, transparent, var(--sun-glow) 85%, var(--sun));
  animation: scan 1.4s ease-in-out infinite;
}
@keyframes scan { to { top: 100%; } }
.scan-status { display: none; font-weight: 700; color: var(--accent-text); margin: 0 0 12px; }
.scan-status small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 2px; }
.sheet.loading .scanning, .sheet.loading .scan-status { display: block; }
.sheet.loading .result, .sheet.failed .result { display: none; }
.sheet.loading #sheet-log, .sheet.failed #sheet-log { display: none; }

.demo-flag { font-size: 13px; background: var(--sun-soft); color: var(--sun-text); border: 1px solid var(--sun-line); border-radius: 10px; padding: 8px 10px; margin: 0 0 10px; }
.items { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.item { background: var(--panel-2); border-radius: 12px; padding: 10px 12px; }
.item-top, .item-bottom { display: flex; align-items: center; gap: 8px; }
.item-bottom { margin-top: 6px; }
.item-name { flex: 1; min-width: 0; font-weight: 700; }
.item-kcal { font-weight: 800; white-space: nowrap; }
.item-macros { flex: 1; font-size: 12px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.conf-high .dot { background: var(--accent); }
.conf-medium .dot { background: var(--sun); }
/* Not sure about this food: a hollow dot, never red (nothing about food is red here). */
.conf-low .dot { background: none; border: 2px solid var(--muted); }
.stepper { display: flex; align-items: center; background: var(--input-bg); border-radius: 10px; }
.stepper button { width: 34px; height: 32px; border: 0; background: none; font-size: 18px; font-weight: 800; color: var(--accent-text); }
.stepper span { min-width: 58px; text-align: center; font-size: 14px; }
.notes { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.sheet-total { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 12px; }
.sheet-total strong { font-size: 20px; }
.sheet-total .muted { flex-basis: 100%; font-size: 13px; }
.error { color: var(--warn); font-weight: 700; }
.sheet-actions { display: flex; gap: 10px; margin-top: 14px; }
.btn { flex: 1; padding: 13px 16px; border-radius: 12px; border: 0; font-weight: 800; font-size: 16px; white-space: nowrap; }
.sheet-actions .btn.ghost { flex: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: var(--panel-2); border: 1px solid var(--line); }

/* Your plan (⚙️) */
.plan-sum { display: grid; gap: 2px; padding: 12px 14px; margin-bottom: 12px; border-radius: 12px; background: var(--accent-soft); border: 1px solid var(--accent-line); }
.plan-sum strong { color: var(--accent-text); font-size: 20px; }
.plan-sum small { color: var(--muted); font-size: 13px; }
.set-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; }
.set-list button {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; padding: 11px 12px;
  border: 0; border-radius: 12px; background: var(--panel-2);
}
.set-list button:hover { background: var(--hover); }
.set-list button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.set-list span:first-child { flex: none; color: var(--muted); font-size: 14px; }
.set-list b { flex: 1; min-width: 0; text-align: right; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-list .chev { color: var(--muted); font-size: 20px; line-height: 1; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { border: 0; padding: 0; margin: 0 0 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.seg legend { font-size: 13px; color: var(--muted); margin-bottom: 4px; padding: 0; }
.seg label { flex: 1; margin: 0; display: block; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 10px; border-radius: 10px; background: var(--input-bg); border: 1px solid var(--line); color: var(--text); font-weight: 700; cursor: pointer; }
.seg input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Save progress (guests) */
.save-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; font-weight: 800; font-size: 14px;
  background: var(--sun-soft); color: var(--sun-text); border: 1px solid var(--sun-line);
}
.save-pill:hover { border-color: var(--sun-text); }
.save-pill.signed-in { background: none; border-color: transparent; color: var(--text); font-size: 20px; padding: 6px; }
.save-pill.signed-in:hover { background: var(--panel-2); }
.save-pill:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.save-banner { display: flex; align-items: center; gap: 12px; padding: 12px 10px 12px 14px; border-color: var(--sun-line); background: linear-gradient(180deg, var(--sun-soft), var(--panel)); }
.save-banner[hidden] { display: none; }
.save-banner p { flex: 1; margin: 0; font-size: 13px; color: var(--muted); }
.save-banner p b { color: var(--text); display: block; font-size: 14px; }
.save-banner .btn { flex: none; padding: 10px 16px; }
.sb-ico { font-size: 24px; }
.sb-x { flex: none; font-size: 14px; color: var(--muted); }
.acct-why { margin: 0 0 8px; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); border: 1px solid var(--accent-line); font-weight: 700; }

/* The opening screens (the first-run plan builder) */
body.in-open { overflow: hidden; }
.intro {
  position: fixed; inset: 0; z-index: 40; overflow-y: auto; background: radial-gradient(120% 60% at 50% 0%, var(--bg-glow), var(--bg) 60%) var(--bg);
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.intro[hidden] { display: none; }
.in-wrap { max-width: 520px; min-height: 100%; margin: 0 auto; padding: 12px 16px 0; display: flex; flex-direction: column; }
.in-top { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.in-top[hidden], .in-top [hidden] { display: none; }
/* The progress bar of the opening screens (.in-bar) and of "building your plan" (.build-bar). They carry the whole
   look themselves, so the markup needs no other class on them. */
.in-bar, .build-bar { background: var(--track); border: 2px solid var(--line); border-radius: 8px; overflow: hidden; }
.in-bar span, .build-bar span { display: block; height: 100%; width: 0; border-radius: 6px; background: var(--accent); transition: width .6s ease; }
.in-bar { flex: 1; height: 12px; }
.in-count { font-size: 12px; font-weight: 800; color: var(--muted); min-width: 34px; text-align: right; }
.in-close { margin-left: auto; }
.in-title { font-size: 26px; line-height: 1.2; margin: 18px 0 6px; outline: none; }
.in-sub { color: var(--muted); margin: 0 0 16px; }
.in-sub[hidden] { display: none; }
.in-content { display: grid; gap: 10px; }
.in-multi { grid-template-columns: 1fr 1fr; }
.in-opt {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px; text-align: left; border-radius: 14px;
  background: var(--panel); border: 2px solid var(--line); transition: border-color .12s ease, background .12s ease, transform .08s ease;
}
.in-opt:hover { border-color: var(--line-strong); }
.in-opt:active { transform: scale(.98); }
.in-opt[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.in-opt:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.in-ico { flex: none; width: 34px; text-align: center; font-size: 24px; }
.in-lab { display: grid; gap: 2px; min-width: 0; }
.in-lab b { font-size: 16px; }
.in-lab small { color: var(--muted); font-size: 13px; }
.in-multi .in-opt { padding: 12px 10px; gap: 8px; }
.in-multi .in-ico { width: 26px; font-size: 20px; }
.in-multi .in-lab b { font-size: 14px; }
.in-reflect {
  margin: 14px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--panel-2); border-left: 4px solid var(--accent);
  font-weight: 700; animation: rise .25s ease;
}
.in-reflect[hidden] { display: none; }
.in-reflect.bad { border-left-color: var(--warn); color: var(--warn); background: var(--warn-soft); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.in-foot { position: sticky; bottom: 0; margin-top: auto; padding: 16px 0 20px; background: linear-gradient(transparent, var(--bg) 30%); }
.in-foot[hidden] { display: none; }
.in-foot .btn { font-size: 18px; padding: 15px; }

.in-nums { display: flex; gap: 10px; flex-wrap: wrap; }
.in-num { flex: 1 1 120px; display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.in-num-box { display: flex; align-items: baseline; gap: 6px; padding: 10px 14px; border-radius: 14px; background: var(--panel); border: 2px solid var(--line); }
.in-num-box:focus-within { border-color: var(--focus); }
.in-num-box input { width: 100%; min-width: 0; font: inherit; font-size: 30px; font-weight: 800; color: var(--text); background: none; border: 0; outline: none; }
.in-num-box small { color: var(--muted); font-size: 15px; font-weight: 700; }
.in-units { display: inline-grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 12px; background: var(--input-bg); border-radius: 12px; justify-self: start; }
.in-units button { border: 0; background: none; padding: 8px 14px; border-radius: 9px; font-weight: 800; color: var(--muted); }
.in-units button[aria-checked="true"] { background: var(--accent-soft); color: var(--text); }

.in-hero { display: grid; place-items: center; margin: 4px 0 6px; }
.in-hero img { filter: drop-shadow(0 0 24px var(--accent-glow)); animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
.in-perks, .in-loop { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.in-perks li { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--panel); font-weight: 700; }
.in-perks span { font-size: 22px; }
.in-loop li {
  display: grid; grid-template-columns: 34px 1fr auto; grid-template-rows: auto auto; column-gap: 10px; align-items: center;
  padding: 12px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line);
}
.in-loop li > span { grid-row: span 2; font-size: 24px; text-align: center; }
.in-loop b { font-size: 15px; }
.in-loop small { grid-column: 2; color: var(--muted); font-size: 13px; }
.in-loop em { grid-column: 3; grid-row: 1 / span 2; font-style: normal; font-weight: 900; color: var(--sun-text); font-size: 13px; white-space: nowrap; }

.build-bar { height: 16px; margin: 8px 0 18px; }
.build-bar span { width: 0; transition: width .5s ease; }
.build-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.build-list li { display: flex; gap: 10px; align-items: center; color: var(--muted); opacity: .35; transition: opacity .3s ease, color .3s ease; font-weight: 700; }
.build-list li::before { content: ""; flex: none; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); }
.build-list li.done { opacity: 1; color: var(--text); }
.build-list li.done::before { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 4px var(--accent-soft); }

.plan-card { padding: 16px; border-radius: var(--radius); background: var(--panel); border: 2px solid var(--sun); box-shadow: var(--shadow); display: grid; gap: 12px; animation: pop .45s cubic-bezier(.2, 1.6, .4, 1); }
.plan-top { display: flex; align-items: center; gap: 14px; }
.plan-kcal strong { font-size: 40px; line-height: 1; color: var(--accent-text); }
.plan-macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pm { display: grid; padding: 10px; border-radius: 12px; background: var(--panel-2); text-align: center; border-top: 3px solid; }
.pm b { font-size: 18px; }
.pm small { color: var(--muted); font-size: 12px; }
.pm.protein { border-color: var(--protein); }
.pm.carbs { border-color: var(--carbs); }
.pm.fat { border-color: var(--fat); }
.plan-line { margin: 0; font-weight: 700; display: flex; gap: 8px; }
.plan-save { margin: 18px 0 24px; }
.plan-save h2 { font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--text); margin: 0 0 4px; }
.plan-save .acct-form { margin-top: 10px; }
.plan-save .center { margin: 10px 0 0; }
.muted-link { color: var(--muted); font-weight: 600; }
.fine { font-size: 12px; color: var(--muted); margin: 16px 0 0; text-align: center; }
.fine a, .foot a { color: var(--muted); }
.check { display: flex !important; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--muted); margin: 2px 0 12px; }
.check[hidden] { display: none !important; }
.check input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.check a { color: var(--muted); }
.in-detail { margin: -6px 0 14px; }
.in-detail[hidden] { display: none; }
.in-detail a { color: var(--muted); }
.in-facts { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.in-facts li { display: flex; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--panel); font-size: 14px; }
.in-skip { display: block; margin: 12px auto 0; padding: 4px 10px; }
.in-skip[hidden] { display: none; }

/* The small pop-in of the plan card and the picture on the first opening screen. */
@keyframes pop { from { transform: scale(.6); opacity: 0; } }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--sun); color: var(--sun-ink); font-weight: 900; padding: 10px 18px; border-radius: 999px;
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 380px) {
  .today { flex-direction: column; align-items: stretch; }
  .ring-wrap { margin: 0 auto; }
}
.item-src { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }

/* "Something missing or wrong?" under a scan: chips + a note, one free re-read of the same photo. */
.blindspot { font-size: 12px; color: var(--muted); margin: 8px 2px 0; }
.fix { margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.fix[hidden] { display: none; }
.fix summary { cursor: pointer; font-weight: 700; font-size: 14px; color: var(--accent-text); }
.fix-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 8px; }
.fix-chips button { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 6px 10px; font-size: 13px; }
.fix-chips button.on { border-color: var(--accent); color: var(--accent-text); }
.fix-row { display: flex; gap: 8px; }
.fix-row .text-input { flex: 1; min-width: 0; }
.fix-row .btn { flex: 0 0 auto; padding: 10px 14px; }

/* Meal sheet as an editor: logged meals open without the photo; amounts can be typed; counted foods show pieces. */
.sheet.editing .sheet-photo, .sheet.editing .blindspot, .sheet.editing .fix { display: none; }
.stepper .amt { display: flex; align-items: baseline; justify-content: center; gap: 3px; min-width: 66px; }
.stepper .amt span { min-width: 0; color: var(--muted); font-size: 12px; }
.stepper input { width: 44px; padding: 0; border: 0; background: none; color: var(--text); font: inherit; font-size: 16px; font-weight: 700; text-align: right; -moz-appearance: textfield; appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.add-food { width: 100%; margin: 0 0 10px; padding: 10px 14px; }

/* Apple Health / Health Connect (phone app only, engine/client/health.js) */
.btn-gap { width: 32px; flex: none; }
.meal.dup .wo-kcal { color: var(--muted); text-decoration: line-through; }
.health-box { padding: 12px 14px; margin-bottom: 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.health-box p { margin: 0 0 8px; }
.health-head { font-size: 15px; }
.health-state { color: var(--accent-text); font-size: 13px; font-weight: 700; margin-left: 4px; }

/* Quick add (⭐ saved meals, copy yesterday), describe a meal, portions and typed calories (engine/client/meals.js) */
.meal .icon-btn { padding: 6px 4px; min-width: 0; }
.icon-btn.star:not(.on) { filter: grayscale(1); opacity: .35; }
.chip.copy { border-style: dashed; }
.sheet-name { display: flex; align-items: center; gap: 6px; }
.sheet-name input { flex: 1; min-width: 0; font: inherit; color: inherit; background: none; border: 0; border-bottom: 1px dashed transparent; border-radius: 0; padding: 2px 0; }
.sheet-name input:hover, .sheet-name input:focus { border-bottom-color: var(--muted); outline: none; }
.sheet-name input:focus-visible { border-bottom-color: var(--focus); border-bottom-style: solid; }
.sheet-name span { font-size: 14px; opacity: .55; pointer-events: none; }
.portions { display: flex; align-items: center; gap: 6px; margin: 10px 0; }
.portions[hidden] { display: none; }
.portions span { font-size: 13px; color: var(--muted); margin-right: 2px; }
.portions button { min-width: 44px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 6px 10px; font-size: 14px; font-weight: 700; }
.portions button.on { border-color: var(--accent); color: var(--accent-text); }
.kcal-box { display: inline-flex; align-items: baseline; gap: 3px; margin-left: auto; white-space: nowrap; }
.kcal-box input { width: 56px; padding: 2px 5px; border: 1px solid var(--line); border-radius: 8px; background: var(--input-bg); color: var(--text); font: inherit; font-size: 16px; font-weight: 800; text-align: right; -moz-appearance: textfield; appearance: textfield; }
.kcal-box input::-webkit-outer-spin-button, .kcal-box input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.kcal-box input:focus { outline: 2px solid var(--focus); outline-offset: 0; }
.kcal-box input:disabled { border-color: transparent; background: none; }
.kcal-box span { font-size: 12px; color: var(--muted); }
.sheet-total .kcal-box { margin-left: 0; }
.kcal-box.big input { width: 76px; font-size: 20px; }
.results .r-special { border: 1px solid var(--accent); }
.results .r-special .r-name { color: var(--accent-text); font-weight: 800; }
.results .r-special:disabled { border-color: var(--line); opacity: .6; }
.sheet.described .sheet-photo, .sheet.described .blindspot, .sheet.described .fix { display: none; }

/* Your day (Settings): day start, hide calorie numbers */
.set-h { font-size: 13px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
.day-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 4px; font-weight: 700; }
.day-row select { width: auto; min-width: 150px; }
#hide-help a { color: var(--accent-text); }
.seg[hidden] { display: none; }
/* "Don't estimate" (fiber and sugar for photo meals) is the longest choice: one line, also on a 320 px phone. */
#subs-seg span { white-space: nowrap; }
@media (max-width: 350px) { #subs-seg span { font-size: 14px; padding: 10px 4px; } }
/* Hide calorie numbers: every calorie and macro figure goes; amounts (grams, pieces) and the ring and bars stay. */
.hide-kcal .kc, .hide-kcal .meal-kcal, .hide-kcal .item-macros, .hide-kcal .kcal-box,
.hide-kcal #sheet-total, .hide-kcal #portion-per100, .hide-kcal #pt-macros, .hide-kcal #eaten-line,
.hide-kcal #p-text, .hide-kcal #c-text, .hide-kcal #f-text, .hide-kcal #wo-total, .hide-kcal .plan-kcal { display: none !important; }
.hide-kcal .ring-text small { font-size: 15px; font-weight: 700; color: var(--text); }

/* Reduce motion (a phone or computer setting): nothing animates or slides, here or in the rules added below. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- the patch (added by the screens) ---------- */

/* The plant drawings (plants.js): one hidden sheet of symbols at the top of the page, taken out of the flow so it
   leaves no gap above the header, and the small <svg class="plant"> / <svg class="bloom"> that point at it. */
.sprites { position: absolute; width: 0; height: 0; overflow: hidden; }
.plant { display: block; width: 40px; height: 40px; }
.bloom { display: block; width: 24px; height: 24px; }
/* Words for screen readers only (a bloomed week, the label in front of today's plant). */
.vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* The header: "Munch Patch" and the account pill each stay on one line. On phones the name is set a little smaller,
   and on narrow ones the pill and the name lose their icons. If it still cannot fit, the name is cut short with
   dots sooner than the page scrolls sideways. */
.top { gap: 8px; }
.brand { min-width: 0; }
.brand img { flex: none; }
.brand span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { flex: none; }
.save-pill { white-space: nowrap; }
@media (max-width: 420px) {
  .brand { font-size: 19px; gap: 8px; }
  .brand img { width: 30px; height: 30px; }
  .save-pill:not(.signed-in) { font-size: 13px; padding: 7px 10px; }
  .save-pill:not(.signed-in) > span { display: none; }
}
@media (max-width: 372px) {
  .brand img { display: none; }
}
@media (max-width: 340px) {
  .brand { font-size: 18px; }
  .save-pill:not(.signed-in) { font-size: 12px; padding: 7px 8px; }
}

/* The patch sits on the page itself, not in a card, so the bed gets the full width on a small phone.
   Head: the month and its arrows on one row, the line about it and the Year button on the next. */
.patch { margin-bottom: 14px; }
.patch-head { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 0 8px; margin-bottom: 8px; }
.patch-title { grid-column: 1 / 3; margin: 0; font-family: var(--serif); font-weight: 600; font-size: 30px; line-height: 1.15; letter-spacing: 0; text-transform: none; color: var(--text); }
.patch-nav { grid-column: 3; justify-self: end; display: flex; gap: 4px; }
.patch-nav .icon-btn { display: grid; place-items: center; padding: 0; color: var(--text); }
.patch-nav .icon-btn svg { width: 22px; height: 22px; }
.patch-nav .icon-btn:disabled { opacity: .35; cursor: default; }
.patch-nav .icon-btn:disabled:hover { background: none; }
.patch-sub { grid-column: 1; margin: 0; font-size: 14px; color: var(--muted); }
.patch-year { justify-self: end; min-height: 44px; padding: 0 16px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); font-weight: 800; font-size: 14px; }
.patch-year:hover { background: var(--hover); }

/* The raised bed: a wooden edge round seven columns of plots. The weekday letters share the plots' columns. */
.bed { background: var(--bed); border: 4px solid var(--bed-edge); border-radius: 22px; padding: 10px 10px 12px; }
.patch-days, .patch-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.patch-days { margin-bottom: 6px; }
.patch-days span { text-align: center; font-size: 11px; font-weight: 800; color: var(--text); }
.patch-grid { display: grid; gap: 5px; }
.patch-row { position: relative; }

/* One day. Bare soil is the pale plot; a planted day is the warm tan one, the same in both themes, so it glows at
   dusk. The plant stands on the bottom edge and the day number sits in the top corner. */
.plot {
  position: relative; display: flex; align-items: flex-end; justify-content: center; min-width: 0; height: 44px; padding: 0;
  border: 0; border-radius: 10px; background: var(--soil-empty); color: var(--soil-empty-ink);
}
.plot.planted { background: var(--soil); color: var(--soil-ink); }
.plot:disabled { cursor: default; }
.plot-n { position: absolute; top: 3px; left: 5px; font-size: 10px; font-weight: 800; line-height: 1; }
.plot .plant { width: min(100%, 38px); height: auto; aspect-ratio: 1; pointer-events: none; }
/* Today: a ring round the plot, and its number on a small pill so the ring is not the only sign. */
.plot.today { box-shadow: 0 0 0 3px var(--accent); }
.plot.today .plot-n { top: 2px; left: 2px; padding: 2px 4px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); }
.plot:focus-visible, .patch-year:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; z-index: 1; }
/* A bloomed week: the bloom sits over the right-hand edge of the bed, in line with its row. */
.patch-row .bloom { position: absolute; top: 50%; right: -19px; margin-top: -12px; pointer-events: none; }
.patch-line { margin: 8px 4px 0; font-size: 13px; color: var(--muted); }

/* Today's plot and its line, under the ring and the bars. */
.today { flex-wrap: wrap; row-gap: 12px; }
.today-plant { flex: 1 1 100%; display: flex; align-items: center; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.tp-plot { flex: none; display: flex; align-items: flex-end; justify-content: center; width: 48px; height: 48px; border-radius: 12px; background: var(--soil-empty); }
.tp-plot.planted { background: var(--soil); }
.tp-plot .plant { width: 42px; height: 42px; }
.tp-text { margin: 0; min-width: 0; font-size: 14px; line-height: 1.35; color: var(--muted); }
.tp-text b { display: block; font-size: 15px; color: var(--text); }

/* The plan reveal after the opening questions: a first plot with a sprout in it. */
.plan-plot { flex: none; display: flex; align-items: flex-end; justify-content: center; width: 64px; height: 64px; border-radius: 16px; background: var(--soil); }
.plan-plot .plant { width: 54px; height: 54px; }

/* Small phones (down to 320 px): a little less padding so the plots stay wide enough for the plants. */
@media (max-width: 380px) {
  .patch-title { font-size: 26px; }
  .patch-sub { font-size: 13px; }
  .bed { padding: 8px 8px 10px; }
  .patch-days, .patch-row, .patch-grid { gap: 4px; }
  .patch-row .bloom { right: -17px; }
}
/* Phones (up to about 400 px): the bed reaches into the page's side gutters and its gaps tighten, so a plot is at
   least 44 px wide to tap from 360 px up (48 px at 390). At 320 px seven 44 px plots cannot fit: they are 38 px. */
@media (max-width: 397px) {
  .bed { margin-inline: -8px; border-width: 3px; padding: 6px 6px 8px; }
  .patch-days, .patch-row, .patch-grid { gap: 3px; }
  .patch-row .bloom { right: -16px; }
}
/* Room to spare (the page is 520 px at its widest): taller plots and bigger plants. */
@media (min-width: 460px) {
  .plot { height: 52px; }
  .plot .plant { width: min(100%, 46px); }
  .plot-n { font-size: 11px; }
}

/* ---------- the sheets and the small moments ---------- */

/* Share on the patch card: a round button beside Year (the row is already 44 px tall, so it adds no height). */
.patch-tools { grid-column: 2 / 4; display: flex; align-items: center; gap: 6px; justify-self: end; }
.patch-share { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); }
.patch-share svg { width: 20px; height: 20px; }
.patch-share:hover { background: var(--hover); }
.patch-share:focus-visible, .year-month:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* A toast can be two short sentences ("Planted ✓ New in your patch: Tulip"): it may use the width of the phone,
   and when it wraps it keeps round corners in place of the pill. One line looks as it did. */
.toast { width: max-content; max-width: calc(100vw - 32px); border-radius: 22px; text-align: center; }

/* The day sheet: the plot large, the date and how the day went beside it, then that day's meals. */
.day-top { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.day-plot { flex: none; display: flex; align-items: flex-end; justify-content: center; width: 96px; height: 96px; border-radius: 22px; background: var(--soil-empty); }
.day-plot.planted { background: var(--soil); }
.day-plot .plant { width: 86px; height: 86px; }
.day-words { min-width: 0; }
.day-words h2 { margin: 0 0 2px; font-family: var(--serif); font-weight: 600; font-size: 21px; line-height: 1.2; }
.day-stage { margin: 0; font-size: 16px; font-weight: 700; color: var(--text); }
/* How a finished day went, in words. Never a warning colour: "Close enough" is the soft green, the rest are plain. */
.band-pill { display: inline-block; margin: 8px 0 0; padding: 5px 12px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); font-size: 13px; font-weight: 800; }
.band-pill.in { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); }
.band-pill[hidden] { display: none; }
/* Edit and delete are full-size targets here: there is no star in the row, so there is room. */
.day-meals .meal { gap: 6px; padding-right: 6px; }
.day-meals .icon-btn { min-width: 44px; padding: 6px; }
.day-meals .meal-kcal { margin-left: 4px; }
#day-empty { margin: 0; }
#day-total { margin-top: 10px; }
#day-total[hidden] { display: none; }

/* The year sheet: twelve small beds, three across (four when there is room), a dot a day. */
.year-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; }
.year-head h2 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 26px; line-height: 1.15; }
.year-head .patch-nav[hidden] { display: none; }
.year-sub { margin: 0 0 10px; }
.year-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.year-month { display: grid; align-content: start; gap: 5px; min-width: 0; min-height: 44px; padding: 6px 7px 8px; border: 3px solid var(--bed-edge); border-radius: 14px; background: var(--bed); color: var(--text); text-align: left; }
.year-month:disabled { opacity: .45; cursor: default; }
/* The month the patch card is showing: the same ring as today's plot. */
.year-month.on { box-shadow: 0 0 0 3px var(--accent); }
.ym-name { font-size: 12px; font-weight: 800; line-height: 1.2; }
.ym-bed { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
/* A dot a day, by how far the plot got. Shape as well as colour, so no two stages are told apart by shade alone:
   bare soil (a pale dot), sprout (a small green dot), growing (a full green dot), in bud or nearly ripe (a marigold
   diamond, like a closed bud), in flower or ripe (a pink dot with a marigold centre, like the weekly bloom). */
.yd { display: block; height: 0; padding-top: 100%; border-radius: 50%; background: var(--soil-empty); } /* as tall as it is wide */
.yd.gap { background: none; }
.yd.s1 { background: var(--accent-text); transform: scale(.55); }
.yd.s2 { background: var(--accent-text); }
/* Marigold and pink are close to the bed's tan in the light theme: a thin darker edge keeps them readable. */
.yd.s3 { background: var(--sun); border-radius: 22%; transform: rotate(45deg) scale(.78); box-shadow: inset 0 0 0 1.5px var(--sun-text); }
.yd.s4 { background: radial-gradient(circle, var(--sun) 0 30%, var(--pink) 38%); box-shadow: inset 0 0 0 1px var(--sun-text); }
/* What the dots mean, on a strip of the same bed colour so they look as they do above. */
.year-key { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 10px 0 14px; padding: 8px 10px; border-radius: 12px; background: var(--bed); color: var(--text); font-size: 12px; font-weight: 700; }
.year-key li { display: flex; align-items: center; gap: 5px; }
.year-key .yd { flex: none; width: 10px; height: 10px; padding: 0; }
.share-note { margin: 6px 0 0; }

@media (max-width: 380px) {
  .day-top { gap: 12px; }
  .day-plot { width: 80px; height: 80px; border-radius: 18px; }
  .day-plot .plant { width: 72px; height: 72px; }
  .day-words h2 { font-size: 19px; }
  .year-grid { gap: 6px; }
  .year-month { padding: 5px 6px 7px; }
}
@media (min-width: 460px) {
  .year-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---------- the finishing pass ---------- */

/* "Use a photo of the barcode" is a label that takes the keyboard's focus (the scan button has its ring already). */
.photo-link:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
/* Until the script has drawn it, the ring is empty, not full (a full ring reads as a day already used up). The
   numbers are the ring's own length, 2 x pi x 52; the script sets the real ones on the element, which wins. */
.ring-fg { stroke-dasharray: 326.73; stroke-dashoffset: 326.73; }

/* ---------- the garden ---------- */

/* Ways in. On the patch card, Garden sits beside Year (the same pill). On small phones the two pills are a little
   tighter, so the line beside them keeps to two rows of words. On the narrowest (320 px) there is no room for
   both: the line gets the full width and the three buttons a row of their own under it. */
@media (max-width: 370px) {
  .patch-tools { gap: 5px; }
  .patch-tools .patch-year { padding: 0 11px; font-size: 13px; }
}
@media (max-width: 340px) {
  .patch-sub, .patch-tools { grid-column: 1 / -1; }
  .patch-tools { justify-self: start; margin-top: 6px; }
}
/* In the year sheet: how many plants are found so far, and the button that opens the garden. */
.garden-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding: 8px 8px 8px 14px; border: 1px dashed var(--line); border-radius: 14px; }
.garden-row p { margin: 0; min-width: 0; font-weight: 700; }
.garden-row .btn { flex: none; min-height: 44px; padding: 10px 16px; font-size: 15px; }
.garden-row .btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
/* On the narrowest phones there is no room for the words beside the button (they broke onto three or four
   lines): the words take the row, and the button goes under them. */
@media (max-width: 350px) {
  .garden-row { flex-wrap: wrap; gap: 6px 12px; }
  .garden-row p { flex: 1 0 100%; }
}

/* The sheet. It is as wide as the phone and nearly as tall (the other sheets keep a margin at the sides), and the
   picture runs edge to edge in it, so the plants are as big as the phone allows. The picture is a long walk down
   the year, more than two screens tall: the sheet scrolls (never sideways, and never the page behind it), a small
   header stays in view over the picture, and the card for the plant that was tapped is pinned to the foot.
   (No scroll-padding here: it would make the sheet creep up each time the keyboard moved along the header's own
   buttons. The script keeps a plant the keyboard lands on clear of the header and the card.)
   In a computer window, where a scrollbar takes room, it is a thin one in the theme's own line colour. */
#garden-sheet { max-width: 100vw; max-height: 96dvh; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
html.garden-open { overflow: hidden; }

/* The header: the name, the line of numbers, a button for each season's bed, Close. It keeps the sheet's own
   colour, so the picture slides under it cleanly. Every button is 44 px to the finger; the pill drawn inside it
   is smaller, which keeps the header low. */
.garden-head { position: sticky; top: 0; z-index: 3; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0 8px; padding: 2px 12px 0; border-bottom: 1px solid var(--line); background: var(--panel); }
.sheet .garden-title { margin: 0; padding-left: 4px; font-family: var(--serif); font-weight: 600; font-size: 22px; line-height: 1.15; }
/* The heading takes the focus when the sheet opens, so a screen reader starts at the top. It is not a control. */
.garden-title:focus { outline: none; }
/* The line of numbers is pulled up under the name and lies over the foot of Close: it takes no tap itself, so
   the whole of Close does. */
.garden-line { grid-column: 1 / -1; margin: -6px 0 0; padding-left: 4px; font-size: 13px; font-weight: 700; color: var(--muted); pointer-events: none; }
.gh-close, .gh-season { min-height: 44px; padding: 0; border: 0; background: none; font-weight: 800; color: var(--text); }
.gh-close span, .gh-season span { display: block; border: 1px solid var(--line); border-radius: 999px; background: var(--panel-2); line-height: 18px; white-space: nowrap; }
.gh-close { padding-left: 10px; font-size: 14px; }
.gh-close span { padding: 5px 14px; }
.gh-seasons { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.gh-season { font-size: 13px; }
.gh-season span { padding: 5px 0; text-align: center; }
.gh-close:hover span, .gh-season:hover span { background: var(--hover); }
/* The season it is today: a green pill with a dot in it (not colour alone). */
.gh-season[aria-current] span { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-text); }
.gh-season[aria-current] span::before { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 5px 2px 0; border-radius: 50%; background: var(--accent); vertical-align: middle; }
.gh-close:focus-visible, .gh-season:focus-visible { outline: none; }
.gh-close:focus-visible span, .gh-season:focus-visible span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* The picture's box. The script gives it the picture's own shape (garden.js says how wide and tall it is); the
   shape here is close to it, for the moment before that. */
.garden-scene { aspect-ratio: 390 / 1450; overflow: hidden; background: var(--panel-2); }
.garden-scene > svg { display: block; width: 100%; height: 100%; }
/* A plant or a seed mound is a button drawn in the picture. The last thing in each is an unseen box for the
   finger (garden.js puts it there, over the drawing): it takes the tap wherever it lands, and the ring is drawn
   on it, for the keyboard and for the plant whose card is showing. The ring keeps its width on every phone. */
.garden-scene .gd-plant, .garden-scene .gd-seed { cursor: pointer; outline: none; -webkit-tap-highlight-color: transparent; }
.garden-scene .gd-plant > rect:last-child, .garden-scene .gd-seed > rect:last-child { pointer-events: all; fill: none; stroke-width: 3px; vector-effect: non-scaling-stroke; }
.garden-scene .on > rect:last-child { opacity: 1; stroke: var(--sun-text); }
.garden-scene .gd-plant:focus-visible > rect:last-child, .garden-scene .gd-seed:focus-visible > rect:last-child { opacity: 1; stroke: var(--focus); stroke-width: 4px; }
/* At dusk the two rings are the same gold, so for someone using the keyboard they are told apart by shape: while
   the keyboard's ring is showing anywhere else in the sheet, the ring of the plant whose card is open is dashed,
   and the keyboard's own ring is always solid. Under a finger or a mouse the picked plant's ring stays solid. */
#garden-sheet:has(:focus-visible) .garden-scene .on:not(:focus-visible) > rect:last-child { stroke-dasharray: 9 6; stroke-linecap: round; }
/* The scenery never takes a tap (the picture says so too). */
.garden-scene [aria-hidden="true"] { pointer-events: none; }

/* The card for the plant that was tapped: its drawing large on a soil tile, the words, and its own way to close
   it. It stays at the foot of the sheet wherever the picture is scrolled to; at the very end it comes to rest
   between the picture and the buttons. */
.garden-card { position: sticky; bottom: 0; z-index: 2; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); }
.garden-card[hidden] { display: none; }
.gc-body { display: flex; align-items: center; gap: 14px; }
.gc-plot { flex: none; display: flex; align-items: flex-end; justify-content: center; width: 84px; height: 84px; border-radius: 20px; background: var(--soil-empty); }
.gc-plot.planted { background: var(--soil); }
.gc-plot .plant { width: 76px; height: 76px; }
.gc-words { flex: 1; min-width: 0; }
/* The name keeps clear of the card's close button, which sits in the corner beside it; the lines under the name
   run the full width. */
.gc-words h3 { margin: 0 0 2px; padding-right: 36px; font-family: var(--serif); font-weight: 600; font-size: 21px; line-height: 1.2; letter-spacing: 0; text-transform: none; color: var(--text); }
.gc-words p { margin: 0; font-size: 14px; line-height: 1.35; color: var(--text); }
.gc-words .gc-when { margin-bottom: 4px; font-weight: 700; color: var(--muted); }
.gc-close { position: absolute; top: 1px; right: 2px; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); }
.gc-close svg { width: 20px; height: 20px; }
.gc-close:hover { background: var(--panel-2); }
/* The button sits against the sheet's edge, which would cut a ring drawn round it: the ring is drawn inside. */
.gc-close:focus-visible { outline-offset: -3px; }

/* The end of the picture: the way to share it, and Close. */
.garden-foot { padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); }
@media (max-width: 380px) {
  .sheet .garden-title { font-size: 20px; }
  .gc-body { gap: 12px; }
  .gc-plot { width: 72px; height: 72px; border-radius: 18px; }
  .gc-plot .plant { width: 64px; height: 64px; }
  .gc-words h3 { font-size: 19px; }
}
/* The narrowest phones: the header's words a touch smaller, so the line of numbers stays on one line for years
   and today's pill keeps some air round its name. */
@media (max-width: 340px) {
  .garden-line, .gh-season { font-size: 12.5px; }
  .gh-seasons { gap: 4px; }
}

/* Gentle life in the picture, only for people who have not asked for less motion, and only while the sheet is
   open (a closed sheet is not drawn at all, and its picture is taken out). The picture is large, so everything
   that moves only turns, slides or fades (transform and opacity): nothing changes its size or its place in the
   page. The classes are put on by garden.js, on things that carry no transform or opacity of their own. */
@media (prefers-reduced-motion: no-preference) {
  /* A plant turns a little about its own foot. garden.js wraps each plant's drawing in the group that sways, and
     the script tells that group where the foot is; the pivot here (the middle of the foot of the drawing) is only
     for a picture it could not read. Neighbours keep different time. */
  #garden-sheet[open] .gd-sway { transform-box: fill-box; transform-origin: 50% 100%; animation: gd-sway 7s ease-in-out infinite alternate; }
  #garden-sheet[open] .gd-plant:nth-of-type(2n) .gd-sway { animation-duration: 8.6s; animation-delay: -3s; }
  #garden-sheet[open] .gd-plant:nth-of-type(3n) .gd-sway { animation-duration: 6.2s; animation-delay: -1.6s; }
  /* Lantern light, the lamps on today's bed, fireflies and a few stars breathe. */
  #garden-sheet[open] .gd-glow { animation: gd-glow 4.6s ease-in-out infinite alternate; }
  #garden-sheet[open] .gd-glow:nth-of-type(2n) { animation-duration: 6s; animation-delay: -2s; }
  #garden-sheet[open] .gd-glow:nth-of-type(3n) { animation-duration: 5.2s; animation-delay: -3.4s; }
  /* The clouds cross slowly, one each way. */
  #garden-sheet[open] .gd-drift { animation: gd-drift 48s ease-in-out infinite alternate; }
  #garden-sheet[open] .gd-drift + .gd-drift { animation-duration: 64s; animation-direction: alternate-reverse; }
  /* Butterflies and bees bob where they are, about their own middle. */
  #garden-sheet[open] .gd-flutter { transform-box: fill-box; transform-origin: 50% 50%; animation: gd-flutter 3.4s ease-in-out infinite alternate; }
  #garden-sheet[open] g:nth-of-type(2n) > .gd-flutter { animation-duration: 4.1s; animation-delay: -1.3s; }
  @keyframes gd-sway { from { transform: rotate(-1.8deg); } to { transform: rotate(1.8deg); } }
  @keyframes gd-glow { from { opacity: 1; } to { opacity: .5; } }
  @keyframes gd-drift { from { transform: translateX(-6px); } to { transform: translateX(16px); } }
  @keyframes gd-flutter { from { transform: translate(0, 0) rotate(-6deg); } to { transform: translate(3px, -4px) rotate(8deg); } }
}
