/* LunchPlan — mobile first, large touch targets, readable from a kitchen counter. */

:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --text: #1f2421;
  --muted: #5f6661;
  --line: #e2ded4;
  --accent: #2f6b3f;
  --accent-text: #ffffff;
  --accent-soft: #e3efe5;
  --warn: #9a5b00;
  --warn-soft: #fbf0dc;
  --error: #a4262c;
  --error-soft: #fbe7e8;
  --radius: 12px;
  --tabbar: 64px;
  color-scheme: light dark;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.45;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151816;
    --surface: #1f2421;
    --text: #eef1ee;
    --muted: #a3aba5;
    --line: #333a35;
    --accent: #6fbf83;
    --accent-text: #0f1f14;
    --accent-soft: #24382a;
    --warn: #f0b25a;
    --warn-soft: #3a2f1c;
    --error: #ff8a8f;
    --error-soft: #3d2224;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0.4rem 0 0.8rem; }
h2 { font-size: 1.2rem; margin: 1.4rem 0 0.6rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 0.4rem; }
h4 { font-size: 0.85rem; margin: 0.8rem 0 0.3rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
ul, ol { padding-left: 1.2rem; }

.shell { min-height: 100vh; }
.content {
  max-width: 1100px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 0.5rem) max(1rem, env(safe-area-inset-right)) calc(var(--tabbar) + env(safe-area-inset-bottom) + 1.5rem) max(1rem, env(safe-area-inset-left));
}
.splash { padding: calc(env(safe-area-inset-top) + 2rem) 1rem; color: var(--muted); text-align: center; }

/* --- Navigation ----------------------------------------------------------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 0.75rem;
}
.tabs a.active { color: var(--accent); font-weight: 600; }
.tabs svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* --- Building blocks -------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem; margin: 0.8rem 0; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.lead { font-size: 1.1rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.loading { color: var(--muted); }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 44px; padding: 0.5rem 1rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; text-decoration: none; cursor: pointer;
}
button:disabled, .button[aria-disabled="true"] { opacity: 0.5; cursor: default; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.danger { color: var(--error); border-color: var(--error); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; min-height: 32px; }
label { display: block; margin: 0.6rem 0; }
input, select, textarea {
  display: block; width: 100%; min-height: 44px; margin-top: 0.3rem; padding: 0.5rem 0.7rem;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit;
}
input[type="date"] { width: auto; }
.search { margin-bottom: 0.8rem; }
.back { display: inline-block; margin: 0.3rem 0; text-decoration: none; }

.notice { padding: 0.6rem 0.8rem; border-radius: 10px; background: var(--accent-soft); margin: 0.6rem 0; }
.notice-error { background: var(--error-soft); color: var(--error); }
.notice-ok { background: var(--accent-soft); }
.credit-balance { font-size: 1.8rem; font-weight: 650; margin: 0.2rem 0; font-variant-numeric: tabular-nums; }
.credit-balance.low { color: var(--error); }
.credit-entries ul { list-style: none; padding: 0; margin: 0.4rem 0 0; }
.credit-entries li { padding: 0.35rem 0; border-top: 1px solid var(--line); gap: 0.6rem; font-variant-numeric: tabular-nums; }
.credit-plus { color: var(--accent); }
span.notice-error { display: block; padding: 0.2rem 0.4rem; border-radius: 6px; }
.badge { display: inline-block; padding: 0 0.45rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 0.75rem; font-weight: 600; vertical-align: middle; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { border: 0; border-radius: 0; min-width: 44px; font-size: 1.2rem; }
.stepper-value { min-width: 2.2rem; text-align: center; font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.4rem 0; align-items: center; }
.chip { min-height: 40px; min-width: 44px; padding: 0.3rem 0.7rem; border-radius: 999px; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.pantry { list-style: none; padding: 0; margin: 0.4rem 0; }
.pantry li { display: flex; align-items: center; gap: 0.5rem; padding: 0.2rem 0; border-bottom: 1px solid var(--line); }
.pantry-name { flex: 1 1 auto; font-weight: 600; }
.upto { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--muted); }
.upto input { width: 7.6rem; margin: 0; min-height: 40px; }
.upto select { width: auto; margin: 0; min-height: 40px; }
.pantry .icon-button { margin: 0; }
.chips input[type="date"] { margin: 0; min-height: 40px; }

.list { list-style: none; padding: 0; margin: 0; }
.list-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem; width: 100%;
  padding: 0.75rem 0.9rem; margin: 0.4rem 0; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); text-decoration: none; text-align: left;
}
.list-title { font-weight: 600; }
.list.compact .list-item { padding: 0.5rem 0.7rem; margin: 0.25rem 0; min-height: 44px; }
.status { font-size: 0.8rem; font-weight: 600; }
.status-running, .status-queued { color: var(--warn); }
.status-done { color: var(--accent); }
.status-failed { color: var(--error); }

/* Pages without a sign-in, laid out as in the shopping list app (docs/ANMELDUNG-EINHEITLICH.md):
   the card centred in the visible part of the screen (dvh: without Safari's bars). */
