/* A thin layer over vendor/pico.css (Pico CSS v2, MIT) with Libron or Inter (both OFL) and Lucide icons (ISC), all self-hosted. */
@font-face {
  font-family: "Inter";
  font-weight: 100 900;
  font-display: swap;
  src: url(vendor/inter-latin-wght-normal.woff2) format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-weight: 100 900;
  font-display: swap;
  src: url(vendor/inter-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Libron (OFL, see vendor/libron/OFL.txt): static weights only, so Pico's 500/600 use the regular/bold files. */
@font-face {
  font-family: "Libron";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url(vendor/libron/Libron-Regular.woff2) format("woff2");
}
@font-face {
  font-family: "Libron";
  font-weight: 400;
  font-style: italic;
  font-display: swap;
  src: url(vendor/libron/Libron-Italic.woff2) format("woff2");
}
@font-face {
  font-family: "Libron";
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  src: url(vendor/libron/Libron-Bold.woff2) format("woff2");
}
@font-face {
  font-family: "Libron";
  font-weight: 700;
  font-style: italic;
  font-display: swap;
  src: url(vendor/libron/Libron-BoldItalic.woff2) format("woff2");
}
:root {
  --pico-font-family: "Libron", Georgia, serif;
  --pico-border-radius: 0.75rem;
  --pico-form-element-spacing-vertical: 0.7rem;
  --pico-spacing: 1rem;
}
/* Libron is the default; the Aa button in the top bar switches to Inter (see font.js) and remembers the choice. */
:root[data-font="inter"] {
  --pico-font-family: "Inter", system-ui, sans-serif;
}
.topbar .font-toggle {
  width: auto;
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
  color: var(--pico-muted-color);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
body {
  background: var(--pico-background-color);
  min-height: 100vh;
}
@media (prefers-color-scheme: light) {
  body {
    background: linear-gradient(180deg, #eef3ff 0, #f8f9fc 16rem);
  }
}
main.container {
  max-width: 28rem;
  padding: 1rem 1rem 3rem;
  position: relative;
  z-index: 1;
}
.icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  vertical-align: -0.2em;
}

/* ambient aurora background, on every page: slow drifting blurred blobs behind all content.
   Explicit non-negative z-index (0, with main.container promoted to 1) instead of relying on
   negative-z-index-vs-canvas-background behavior, which is inconsistent across engines. */
.aurora {
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.aurora span {
  position: absolute;
  width: 50vw;
  height: 50vw;
  max-width: 38rem;
  max-height: 38rem;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.28;
}
.aurora span:nth-child(1) {
  background: #4f46e5;
  top: -12%;
  left: -4%;
  animation: aurora1 18s ease-in-out infinite;
}
.aurora span:nth-child(2) {
  background: var(--pico-primary-background);
  bottom: -14%;
  right: -6%;
  animation: aurora2 22s ease-in-out infinite;
}
.aurora span:nth-child(3) {
  background: #22d3ee;
  top: 32%;
  right: 16%;
  opacity: 0.16;
  animation: aurora3 26s ease-in-out infinite;
}
@keyframes aurora1 {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  50% {
    transform: translate(6%, 8%) scale(1.15);
  }
}
@keyframes aurora2 {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  50% {
    transform: translate(-8%, -6%) scale(1.1);
  }
}
@keyframes aurora3 {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  50% {
    transform: translate(-10%, 10%) scale(1.2);
  }
}
@media (prefers-reduced-motion: reduce) {
  .aurora span {
    animation: none;
  }
}

/* login card: spinning glow ring around the edge, via the standard two-layer-background
   gradient-border technique (not mask-composite, which silently fails to clip in some
   browsers and collapses the ring to an invisible sliver hidden behind the card). */
.login-card {
  position: relative;
  border-radius: var(--pico-border-radius);
  padding: 1.6rem 1.4rem;
  margin-top: 2.5rem;
  border: 2px solid transparent;
  box-shadow: var(--pico-card-box-shadow);
  background:
    linear-gradient(var(--pico-card-background-color), var(--pico-card-background-color)) padding-box,
    conic-gradient(from var(--ring-angle, 0deg), transparent 0 60%, var(--pico-primary-background) 75%, #22d3ee 85%, transparent 100%)
      border-box;
  animation: ring-spin 3.2s linear infinite;
}
@property --ring-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}
@keyframes ring-spin {
  to {
    --ring-angle: 360deg;
  }
}
@media (prefers-reduced-motion: reduce) {
  .login-card {
    animation: none;
  }
}

/* top row: log out (left), back to the app list (middle, absent on the pages that have none), language (right) */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}
.topbar a {
  color: var(--pico-muted-color);
  text-decoration: none;
}
.topbar a.on {
  color: var(--pico-color);
  font-weight: 600;
}
.topbar .start {
  justify-self: start;
}
.topbar .end {
  justify-self: end;
  display: flex;
  gap: 0.9rem;
}
.topbar .logout,
.topbar .back {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.topbar .back {
  color: var(--pico-color);
  font-weight: 600;
}

/* which page this is: the app's name, big, where the old tab row was */
.page-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.5rem 0 1rem;
  font-size: 1.6rem;
}
.page-title .icon {
  width: 1.3em;
  height: 1.3em;
}

/* the landing page: one big tile per app */
nav.apps {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
nav.apps a {
  flex-direction: column;
  gap: 0.7rem;
  padding: 1.8rem 0.5rem;
  font-size: 1.05rem;
}
nav.apps a {
  position: relative;
}
nav.apps .badge {
  position: absolute;
  top: 0.5rem;
  right: 0.7rem;
  min-width: 1.4rem;
  padding: 0 0.4rem;
  border-radius: 1rem;
  background: var(--pico-del-color);
  color: #fff;
  font-size: 0.8rem;
  text-align: center;
}
#tasks li.late small {
  color: var(--pico-del-color);
}
#who {
  margin-top: 1rem;
}
nav.apps .icon {
  width: 2rem;
  height: 2rem;
}

/* A link that reads as plain muted text with an icon (like "Log out") rather than a classic
   underlined/colored link - still clearly clickable (icon + hover color), just calmer. */
.muted-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--pico-muted-color);
  text-decoration: none;
}
.muted-link:hover {
  color: var(--pico-color);
}
.muted-link .icon {
  width: 1em;
  height: 1em;
}