.login { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 1rem; }
.login .card { width: 100%; max-width: 400px; }
.app-head { display: flex; align-items: center; gap: 0.6rem; font-size: 1.6rem; margin: 0 0 0.2rem; }
.app-head img { width: 44px; height: 44px; border-radius: 10px; }
.tagline { margin: 0 0 1rem; }
.login h2 { font-size: 1.2rem; margin: 0.6rem 0 0.4rem; }
.login .wide { width: 100%; margin-top: 0.6rem; }
.login .button.link { border: 0; background: none; color: var(--accent); }
.login form > p.center { margin: 0.6rem 0 0; }
.login .stack { display: grid; gap: 0.2rem; }
.switch-mode { display: grid; gap: 0.3rem; margin-top: 1rem; padding-top: 0.8rem; border-top: 1px solid var(--line); text-align: center; }
.switch-mode .wide { margin-top: 0.2rem; }
.login.signup { place-items: start center; gap: 1rem; }
.signup .card { max-width: 34rem; }
.signup ol, .signup ul { display: grid; gap: 0.45rem; margin: 0.4rem 0 0.6rem; }
@media (min-width: 60rem) {
  .login.signup { grid-template-columns: minmax(0, 34rem) minmax(0, 26rem); justify-content: center; align-items: start; }
}
/* A field's hint stands below it, outside the label: screen readers read it as its description. */
.hint { margin: -0.4rem 0 0.6rem; }
.account-field label { margin-bottom: 0; }
.account-field .row { align-items: center; margin-bottom: 0.6rem; }
.account-field .row input { flex: 1; min-width: 0; margin-top: 0; }
.account-field .hint { margin-top: -0.3rem; }
.first-steps ol { display: grid; gap: 0.45rem; padding-left: 1.2rem; }