/* sub-page tabs — the active tab just jumps to a solid fill, no sliding/glow, no transition on .on itself. */
nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
nav a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.7rem 0.4rem;
  border-radius: var(--pico-border-radius);
  border: 1px solid var(--pico-muted-border-color);
  background: var(--pico-card-background-color);
  color: var(--pico-color);
  text-decoration: none;
  font-weight: 600;
}
nav a:hover {
  background: var(--pico-secondary-background);
}
nav a.on {
  background: var(--pico-primary-background);
  border-color: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
}
nav[data-nav="sub"] {
  margin-bottom: 1.5rem;
  flex-wrap: wrap; /* four tabs do not fit a phone in one row */
}
nav[data-nav="sub"] a {
  flex: 1 1 auto;
  padding: 0.5rem 0.4rem;
  font-size: 0.9rem;
  font-weight: 500;
}
@media (prefers-reduced-motion: no-preference) {
  nav a {
    transition: transform 0.15s cubic-bezier(0.22, 1, 0.36, 1);
  }
  nav a:hover {
    transform: translateY(-1px);
  }
  nav a:active {
    transform: translateY(0) scale(0.97);
  }
}

/* forms */
form {
  display: grid;
  gap: 1rem;
  margin: 0;
}
form > *,
details > * {
  margin-bottom: 0;
}
/* align-content:start stops a label stretched taller than its content (e.g. by a .row sibling
   with a taller column) from distributing the leftover space unevenly between its own text
   and control rows — without it, two labels of identical content can end up with their
   control sitting at different heights purely from how that leftover space got divided. */
/* flex column, not grid: a grid's sole "auto" row track stretches to fill a taller container
   even with align-content:start (verified in a real browser — it's a genuine grid quirk, not
   just a missing property). Flex items default to their own natural/explicit size and pack at
   the start, which is what every label here actually wants. */
label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--pico-muted-color);
}
label > input,
label > select,
label .ghost,
label .password-field {
  margin-bottom: 0;
}
/* Force every text input and select to the exact same box height, overriding Pico's own
   higher-specificity `select:not([multiple],[size])` padding rule with !important — relying
   on equal padding alone wasn't enough to keep them pixel-aligned in every browser. */
input:not([type="checkbox"]),
select {
  margin-bottom: 0;
  font-size: 1rem;
  box-sizing: border-box !important;
  line-height: var(--pico-line-height) !important;
  padding-block: var(--pico-form-element-spacing-vertical) !important;
  border-width: var(--pico-border-width) !important;
  height: calc(1rem * var(--pico-line-height) + var(--pico-form-element-spacing-vertical) * 2 + var(--pico-border-width) * 2) !important;
}

.password-field {
  position: relative;
  display: block;
}
.password-field input {
  width: 100%;
  padding-right: 2.6rem;
}
.password-toggle {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  background: none;
  border: none;
  color: var(--pico-muted-color);
  cursor: pointer;
}
.password-toggle:hover {
  color: var(--pico-color);
}
.row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0.75rem;
}
.row.even {
  grid-template-columns: 1fr 1fr;
}
button {
  font-weight: 600;
  margin-bottom: 0;
  box-shadow: 0 1px 2px #0002;
}
button.small,
a.small {
  width: auto;
  margin: 0; /* Pico gives buttons a bottom margin, which pushed them above a link beside them */
  padding: 0.3rem 0.8rem;
  font-size: 0.85rem;
  background: transparent;
  /* not var(--pico-color): a button redefines that one for itself (white, for text on the primary colour) */
  color: var(--pico-contrast);
  border: 1px solid var(--pico-muted-border-color);
  box-shadow: none;
  border-radius: var(--pico-border-radius);
  text-decoration: none;
  font-weight: 600;
}
button.small:hover,
a.small:hover {
  background: var(--pico-secondary-background);
}

/* cards */
details {
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  padding: 0.8rem 1rem;
  background: var(--pico-card-background-color);
  box-shadow: var(--pico-card-box-shadow);
  margin-bottom: 0;
}
details[open] {
  display: grid;
  gap: 0.75rem;
}
summary {
  font-weight: 600;
  margin-bottom: 0;
}
summary:focus-visible {
  outline: none;
}
#editing {
  margin: 0 0 1rem;
  padding: 0.6rem 0.9rem;
  border-radius: var(--pico-border-radius);
  background: var(--pico-primary-focus);
}
#last {
  margin-top: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  border-radius: var(--pico-border-radius);
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-muted-border-color);
}
#last[hidden],
#result[hidden],
#toast[hidden] {
  display: none;
}
.muted {
  color: var(--pico-muted-color);
}
.error {
  color: var(--pico-del-color);
  margin: 0;
}
#dupe {
  margin: -0.5rem 0 0;
  font-size: 0.85rem;
}

/* meal / food rows */
.part {
  margin-bottom: 0.75rem;
}
.part label {
  position: relative;
}
.part .unit {
  position: absolute;
  right: 0.8rem;
  bottom: 0.75rem;
  color: var(--pico-muted-color);
  pointer-events: none;
  font-size: 0.9rem;
}

/* result */
#result {
  margin-top: 1.75rem;
  padding: 1.1rem;
  border-radius: calc(var(--pico-border-radius) * 1.3);
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-muted-border-color);
  box-shadow: var(--pico-card-box-shadow);
}
#result h2 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
}
#result h2 #total {
  color: var(--pico-primary);
  font-variant-numeric: tabular-nums;
}
.list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}
.list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--pico-border-radius);
  background: var(--pico-form-element-background-color);
  border: 1px solid var(--pico-muted-border-color);
  margin: 0;
  font-size: 0.92rem;
  transition: transform 0.1s;
}
.list li:hover {
  transform: translateY(-1px);
}
.list li > :last-child {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.list small {
  display: block;
}
.item-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap; /* on a phone the buttons of a row go on a second line instead of pushing the page sideways */
  gap: 0.4rem;
}
.list li > :first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem;
  background: none;
  border: none;
  border-radius: 0.4rem;
  color: var(--pico-muted-color);
  cursor: pointer;
  box-shadow: none;
  margin-bottom: 0;
  width: auto;
}
.icon-button:hover {
  color: var(--pico-del-color);
  background: var(--pico-secondary-background);
}
.icon-button.delete .icon {
  width: 1.3em;
  height: 1.3em;
}

/* toast */
#toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  max-width: 24rem;
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  background: var(--pico-color);
  color: var(--pico-background-color);
  box-shadow: 0 6px 20px #0005;
  animation: pop 0.18s ease-out;
}
@keyframes pop {
  from {
    opacity: 0;
    transform: translate(-50%, 0.5rem);
  }
}