/* --- Week ------------------------------------------------------------------- */
.week-head h1 { margin: 0; }
.days { display: grid; gap: 0.2rem; }
.day.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.day h2 { margin: 0 0 0.4rem; font-size: 1.05rem; }
.dish { margin: 0.3rem 0; }
.dish-title { width: 100%; justify-content: flex-start; text-align: left; background: var(--accent-soft); border-color: transparent; }
.dish-title.missing { background: var(--error-soft); color: var(--error); }
.dish-actions { display: grid; gap: 0.6rem; padding: 0.7rem 0.2rem 0.4rem; }
.add { width: 100%; border-style: dashed; color: var(--muted); margin-top: 0.3rem; }
.picker { display: grid; gap: 0.4rem; margin-top: 0.4rem; }
.picker-needs { display: block; font-weight: normal; }
.amount-summary { margin: 0.4rem 0 0.2rem; }
.amount-more { margin-top: 0.8rem; }
.amount-more summary { cursor: pointer; color: var(--muted); }
.trip.past { opacity: 0.7; }
.items { list-style: none; padding: 0; margin: 0; }
.items li { display: flex; flex-direction: column; padding: 0.35rem 0; border-bottom: 1px solid var(--line); }
.items li:last-child { border-bottom: 0; }
.to-buy { white-space: nowrap; }
.warnings { padding-left: 1.1rem; margin: 0.4rem 0 0.8rem; }
textarea { resize: vertical; line-height: 1.4; }
.edit-row { display: grid; gap: 0.4rem; align-items: start; padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
.edit-row input, .edit-row textarea { margin: 0; padding: 0.5rem; }
.edit-row.ingredient { grid-template-columns: 4rem 5.8rem 1fr auto; grid-template-areas: "qty unit name name" "note note note tools"; }
.edit-row.ingredient .qty { grid-area: qty; }
.edit-row.ingredient .unit { grid-area: unit; }
.edit-row.ingredient .name { grid-area: name; }
.edit-row.ingredient .note { grid-area: note; }
.edit-row.ingredient .row-tools { grid-area: tools; }
.edit-row.section { grid-template-columns: 1fr auto; }
.edit-row.step { grid-template-columns: 1fr; }
.edit-row.step .row-tools { justify-self: end; }
.edit-row.section input { font-weight: 600; }
.edit-row.invalid .qty { border-color: var(--error); }
.row-tools { display: inline-flex; gap: 0.2rem; }
.row-tools button { min-width: 40px; padding: 0.4rem; }
.editor-actions { position: sticky; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); z-index: 5; background: var(--bg); padding: 0.6rem 0; border-top: 1px solid var(--line); }
.warnings li { margin: 0.3rem 0; }
.trip > button, .trip > .button { width: 100%; margin-top: 0.8rem; }
.trip > .button + p { margin-top: 0.4rem; }
.paste { display: block; margin: -0.3rem 0 0.6rem; }
.warning { background: var(--warn-soft); border-color: transparent; }
details summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 0.4rem; font-weight: 600; list-style: none; }
details summary::-webkit-details-marker { display: none; }
/* As a flex box the summary loses its triangle; this one also turns when it opens. */
details summary::before { content: "▸"; color: var(--muted); transition: transform 0.15s; }
details[open] > summary::before { transform: rotate(90deg); }