/* name field with greyed-out completion */
.ghost {
  position: relative;
  display: block;
}
#ghost {
  position: absolute;
  inset: 0;
  padding: var(--pico-form-element-spacing-vertical) var(--pico-form-element-spacing-horizontal);
  border: var(--pico-border-width) solid transparent;
  font: inherit;
  font-size: 1rem;
  white-space: pre;
  overflow: hidden;
  pointer-events: none;
  color: var(--pico-color);
}
#typed {
  visibility: hidden;
}
#rest {
  color: var(--pico-muted-color);
  opacity: 0.7;
  pointer-events: auto;
  cursor: pointer;
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* shopping list: a ticked line is struck through and sinks (the server sorts it below the rest) */
#shopping label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  font-weight: 400;
}
#shopping input[type="checkbox"] {
  margin: 0;
}
#shopping .bought label {
  text-decoration: line-through;
  color: var(--pico-muted-color);
}
#clear-bought,
#to-shopping {
  margin-top: 1rem;
}
#shopping input.got {
  width: 5.5rem;
  margin: 0 0.3rem 0 auto;
  padding: 0.25rem 0.5rem;
}
#stock li {
  flex-wrap: wrap;
}
#stock li.low {
  border-color: var(--pico-del-color);
}
#stock input.got,
#stock input.list-name {
  width: 5.5rem;
  margin: 0;
  padding: 0.25rem 0.5rem;
}
#shopping li.group {
  background: none;
  border: none;
  padding: 0.5rem 0 0;
  font-weight: 600;
}
#shopping li > .got + span {
  font-weight: 400;
}

/* calendar */
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cal-head h2 {
  margin: 0;
  font-size: 1.15rem;
  text-transform: capitalize;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.25rem;
  margin: 0.75rem 0 1rem;
}
.cal-name {
  text-align: center;
  font-size: 0.75rem;
  color: var(--pico-muted-color);
  text-transform: capitalize;
}
.cal-grid button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 2.9rem;
  margin: 0;
  padding: 0.25rem 0;
  background: var(--pico-form-element-background-color);
  border: 1px solid var(--pico-muted-border-color);
  color: inherit; /* not var(--pico-color): Pico sets that to white on every button */
  font-size: 0.9rem;
  box-shadow: none;
}
.cal-grid button small {
  line-height: 0.6;
  color: var(--pico-primary);
}
.cal-grid button.other {
  color: var(--pico-muted-color); /* dimmed by colour, not opacity: faded text is too faint to read */
}
.cal-grid button.today {
  font-weight: 700;
  border-color: var(--pico-primary);
}
.cal-grid button.on {
  background: var(--pico-primary);
  color: var(--on-primary);
}
.cal-grid button.on small {
  color: inherit;
}
#day-title {
  text-transform: capitalize;
  font-size: 1.05rem;
  margin: 0;
}
.cal-grid button {
  touch-action: none; /* dragging over days selects them instead of scrolling the page */
  user-select: none;
}

/* a checkbox with its text to the right, kept tight; the explanation goes under it as a .note */
label.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-weight: 400;
  width: fit-content;
}
label.check input {
  margin: 0;
  flex: none;
}
details .note {
  margin: 0.25rem 0 1rem;
  font-size: 0.85rem;
}

/* planner: a day's meals as small boxes (solid = dinner cooked, outlined = lunch eaten) */
.chip {
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin-top: 0.15rem;
  padding: 0 0.2rem;
  border: 1px solid var(--pico-primary);
  border-radius: 0.25rem;
  font-size: 0.6rem;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
/* cooking is solid; eating is outlined (a dinner) or dashed (a lunch) */
.chip.cook {
  background: var(--pico-primary);
  color: var(--on-primary);
}
.chip.dinner {
  color: var(--pico-primary);
}
.chip.lunch {
  color: var(--pico-primary);
  border-style: dashed;
}
.cal-grid button.on .chip.dinner,
.cal-grid button.on .chip.lunch {
  color: inherit;
  border-color: currentColor;
}
.cal-grid button.on .chip.cook {
  background: var(--on-primary);
  color: var(--pico-primary);
}
#meal-dialog .md-line {
  display: flex;
  gap: 0.75rem;
  margin: 0 0 0.5rem;
}
#meal-dialog .md-line strong {
  flex: none;
  min-width: 5.5rem;
}
#meal-dialog footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
#md-items {
  max-height: 40vh;
  overflow-y: auto;
}

/* cooking: the confirm dialog says what happens, and shouts about what would run short */
.warn {
  margin: 0.75rem 0 0;
  padding: 0.6rem 0.8rem;
  border-radius: var(--pico-border-radius);
  border: 1px solid var(--pico-del-color);
  background: color-mix(in srgb, var(--pico-del-color) 8%, transparent);
}
.warn p {
  margin: 0.2rem 0;
  font-weight: 600;
  color: var(--pico-del-color);
}
.warn p.muted {
  font-weight: 400;
  color: var(--pico-muted-color);
}
#cd-body p {
  margin: 0.3rem 0;
}
#cd-body p.ok {
  color: var(--pico-ins-color);
  font-weight: 600;
}
.plan-note {
  margin: 0 0 0.75rem;
  color: var(--pico-ins-color);
  font-weight: 600;
}
#cook-dialog footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* a cooked meal is history: green instead of blue */
.chip.done {
  border-color: var(--pico-ins-color);
  color: var(--pico-ins-color);
}
.chip.cook.done {
  background: var(--pico-ins-color);
  color: #fff;
}
.cal-grid button.on .chip.done:not(.cook) {
  color: inherit;
}
.ok-line {
  color: var(--pico-ins-color);
  font-weight: 600;
  margin: 1rem 0 0;
}
#check .warn ul {
  margin: 0.3rem 0 0.6rem;
  padding-left: 1.1rem;
}
#check .warn li {
  font-weight: 400;
}
#meal-dialog footer a[role="button"] {
  margin-right: auto;
}

/* planner views: a month of equal boxes with icons only, or a week as a list with full text and cost */
.view-switch {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
  margin-bottom: 0.5rem;
}
.view-switch button {
  margin: 0;
  background: transparent;
  color: var(--pico-primary); /* not var(--pico-color): Pico sets that to white on every button */
  border: 1px solid var(--pico-primary);
  box-shadow: none;
}
.view-switch button[aria-pressed="true"] {
  background: var(--pico-primary) !important; /* Pico has its own look for pressed buttons */
  color: var(--on-primary) !important;
}
.cal-grid .day-label {
  line-height: 1.2;
}
.cal-grid .icons {
  display: flex;
  justify-content: center;
  gap: 1px;
  height: 1rem; /* always reserved, so a day with meals is no taller than an empty one */
  overflow: hidden;
}
.icons .chip {
  display: inline-block;
  width: auto;
  margin: 0;
  padding: 0;
  border: none !important; /* icons alone: no boxes, whatever the day's state (selected, cooked) */
  background: none !important;
  font-size: 0.72rem;
  line-height: 1rem;
  color: inherit !important;
}
.icons .chip.done::after {
  content: "✓";
  font-size: 0.5rem;
  color: var(--pico-ins-color);
}
.cal-grid.week {
  grid-template-columns: 1fr;
  gap: 0.35rem;
}
.cal-grid.week button {
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  text-align: left;
  touch-action: pan-y; /* the list scrolls; days are picked by tapping (or dragging with a mouse) */
}
.cal-grid.week .day-label {
  flex: none;
  min-width: 5.5rem;
  font-weight: 600;
}
.cal-grid.week .chips {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: stretch;
  gap: 0.15rem;
}
.cal-grid.week .chip {
  font-size: 0.8rem;
  white-space: normal;
  text-overflow: clip;
  overflow: visible;
  margin: 0;
}
.cal-grid.week .cost {
  flex: none;
  min-width: 4.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
}
.week-total {
  text-align: right;
  font-weight: 600;
  margin: 0.25rem 0 1rem;
}

/* a meal that cannot be made (an ingredient's grocery is gone): orange, which stands out against all the blue */
:root {
  --broken: #e07a00;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --broken: #ff9a2e;
  }
}
:root[data-theme="dark"] {
  --broken: #ff9a2e;
}
small.broken,
.broken-note {
  color: var(--broken);
  font-weight: 600;
}
.broken-note {
  margin: 0 0 0.75rem;
}
.chip.broken {
  border-color: var(--broken);
  color: var(--broken);
}
.chip.cook.broken {
  background: var(--broken);
  color: #fff;
}
.cal-grid button.on .chip.broken:not(.cook) {
  color: #ffd9a8;
  border-color: #ffd9a8;
}
.icons .chip.broken::after {
  content: "⚠";
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--broken);
}
.icons .chip.broken {
  filter: sepia(1) saturate(6) hue-rotate(-10deg); /* the emoji itself turns orange too */
}