/* --- Recipe (kitchen) ------------------------------------------------------ */
.recipe h1 { font-size: 1.8rem; }
.title-row { display: flex; align-items: flex-start; gap: 0.4rem; }
.title-row h1 { flex: 0 1 auto; }
.icon-button { flex: 0 0 auto; min-width: 44px; margin-top: 0.4rem; padding: 0.5rem; border-color: transparent; background: transparent; color: var(--muted); }
.icon-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.title-edit { display: grid; gap: 0.5rem; margin: 0.4rem 0 0.8rem; }
.title-edit input { margin: 0; font-size: 1.3rem; font-weight: 700; }
.recipe-tools { display: flex; flex-wrap: wrap; gap: 0.8rem 1.4rem; align-items: center; margin: 0.6rem 0; }
.tool { display: inline-flex; align-items: center; gap: 0.6rem; margin: 0; }
.switch input { width: 22px; height: 22px; min-height: 0; margin: 0; }
.checklist, .steplist { list-style: none; padding: 0; margin: 0; }
.checklist button, .steplist button {
  width: 100%; justify-content: flex-start; align-items: baseline; text-align: left; gap: 0.7rem;
  border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; padding: 0.55rem 0.2rem;
}
.checklist button.done { color: var(--muted); text-decoration: line-through; }
/* Crossed-out paragraphs are hard to read again; a finished step only fades. */
.steplist button.done { opacity: 0.45; }
.steplist button.done .step-number { background: var(--accent); color: var(--accent-text); }
.amount { flex: 0 0 6.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.step-number { flex: 0 0 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: inline-grid; place-items: center; font-weight: 700; text-decoration: none; }
.steplist button { font-size: 1.1rem; line-height: 1.55; padding: 0.8rem 0.2rem; }

.thumbs { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0.6rem 0; }
.thumb { position: relative; width: 96px; height: 128px; padding: 0; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-remove { position: absolute; top: 4px; right: 4px; min-height: 32px; min-width: 32px; padding: 0; border-radius: 50%; background: rgb(0 0 0 / 0.6); color: #fff; border: 0; }
.overlay { position: fixed; inset: 0; z-index: 20; background: rgb(0 0 0 / 0.92); display: grid; place-items: center; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.overlay img { max-width: 100vw; max-height: 100vh; object-fit: contain; }
.overlay-close { position: fixed; top: calc(env(safe-area-inset-top) + 0.6rem); right: 0.6rem; background: rgb(255 255 255 / 0.15); color: #fff; border: 0; }
.overlay-nav { position: fixed; top: 50%; transform: translateY(-50%); min-width: 48px; min-height: 64px; font-size: 1.8rem; background: rgb(255 255 255 / 0.15); color: #fff; border: 0; }
.overlay-nav.previous { left: 0.4rem; }
.overlay-nav.next { right: 0.4rem; }
.overlay-count { position: fixed; bottom: calc(env(safe-area-inset-bottom) + 0.8rem); left: 0; right: 0; text-align: center; color: #fff; font-size: 0.85rem; text-shadow: 0 1px 2px #000; }

/* The dish picture: a square in lists and the plan, 4:3 above the recipe. */
.dish-thumb { flex: 0 0 auto; width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--accent-soft); display: block; }
.dish-thumb.small { width: 40px; height: 40px; border-radius: 8px; }
.dish-thumb.empty { background: transparent; }
.list-item.with-thumb { flex-direction: row; align-items: center; justify-content: flex-start; gap: 0.75rem; }
.list-text { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.dish-title.with-thumb { gap: 0.6rem; padding-left: 0.4rem; }
.dish-text { display: flex; flex-direction: column; min-width: 0; }
.dish-text .dish-energy { flex-basis: auto; }
.dish-hero { display: block; width: 100%; max-height: 42vh; padding: 0; margin: 0.4rem 0 0.2rem; border: 0; border-radius: var(--radius); overflow: hidden; aspect-ratio: 4 / 3; background: var(--accent-soft); }
.dish-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dish-preview { display: block; width: 100%; max-width: 28rem; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; margin: 0.4rem 0; background: var(--accent-soft); }
.thumb.dish { width: 128px; }
.frame-box { position: relative; display: inline-block; max-width: 100%; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; line-height: 0; }
.frame-box img { max-width: 100%; max-height: 70vh; display: block; }
.frame { position: absolute; box-shadow: 0 0 0 9999px rgb(0 0 0 / 0.5); outline: 2px solid #fff; cursor: move; }
.frame-handle { position: absolute; right: 0; bottom: 0; width: 32px; height: 32px; border-radius: 10px 0 0 0; background: #fff; border: 2px solid var(--accent); cursor: nwse-resize; }
@media (min-width: 48rem) { .recipe .dish-hero { max-width: 36rem; } }

/* iPad and wider: ingredients next to the steps, the week as a grid. */
@media (min-width: 760px) {
  :root { font-size: 18px; }
  .recipe-columns { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: 2rem; align-items: start; }
  /* Stays in view while the steps scroll; a long list scrolls on its own. */
  .ingredients {
    position: sticky; top: 1rem; overflow-y: auto; overscroll-behavior: contain;
    max-height: calc(100dvh - var(--tabbar) - env(safe-area-inset-bottom) - 2rem);
  }
  .days { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.8rem; }
  .days .card { margin: 0; }
}

/* --- Family and account ------------------------------------------------------ */
.members { list-style: none; padding: 0; margin: 0 0 0.6rem; }
.members li { display: grid; gap: 0.2rem; padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.members li:last-child { border-bottom: 0; }
/* A lapsed link: only that part in the error colour, in the same line. */
.members .expired { color: var(--error); }
.member-actions { margin-top: 0.3rem; }
.member-actions button { min-height: 40px; padding: 0.3rem 0.8rem; font-size: 0.9rem; }
.link-box { display: grid; gap: 0.5rem; padding: 0.8rem; margin: 0.4rem 0 0.8rem; border-radius: 10px; background: var(--accent-soft); }
.link-box p { margin: 0; }
.link-box input { margin: 0; font-size: 0.85rem; }
.invite { border-top: 1px solid var(--line); margin-top: 0.4rem; }
.password { margin: 0.4rem 0 0.8rem; }
.password form { padding-top: 0.2rem; }

/* --- Bring! access ------------------------------------------------------------ */
.bring fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 0.4rem 0.8rem; margin: 0.8rem 0; }
.bring legend { padding: 0 0.3rem; font-weight: 600; }
.choice { display: flex; gap: 0.6rem; align-items: flex-start; margin: 0.5rem 0; }
.choice input { width: auto; min-height: 0; margin: 0.25rem 0 0; flex: 0 0 auto; }
.choice span .small { display: block; }
.trip > p.center { margin: 0.3rem 0 0; }

/* --- Families (superadmin) ------------------------------------------------------- */
.inline-form { display: grid; gap: 0.2rem; margin-top: 0.4rem; }
.inline-form label { margin: 0.3rem 0; }
.danger-zone { padding: 0.6rem 0.8rem; border-radius: 10px; background: var(--error-soft); }
.danger-zone p { margin: 0; }
.bring .unsaved { color: var(--warn); font-weight: 600; margin: 0.4rem 0; }

/* Sharing recipes with another family */
.sheet-overlay { background: rgb(0 0 0 / 0.55); align-items: end; padding: 0; }
.sheet { background: var(--surface); color: inherit; width: min(34rem, 100%); max-height: 88vh; overflow-y: auto; border-radius: 1rem 1rem 0 0;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)); display: grid; gap: 0.7rem; }
.sheet h2 { margin: 0; }
.pick { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.15rem; max-height: 45vh; overflow-y: auto; }
.pick label { display: flex; align-items: start; gap: 0.6rem; margin: 0; padding: 0.45rem 0.2rem; border-bottom: 1px solid var(--line); }
.pick label > span { display: grid; gap: 0.1rem; }
.pick label.with-thumb { align-items: center; }
.pick input[type="checkbox"], .sheet > label input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; margin: 0; flex: none; }
.sheet > label { display: flex; align-items: center; margin: 0; }
.sheet h3 { margin: 0.3rem 0 0; }
.pick-all { max-height: none; overflow: visible; }
/* What to do stays at the bottom of a long sheet, and so does the answer. */
.sheet-actions { position: sticky; bottom: calc(-1rem - env(safe-area-inset-bottom)); display: grid; gap: 0.5rem;
  margin: 0 -1rem calc(-1rem - env(safe-area-inset-bottom)); padding: 0.6rem 1rem calc(1rem + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line); }
.sheet-actions:empty { display: none; }
.sheet-actions .list-select { margin: 0; }
.sheet-actions .notice, .sheet-actions p { margin: 0; }

/* Choosing the Bring! list: only shown with more than one allowed list */
.list-select { display: flex; align-items: center; gap: 0.6rem; margin: 0.8rem 0 0; }
.list-select > span { color: var(--muted); font-size: 0.9rem; flex: none; }
.list-select select { margin: 0; }
.trip > .list-select + button { margin-top: 0.5rem; }

/* An ingredient the list lacks, added from the hint about it */
.servings-confirm .row + .row { margin-top: 0.7rem; }
.add-missing { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin: 0.4rem 0 0.2rem; }
.add-missing input { width: 6rem; margin: 0; }
.add-missing .notice { flex-basis: 100%; margin: 0; }
.add-missing .add-basis { flex-basis: 100%; margin: 0; }
.review-actions { margin-top: 0.6rem; }
.warnings li { margin-bottom: 0.5rem; }
.warnings button.link { display: block; margin-top: 0.1rem; }

/* People with − and +, or pieces and trays typed in, with the unit beside it */
.amount-input { display: inline-flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.amount-input input { width: 5.5rem; margin: 0; }
.amount-input select { width: auto; margin: 0; }
.shares { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.shares li { border-top: 1px solid var(--line); padding-top: 0.6rem; }
.shares p { margin: 0.1rem 0; }

/* Nutrition: energy first, nutrients as a table, what was not counted folded away */
.nutrition .energy { font-size: 1.2rem; margin: 0.3rem 0 0.5rem; }
.nutrients { border-collapse: collapse; width: 100%; max-width: 26rem; margin-bottom: 0.4rem; }
.nutrients th { text-align: left; font-weight: normal; padding: 0.2rem 0; border-bottom: 1px solid var(--line); }
.nutrients td { text-align: right; padding: 0.2rem 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.nutrients tr.part th { padding-left: 1rem; color: var(--muted); }
.nutrition-details summary { cursor: pointer; margin-top: 0.4rem; }
.nutrition-details ul { margin: 0.2rem 0 0.4rem; padding-left: 1.1rem; }
.pieces-form { flex-wrap: wrap; align-items: flex-end; gap: 0.5rem; }
.pieces-form input { width: 6rem; margin: 0.2rem 0 0; }
.pieces-form .notice { flex-basis: 100%; margin: 0; }
.nutrition-summary { margin: 0.4rem 0 0.8rem; }
.energy-choice { margin: 0.4rem 0 0.6rem; }
.energy-choice .notice { flex-basis: 100%; }
.foods .food-search { flex-wrap: wrap; gap: 0.4rem; margin-top: 0.3rem; }
.foods .food-search input { flex: 1 1 10rem; margin: 0; }
.food-results { list-style: none; padding: 0; margin: 0.3rem 0; display: grid; gap: 0.2rem; }
.food-weights { display: grid; gap: 0.3rem; margin-top: 0.5rem; }
.food-weights label { display: grid; gap: 0.15rem; font-size: 0.9rem; }
.food-weights p { margin: 0; }
.food-results li { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: baseline; border: 0; padding: 0.1rem 0; }
.food-results button.link { text-align: left; }
.own-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 0.4rem 0.6rem; }
.own-values label { display: grid; gap: 0.15rem; font-size: 0.9rem; }
details.card > summary h2 { display: inline; }
.dish-title { flex-wrap: wrap; }
.dish-energy { flex-basis: 100%; }

/* A newer version on the server: at the top, above everything, until the page is reloaded. */
.new-version { position: sticky; top: 0; z-index: 15; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: calc(env(safe-area-inset-top) + 0.5rem) 1rem 0.5rem; background: var(--accent-soft); border-bottom: 1px solid var(--line); }
.new-version button { min-height: 40px; }

/* Until the app has started; replaced by it. */
.boot { padding: calc(env(safe-area-inset-top) + 2rem) 1rem; color: var(--muted); }
.boot button { margin-left: 0.5rem; }

/* --- Library: filters, collections, shelves (Phase 4t) ------------------------ */
.heart { width: 1em; height: 1em; vertical-align: -0.12em; fill: none; stroke: var(--accent); stroke-width: 2; }
.heart.filled { fill: var(--accent); }
.list-title .heart { margin-left: 0.2rem; }
.filter-bar { flex-wrap: nowrap; overflow-x: auto; margin: 0 -1rem 0.4rem; padding: 0 1rem; scrollbar-width: none; }
.filter-bar::-webkit-scrollbar { display: none; }
.filter-bar .chip { flex: none; min-height: 36px; padding: 0.2rem 0.7rem; font-size: 0.9rem; white-space: nowrap; }
.chip-select, .sort-select { flex: none; width: auto; min-height: 36px; margin: 0; padding: 0.2rem 0.5rem; font-size: 0.9rem; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; margin: 1rem 0 0.2rem; }
.list-head h2, .list-head p { margin: 0; }
.list-head h2 { white-space: nowrap; }
.filter-actions { display: flex; flex-wrap: wrap; gap: 0.2rem 1.2rem; margin: 0 0 0.4rem; }
.filter-actions button.link { justify-content: flex-start; text-align: left; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.section-head h2 { margin-bottom: 0.3rem; }
.collection-list { margin-bottom: 0.4rem; }
.collection-list li.depth-1 { margin-left: 1.4rem; }
.collection-list li.depth-2 { margin-left: 2.8rem; }
.collection-link { flex-direction: row; align-items: center; gap: 0.6rem; }
.collection-link .count { margin-left: auto; }
.collection-icon { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linejoin: round; vertical-align: -0.15em; }
h1 .collection-icon { width: 26px; height: 26px; }
.collection-actions { margin: 1rem 0; }
.new-collection select { width: 100%; }
.pick label.depth-1 { padding-left: 1.4rem; }
.pick label.depth-2 { padding-left: 2.8rem; }
.shelf { margin: 0.6rem 0 0.2rem; }
.shelf-head { display: flex; align-items: baseline; justify-content: space-between; }
.shelf-head h2 { margin: 0.6rem 0 0.3rem; font-size: 1.05rem; }
.shelf-items { list-style: none; margin: 0; padding: 0 0 0.4rem; display: grid; grid-auto-flow: column; grid-auto-columns: 6.5rem; gap: 0.6rem;
  overflow-x: auto; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.tile { display: grid; gap: 0.3rem; color: var(--text); text-decoration: none; font-size: 0.85rem; line-height: 1.25; scroll-snap-align: start; }
.tile .dish-thumb { width: 6.5rem; height: 6.5rem; border-radius: 12px; }
.tile .dish-thumb.empty { background: var(--accent-soft); }
.tile span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.library-bar { margin: 0.3rem 0 0.6rem; }
.library-bar .chips { margin: 0.2rem 0; }
.library-bar .chip { min-height: 38px; font-size: 0.9rem; }
.library-bar .chip[aria-pressed="true"] .heart { stroke: currentColor; fill: currentColor; }
.library-bar p { margin: 0.2rem 0; }
.picker .filter-bar { margin: 0.4rem 0; padding: 0; }
.picker-collection { margin: 0 0 0.4rem; }
.error-text { color: var(--error); }
.shared-list { margin: 0.4rem 0 0.8rem; padding-left: 1.2rem; }
.properties { margin: 0.2rem 0 0.8rem; }
.properties p { margin: 0.3rem 0; }
.properties .chip.property { min-height: 34px; padding: 0.15rem 0.7rem; font-size: 0.9rem; background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.properties details ul { margin: 0.3rem 0; padding-left: 1.2rem; }
.properties .chip.property.label { background: var(--surface); border-color: var(--line); color: var(--text); }
.time-line { margin: -0.4rem 0 0.6rem; }
.time-line button.link { min-height: 28px; font-size: inherit; }
.time-edit { margin: 0 0 0.8rem; }
.time-edit input[type="number"] { width: 7rem; }
.labels-edit fieldset.label-group { border: 0; padding: 0; margin: 0.6rem 0; }
.labels-edit legend { padding: 0; margin-bottom: 0.2rem; }
.labels-edit .chip { min-height: 36px; padding: 0.2rem 0.7rem; font-size: 0.9rem; }