/* notes */
.new-note {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.note-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 0.75rem;
}
.note-nav a:not([role="button"]) {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  text-decoration: none;
}
.note-nav [role="button"],
.note-nav button {
  margin: 0;
  background: transparent;
  color: var(--pico-primary); /* not Pico's own: it is white text on a pale button */
  border: 1px solid var(--pico-primary);
  box-shadow: none;
}
#notes button.view {
  color: var(--pico-primary); /* like the Edit link beside it, not Pico's white button text */
}
.note-dialog article {
  width: min(42rem, 94vw);
  max-height: 85vh;
  overflow-y: auto;
  margin: 0;
}
.note-dialog header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.note-dialog header h3 {
  margin: 0;
  overflow-wrap: anywhere;
}
.note-dialog header .icon-button {
  flex: none;
  margin: 0;
}
.note-body {
  overflow-wrap: anywhere;
}
.note-body > :first-child {
  margin-top: 0;
}
.note-body pre,
.note-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.note-body table {
  display: block;
  overflow-x: auto;
}
.note-body input[type="checkbox"] {
  margin-right: 0.4rem;
}
.note-body img {
  max-width: 100%;
  height: auto;
}
#editor .cm-editor {
  min-height: 55vh;
}
#editor .cm-scroller {
  min-height: 55vh;
}
.note-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
}
.note-bar .muted {
  flex: 1;
}
.note-bar button {
  margin: 0;
  width: auto;
}

.day-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

/* shown by pwa.js while the phone has no connection and the pages come from what it saved */
#offline-bar {
  display: none;
}
:root[data-offline] #offline-bar {
  display: block;
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 0.35rem 1rem;
  text-align: center;
  font-weight: 600;
  background: var(--broken);
  color: #000;
}

/* The status page: one line per check, coloured by how it is going. */
.verdict {
  font-weight: 600;
}
.verdict.ok,
.check.ok b {
  color: var(--pico-ins-color);
}
.verdict.warn,
.check.warn b {
  color: var(--broken);
}
.verdict.bad,
.check.bad b {
  color: var(--pico-del-color);
}
.checks {
  list-style: none;
  padding: 0;
}
.check {
  display: flex;
  flex-direction: column;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--pico-muted-border-color);
}
.check span {
  color: var(--pico-muted-color);
}

/* Files and photos: a round of buttons to send with, and a list with a preview picture in front of each line. */
.send-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.send-buttons button {
  width: auto;
  margin: 0;
}
.uploads li {
  justify-content: flex-start;
}
.uploads .preview {
  flex: none;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 0.5rem;
  overflow: hidden;
  background: var(--pico-muted-border-color);
}
.uploads .preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
}
.uploads .what {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.uploads .item-actions {
  margin-left: auto;
}
.uploads .price {
  font-weight: 600;
  white-space: nowrap;
}

/* Search: the box on the start page, and results as whole-line links. */
.home-search {
  margin-bottom: 1rem;
}
.results li {
  padding: 0;
}
.results .hit {
  display: block;
  flex: 1;
  padding: 0.7rem 0.9rem;
  text-decoration: none;
  color: inherit;
  overflow-wrap: anywhere;
}

/* A heading under the page title that looks like the smaller one the pages always had (it is an h2 so the order is right). */
h2.sub {
  font-size: 1.25rem;
}

/* Muted text on the dark theme was too faint to read comfortably (the contrast checker's rule is 4.5:1). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --pico-muted-color: #a9b2c0;
  }
}
:root[data-theme="dark"] {
  --pico-muted-color: #a9b2c0;
}

/* Text on the accent colour: white on the light theme's dark blue, dark on the dark theme's light blue. */
:root {
  --on-primary: #fff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --on-primary: #0e1220;
  }
}
:root[data-theme="dark"] {
  --on-primary: #0e1220;
}

/* A note's changes: blocks of text, each under who wrote it and when. */
:root {
  --who-anh: #2f6fed;
  --who-ahj: #d9730d;
  --who-before: #8a93a3;
}
.note-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.note-tools button[aria-pressed="true"] {
  outline: 2px solid var(--pico-primary);
}
.hunks {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.hunk {
  --who: var(--who-before);
  border-left: 0.3rem solid var(--who);
  padding-left: 0.75rem;
}
.hunk.who-anh {
  --who: var(--who-anh);
}
.hunk.who-ahj {
  --who: var(--who-ahj);
}
.hunk header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--pico-muted-color);
}
.hunk .chip {
  padding: 0 0.5rem;
  border-radius: 1rem;
  border: 1px solid var(--who);
  color: var(--pico-color);
  background: color-mix(in srgb, var(--who) 16%, transparent);
}
.hunk pre {
  margin: 0.25rem 0 0;
  padding: 0;
  background: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: inherit;
}
.hunk.new {
  background: color-mix(in srgb, var(--who) 10%, transparent);
}
.hunks.only-new .hunk:not(.new) {
  display: none;
}
.list .badge,
.hunk .badge {
  padding: 0 0.45rem;
  border-radius: 1rem;
  background: var(--pico-primary);
  color: var(--on-primary);
  font-size: 0.75rem;
  white-space: nowrap;
}

/* Code: a conversation with Claude, the state of a task, and the changes it made. */
:root {
  --state-ok: #1f8a4c;
  --state-bad: #d03b3b;
}
.state {
  display: inline-block;
  padding: 0 0.5rem;
  border-radius: 1rem;
  border: 1px solid var(--st, var(--pico-muted-border-color));
  background: color-mix(in srgb, var(--st, transparent) 16%, transparent);
  color: var(--pico-color);
  font-size: 0.8rem;
  white-space: nowrap;
}
.state.s-running,
.state.s-queued {
  --st: var(--pico-primary);
}
.state.s-ready,
.state.s-merged {
  --st: var(--state-ok);
}
.state.s-approval {
  --st: var(--broken);
}
.state.s-failed,
.state.full {
  --st: var(--state-bad);
}
.chat {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.chat .msg {
  max-width: 92%;
  padding: 0.5rem 0.75rem;
  border-radius: 0.75rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.chat .msg.you {
  align-self: flex-end;
  background: color-mix(in srgb, var(--pico-primary) 18%, transparent);
}
.chat .msg.claude {
  align-self: flex-start;
  background: color-mix(in srgb, var(--pico-muted-color) 14%, transparent);
}
.chat .msg.error {
  border: 1px solid var(--state-bad);
  background: color-mix(in srgb, var(--state-bad) 12%, transparent);
}
.chat .tool,
.chat .note {
  font-size: 0.85rem;
  color: var(--pico-muted-color);
  overflow-wrap: anywhere;
}
.chat .note {
  text-align: center;
}
.chat details pre {
  margin: 0.25rem 0 0;
  max-height: 14rem;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.8rem;
}
.chat details.bad summary {
  color: var(--state-bad);
}
.code-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.75rem;
  background: color-mix(in srgb, var(--pico-muted-color) 12%, transparent);
}
.code-panel.ask {
  border: 1px solid var(--broken);
  flex-direction: column;
  align-items: stretch;
}
.code-panel ul {
  margin: 0;
  padding-left: 1.2rem;
  overflow-wrap: anywhere;
}
#reply {
  position: sticky;
  bottom: 0;
  padding: 0.5rem 0;
  background: var(--pico-background-color);
}
.diff-stat {
  font-size: 0.8rem;
  white-space: pre-wrap;
}
.diff-stat:empty {
  display: none;
}
#diff details.file {
  margin-bottom: 0.75rem;
}
#diff summary {
  overflow-wrap: anywhere;
  font-weight: 600;
}
pre.diff {
  margin: 0.25rem 0 0;
  padding: 0;
  overflow-x: auto;
  font-size: 0.78rem;
  line-height: 1.35;
}
pre.diff .line {
  display: block;
  padding: 0 0.5rem;
  white-space: pre;
  color: var(--pico-color);
}
pre.diff .add {
  background: color-mix(in srgb, var(--state-ok) 22%, transparent);
}
pre.diff .del {
  background: color-mix(in srgb, var(--state-bad) 20%, transparent);
}
pre.diff .hdr {
  font-style: italic;
  background: color-mix(in srgb, var(--pico-primary) 10%, transparent);
}
