/* Layout and components. Tokens only - no literal colours. Mobile first. */
*, *::before, *::after { box-sizing: border-box; }
/* Component display rules (flex, grid) must never un-hide something marked hidden. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font: 400 15px/1.55 var(--font);
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent-strong); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 var(--space-3); }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0 0 var(--space-3); }
.muted { color: var(--text-faint); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }

/* ---------- frame ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  min-height: var(--header-h);
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: var(--space-2); min-width: 0; color: var(--text); text-decoration: none; }
.brand__mark { width: 32px; height: 32px; flex: 0 0 auto; display: block; }
.brand__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.brand__name { font-weight: 700; font-size: 16px; }
.brand__home { font-size: 12px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); flex: 0 0 auto; }
/* How much detail (D-121): the header's second row, so it follows the top bar down the page. */
.app-header { flex-wrap: wrap; row-gap: var(--space-1); }
/* A thin row of small pills - not like the other buttons (the reference: the Detronics mode bar). The
   .level-bar prefix outranks the general .chip and .btn rules further down the file. */
.level-bar { flex: 1 0 100%; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding-top: 3px; border-top: 1px solid var(--border); }
.level-bar .chipset { gap: 4px; }
.level-bar .chip { min-height: 0; height: 22px; padding: 0 10px; font-size: 12px; line-height: 20px; font-weight: 500; }
.level-bar .chip[aria-pressed="true"] { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink); }
.level-bar .chip[aria-pressed="true"]::before { content: none; }
.level-bar__says { flex: 1 1 220px; font-size: 12px; }
.level-bar .level-bar__hide { margin-left: auto; min-height: 0; height: 22px; padding: 0 8px; font-size: 12px; line-height: 20px; }
.level-bar--folded { justify-content: center; border-top: 0; padding: 0; margin: calc(-1 * var(--space-2)) 0; }
.level-tab { border: 1px solid var(--border); border-top: 0; background: var(--panel); color: var(--text-dim); border-radius: 0 0 var(--radius-sm) var(--radius-sm); padding: 0 18px; line-height: 16px; font-size: 18px; cursor: pointer; }
.level-tab:hover, .level-tab:focus-visible { color: var(--accent-strong); }
@media (max-width: 560px) { .level-bar__says { display: none; } }
@media print { .level-bar { display: none !important; } }

.crumbs {
  max-width: var(--content-w); width: 100%; margin: 0 auto;
  padding: var(--space-3) var(--space-4) 0;
  font-size: 14px; color: var(--text-faint);
}
.crumbs a { color: var(--text-dim); }
/* The topic's Creators and videos (D-113), at the far end of an app's top line. */
.crumbs__extra { float: right; margin-left: var(--space-3); }
.page-back { margin-top: var(--space-4); }
/* A section's ways in: Plan, Check and note, Do - side by side when there is room. */
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--space-3); align-items: start; }
.mode--do { border-top: 3px solid var(--accent); }
details > .modes { margin-top: var(--space-3); }

main.app-main {
  flex: 1 0 auto;
  width: 100%; max-width: var(--content-w);
  margin: 0 auto;
  padding: var(--space-3) var(--space-4) var(--space-6);
  display: flex; flex-direction: column; gap: var(--space-4);
}
main.app-main > * { flex: 0 0 auto; min-width: 0; }

.app-footer {
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  padding: var(--space-3) var(--space-4);
  background: var(--panel);
  border-top: 1px solid var(--border);
  font-size: 13px; color: var(--text-faint);
}
.app-footer nav { margin-left: auto; display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }

/* ---------- surfaces ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
}
.panel > :last-child { margin-bottom: 0; }
.panel--soft { background: var(--panel-2); box-shadow: none; }
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.row { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.row--end { justify-content: flex-end; }
.spacer { flex: 1 1 auto; }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-size: 14px; font-weight: 600;
  min-height: var(--tap);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  text-decoration: none;
  text-align: center;
}
.btn:hover { background: var(--panel-2); }
.btn-primary { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); filter: brightness(1.08); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--accent-strong); }
.btn-quiet:hover { background: var(--accent-soft); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-small { min-height: 34px; padding: 4px var(--space-3); font-size: 13px; }
.btn-icon { width: var(--tap); min-width: var(--tap); padding: 0; }
.btn-icon svg { display: block; }
.btn__glyph { font-size: 16px; line-height: 1; }

.linkish {
  font: inherit; color: var(--accent-strong); background: none; border: none; padding: 0;
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}

/* ---------- chips (single and multi choice) ---------- */
.chipset { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip {
  font: inherit; font-size: 14px;
  min-height: var(--tap);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.chip:hover { background: var(--panel-2); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); font-weight: 600; }
.chip[aria-pressed="true"]::before { content: '\2713\00a0'; color: var(--accent-strong); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.field[hidden] { display: none; }
.field__label { font-weight: 600; font-size: 14px; }
.field__hint { font-size: 13px; color: var(--text-faint); }
.input, .select, textarea.input {
  font: inherit;
  min-height: var(--tap);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
}
textarea.input { min-height: 80px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: var(--space-3); }
@media (min-width: 600px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.checkline { display: flex; gap: var(--space-2); align-items: center; min-height: var(--tap); cursor: pointer; }
.checkline input { width: 20px; height: 20px; accent-color: var(--accent-strong); }
fieldset { border: none; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 600; font-size: 14px; padding: 0; margin-bottom: var(--space-2); }

details.more > summary, details.explain > summary {
  cursor: pointer; font-weight: 600; color: var(--accent-strong);
  min-height: var(--tap); display: flex; align-items: center;
}

/* Sections that fold away (D-062): filters, and the long parts of a form. */
.fold > .fold__head { cursor: pointer; list-style: none; min-height: var(--tap); display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.fold > .fold__head::-webkit-details-marker { display: none; }
.fold > .fold__head::before { content: '\25b8'; color: var(--text-faint); width: 1em; transition: transform .15s; }
.fold[open] > .fold__head::before { transform: rotate(90deg); }
.fold__title { font-weight: 600; }
.fold__note { margin-left: auto; text-align: right; }
.fold[open] > .fold__head .fold__note { display: none; }
.fold__body { padding-top: var(--space-2); }
.fold--form { border-top: 1px solid var(--border); padding-top: var(--space-2); }
/* Save stays in reach at the bottom of the screen on a long form. */
.form-actions { position: sticky; bottom: 0; z-index: 5; background: var(--panel); padding: var(--space-2) 0; margin-bottom: calc(-1 * var(--space-2)); }

/* ---------- dashboard tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: var(--space-3); }
.tile {
  display: flex; flex-direction: column; gap: var(--space-1);
  min-height: 116px;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  text-decoration: none;
}
.tile:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
.tile__name { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: var(--space-2); }
.tile__purpose { font-size: 13px; color: var(--text-dim); }
.tile__meta { margin-top: auto; font-size: 13px; font-weight: 600; color: var(--accent-strong); }
.tile--planned { background: var(--panel-2); box-shadow: none; }
.tile--planned .tile__name { color: var(--text-dim); }
.badge {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
  padding: 2px 8px; border-radius: 999px;
  background: var(--panel-3); color: var(--text-dim);
}
.badge--demo { background: var(--warn-soft); color: var(--warn); }
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--accent { background: var(--accent-soft); color: var(--accent-strong); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: var(--space-1); overflow-x: auto; border-bottom: 1px solid var(--border); }
.tab {
  flex: 0 0 auto;
  min-height: var(--tap);
  padding: var(--space-2) var(--space-4);
  border: none; border-bottom: 3px solid transparent;
  background: none; color: var(--text-dim);
  font: inherit; font-weight: 600; text-decoration: none;
  display: inline-flex; align-items: center;
}
.tab[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.tab:hover { color: var(--text); }

/* ---------- chore cards ---------- */
.cards { display: flex; flex-direction: column; gap: var(--space-3); }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-2);
}
.card__top { display: flex; gap: var(--space-3); align-items: flex-start; }
.card__title { font-weight: 700; font-size: 16px; }
.card__label { font-size: 12px; font-weight: 700; color: var(--accent-strong); text-transform: uppercase; letter-spacing: 0.04em; }
.card__meta { font-size: 13px; color: var(--text-dim); }
.card__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: flex-end; }
.pills { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--text-dim); border: 1px solid var(--border); }
.pill--important { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent); }
.pill--optional { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }

.list { list-style: none; margin: 0; padding: 0; }
/* A list shown as a panel keeps the panel's side padding (the reset above would otherwise take it away). */
.list.panel { padding: var(--space-1) var(--space-4); }
.list > li { display: flex; gap: var(--space-3); align-items: center; padding: var(--space-3) 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.list > li:last-child { border-bottom: none; }
.list__main { flex: 1 1 200px; min-width: 0; }

/* ---------- celebratory-but-calm completion ---------- */
.done-panel { background: var(--ok-soft); border: 1px solid var(--ok); border-radius: var(--radius); padding: var(--space-4); }
.done-panel h2 { color: var(--ok); }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: var(--space-3); }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3) var(--space-4); }
.stat__value { font-size: 28px; font-weight: 700; color: var(--text); }
.stat__label { font-size: 13px; color: var(--text-dim); }
/* The answer row (D-123): darker than the inputs above, who wins in the wide middle. */
.answer-row .stat { background: var(--accent-soft); border-color: var(--border-strong); }
.answer-row--three { grid-template-columns: 1fr 2fr 1fr; }
@media (max-width: 560px) {
  .answer-row--three { grid-template-columns: 1fr 1fr; }
  .answer-row--three .stat--main { grid-column: 1 / -1; order: -1; }
}

table.plain { width: 100%; border-collapse: collapse; font-size: 14px; }
table.plain th, table.plain td { text-align: left; padding: var(--space-2); border-bottom: 1px solid var(--border); }
table.plain th { color: var(--text-dim); font-weight: 600; }

/* ---------- avatars & people ---------- */
.avatar {
  width: 32px; height: 32px; flex: 0 0 auto;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  color: #2b1d14;          /* dark ink on every person colour */
  border: 2px solid var(--panel);
  box-shadow: 0 0 0 1px var(--border-strong);
}
.avatar--none { background: var(--panel-3); color: var(--text-dim); }
.who-btn { padding-left: 6px; }
.who-btn__name { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.colour-dot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; padding: 0; }
.colour-dot[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--accent-strong); }

/* ---------- dialogs ---------- */
dialog.modal {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop { background: rgb(40 25 15 / 45%); }
.modal__head { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-4) var(--space-4) 0; }
.modal__head h2 { margin: 0; flex: 1 1 auto; }
.modal__body { padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.modal__foot { position: sticky; bottom: 0; background: var(--panel); border-top: 1px solid var(--border); padding: var(--space-3) var(--space-4); display: flex; gap: var(--space-2); justify-content: flex-end; flex-wrap: wrap; }
.x-btn { font-size: 22px; line-height: 1; }

.welcome-steps { counter-reset: step; list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.welcome-steps > li { counter-increment: step; display: flex; gap: var(--space-3); align-items: flex-start; }
.welcome-steps > li::before {
  content: counter(step);
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700;
}
.welcome-steps > li > div { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: var(--space-2); }

/* ---------- banners (single notice) - shape; colours come from patterns.css ---------- */
.banner {
  display: flex; align-items: flex-start; gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel-2); color: var(--text); font-size: 14px;
}
.banner--warn { background: var(--warn-soft); border-color: var(--warn); }
.banner--info { background: var(--accent-soft); border-color: var(--accent); }
.banner .btn { min-height: 30px; padding: 2px var(--space-3); font-size: 13px; }

.toast {
  position: fixed; left: 50%; bottom: var(--space-5); transform: translateX(-50%);
  z-index: 400; max-width: calc(100vw - 32px);
  padding: var(--space-3) var(--space-4);
  border-radius: 999px; background: var(--text); color: var(--bg);
  box-shadow: var(--shadow-lg); font-size: 14px;
}

.faq { margin-bottom: var(--space-3); }
.faq__q { font-weight: 700; }
.howto-steps { margin: var(--space-2) 0 0; padding-left: 1.4em; }
.howto-steps li { margin-bottom: var(--space-1); }

.empty { text-align: center; padding: var(--space-5) var(--space-4); }
.empty p { color: var(--text-dim); }

@media (max-width: 520px) {
  .brand__home { display: none; }
  .who-btn__name { max-width: 5em; }
  h1 { font-size: 21px; }
  .tab { padding: var(--space-2) 10px; font-size: 14px; }
  .tabs { scrollbar-width: none; }
  .card__actions { justify-content: stretch; }
  .card__actions .btn { flex: 1 1 auto; }
}
@media (max-width: 360px) {
  .who-btn__name { display: none; }
}

/* ---------- platform: slots, status, session, player, mini-app frames ---------- */
.slot-header, .slot-crumbs, .slot-footer, .view-host, .session-host { display: contents; }

.chip-status { min-height: 36px; padding: 4px 12px; font-size: 13px; gap: 6px; border-color: var(--border); background: var(--panel-2); color: var(--text-dim); }
.chip-status__glyph { font-weight: 700; }
.chip-status--ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.chip-status--warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.phone-swap { display: flex; gap: 4px; }
.chip-status--send { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink); }
.chip-status--busy .chip-status__glyph { display: inline-block; animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.session { scroll-margin-top: calc(var(--header-h) + var(--space-3)); border-color: var(--accent); background: var(--accent-soft); display: flex; flex-direction: column; gap: var(--space-2); }
.session__top { display: flex; gap: var(--space-3); align-items: center; }
.session__clock { font: 700 28px/1 var(--font-mono); color: var(--text); white-space: nowrap; }
.session__ring { flex: none; }
.session__ring circle { fill: none; stroke-width: 5; }
.session__ring-track { stroke: var(--border); }
.session__ring-full { stroke: var(--accent); }
.session__ring-fill { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .5s linear; }
.session__ring--over .session__ring-fill { stroke: var(--warn); }
.session__ask { gap: var(--space-2); align-items: center; padding: var(--space-2); border-radius: var(--radius-sm, 8px); background: var(--warn-soft); }
@media (prefers-reduced-motion: reduce) { .session__ring-fill { transition: none; } }
.session__music { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; padding: var(--space-2) 0; border-top: 1px dashed var(--border-strong); }
.session__music .checkline { min-height: 34px; }

.player {
  position: fixed; left: 50%; bottom: var(--space-3); transform: translateX(-50%);
  z-index: 350; width: min(560px, calc(100vw - 24px));
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: 999px;
  box-shadow: var(--shadow-lg);
}
.player[hidden] { display: none; }
.player__note { color: var(--accent-strong); font-size: 18px; }
.player__title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
body:has(.player:not([hidden])) .app-footer { padding-bottom: 72px; }

.miniapp-frame { width: 100%; min-height: 240px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }

.tile--core { background: var(--panel-2); box-shadow: none; }

@media (max-width: 520px) {
  .chip-status__text { display: none; }
  .chip-status { width: var(--tap); padding: 0; }
  .session__clock { font-size: 22px; }
  /* A phone's Get and Send keep their words; the avatar alone says who is using it. */
  .phone-swap .chip-status { width: auto; padding: 0 10px; }
  .phone-swap .chip-status__text { display: inline; }
  .header-actions:has(.phone-swap) .who-btn__name { display: none; }
}

/* Decisions: where an agreement is in the Observe -> Adapt cycle */
.cycle { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; counter-reset: c; }
.cycle__step { counter-increment: c; font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--panel-2); color: var(--text-faint); border: 1px solid var(--border); }
.cycle__step::before { content: counter(c) ". "; }
.cycle__step--now { background: var(--accent-soft); color: var(--text); border-color: var(--accent); font-weight: 700; }

/* A simple progress bar (saving goals) */
.progress { height: 10px; border-radius: 999px; background: var(--panel-3); overflow: hidden; }
.progress__bar { height: 100%; background: var(--ok); border-radius: 999px; }
.tile--off { background: var(--panel-2); box-shadow: none; }
.tile--off .btn { align-self: flex-start; margin-top: auto; }

/* Meals section: food facts and Meal Assistant cards */
.stat-big { margin: 0; font-size: 15px; }
.stat-big strong { font-size: 28px; color: var(--accent-strong); margin-right: var(--space-1); }
.facts { width: 100%; border-collapse: collapse; font-size: 14px; }
.facts th, .facts td { padding: 6px 0; border-bottom: 1px solid var(--border); text-align: left; font-weight: normal; }
.facts td { text-align: right; font-variant-numeric: tabular-nums; }
.idea { border-left: 4px solid var(--accent); }
.idea--swap { border-left-color: var(--warn); }
.idea--time { border-left-color: var(--ok); }
.idea--next { border-left-color: var(--border-strong); background: var(--panel-2); }
.idea__type { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-dim); }
.idea h3 { margin: 2px 0 var(--space-2); font-size: 17px; }
.idea dl { display: grid; grid-template-columns: auto 1fr; gap: 2px var(--space-3); margin: 0; font-size: 14px; }
.idea dt { color: var(--text-dim); }
.idea dd { margin: 0; }
.caution { border-left: 4px solid var(--danger); }

/* A Bible book at a glance: three short answers in a row, the two longer ones below. */
.glance { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--space-3); margin: 0; }
.glance__item { grid-column: span 2; background: var(--panel-2); border: 1px solid var(--border); border-top: 3px solid var(--accent); border-radius: var(--radius); padding: var(--space-3) var(--space-4); }
.glance__item:nth-child(n+4) { grid-column: span 3; }
.glance dt { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--accent-strong); margin-bottom: var(--space-1); }
.glance dd { margin: 0; font-size: 15px; line-height: 1.45; }
.glance__own { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); margin-top: var(--space-2); padding-top: var(--space-2); border-top: 1px dashed var(--border); }
.glance__note { margin: 0; font-size: 14px; white-space: pre-wrap; }
@media (max-width: 640px) { .glance { grid-template-columns: 1fr; } .glance__item, .glance__item:nth-child(n+4) { grid-column: auto; } }

/* Age and stage guidance on the People page */
.guidance { margin: var(--space-2) 0 0; padding-left: 0; list-style: none; display: grid; gap: var(--space-2); font-size: 14px; }
.guidance li { padding-left: var(--space-3); border-left: 3px solid var(--border); }
.guidance li.guidance--warn { border-left-color: var(--warn); }

/* Spider charts (js/ui/nutrition-view.js) */
.radar-wrap { display: flex; justify-content: center; }
.radar { width: 100%; max-width: 320px; height: auto; overflow: visible; }
.radar__ring { fill: none; stroke: var(--border); stroke-width: 1; }
.radar__spoke { stroke: var(--border); stroke-width: 1; }
.radar__shape { fill-opacity: .18; stroke-width: 2; stroke-linejoin: round; }
.radar__unknown { fill: var(--panel); stroke-width: 2; stroke-dasharray: 2 2; }
.radar__label { font-size: 11px; fill: var(--text-dim); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
.nutrition .facts td { white-space: normal; }
/* Before you buy (D-111): a stage's checks, and the question sheet printed on its own. */
.look-check { padding-bottom: var(--space-2); border-bottom: 1px solid var(--border); }
.chip[aria-current="page"] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); font-weight: 600; }
.print-sheet { display: none; }
@media print {
  body.printing-sheet > *:not(.print-sheet) { display: none !important; }
  body.printing-sheet .print-sheet { display: block; color: #000; font-size: 11pt; }
  .print-sheet li { break-inside: avoid; margin-bottom: 10px; }
  .print-sheet h2 { break-after: avoid; margin-top: 16px; }
  .print-hint { font-size: 9pt; color: #444; }
  .print-boxes { margin-top: 4px; }
  .print-blank { border-bottom: 1px solid #999; height: 1.5em; }
}
@media print {
  .app-header, .app-footer, .slot-crumbs, .notices-host, .no-print, .tabs { display: none !important; }
  .panel { box-shadow: none; border: 0; }
  .app-main button, .app-main .chipset, .app-main [data-field="saved-panel"] { display: none !important; }
  .fin-chart, table { break-inside: avoid; }
}

/* Ingredient editor (js/ui/ingredient-editor.js) */
.ing-row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; padding-bottom: var(--space-2); border-bottom: 1px solid var(--border); }
.ing-row__name { position: relative; flex: 1 1 220px; min-width: 0; }
.ing-row__name .input { width: 100%; }
.ing-row__full { flex-basis: 100%; }
.ing-suggest { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 2px); margin: 0; padding: 4px; list-style: none; background: var(--panel); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); max-height: 280px; overflow-y: auto; }
.ing-suggest__item { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; color: var(--text); font: inherit; }
.ing-suggest__item:hover, .ing-suggest__item:focus { background: var(--accent-soft); }
.ing-suggest__item--own strong { color: var(--accent-strong); }
.ing-status { font-weight: 700; color: var(--ok); min-width: 1em; text-align: center; }
.ing-status--off { color: var(--warn); }
.ing-grams { white-space: nowrap; }
/* At the shop: big rows, easy to tick with one thumb. */
.shop-mode .shop-tick { font-size: 1.15rem; padding: 10px 0; border-bottom: 1px solid var(--border); }
.shop-mode .shop-tick input { width: 1.4em; height: 1.4em; }

/* Drag and drop (js/ui/drag.js): a copy follows the pointer, the place under it lights up. */
.draggable { cursor: grab; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-user-drag: none; }
.dragging { opacity: .35; }
.drag-ghost { position: fixed; z-index: 1000; pointer-events: none; margin: 0; background: var(--panel); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); opacity: .95; list-style: none; }
.is-dragging, .is-dragging * { cursor: grabbing !important; }
/* While dragging, every place it can go is outlined; the one under the pointer lights up. */
.is-dragging .drop-target { outline: 1px dashed var(--border-strong); outline-offset: 2px; }
.is-dragging .drop-target.drop-over, .drop-over { outline: 3px solid var(--accent); outline-offset: 2px; background: var(--accent-soft); }
.reorder > li { padding-left: var(--space-2); padding-right: var(--space-2); border-radius: var(--radius-sm); }
.reorder > li.drag-ghost { display: flex; gap: var(--space-3); align-items: center; padding: var(--space-3) var(--space-2); }
.grip { color: var(--text-dim); font-size: 18px; line-height: 1; }

/* Meal Planner (D-053): planned meals beside a calendar, a week or a month. */
.planner-split { display: grid; gap: var(--space-4); align-items: start; }
@media (min-width: 900px) { .planner-split { grid-template-columns: minmax(240px, 1fr) 2fr; } .planner-split .pool { position: sticky; top: var(--space-3); max-height: calc(100vh - 2 * var(--space-3)); overflow-y: auto; } }
.pool.drop-over { outline-offset: -2px; }
.meal-chip { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 3px 10px; border: 1px solid var(--border-strong); border-left: 4px solid var(--accent); border-radius: var(--radius-sm); background: var(--panel); color: var(--text); text-decoration: none; font-size: 14px; }
.meal-chip:hover { background: var(--accent-soft); }
.meal-chip__title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meal-chip__sent { color: var(--ok); font-weight: 700; }
/* The bin (D-061): only while a meal is dragged, at the right-hand edge. */
.drag-bin { display: none; position: fixed; right: 8px; top: 50%; transform: translateY(-50%); z-index: 40;
  flex-direction: column; align-items: center; justify-content: center; gap: 4px; width: 76px; height: 120px;
  border: 2px dashed var(--danger); border-radius: var(--radius-lg); background: var(--panel); color: var(--danger); box-shadow: var(--shadow-md); }
.is-dragging .drag-bin { display: flex; }
.is-dragging .drag-bin.drop-target { outline: none; }
.is-dragging .drag-bin.drop-over { outline: none; background: var(--danger-soft); border-style: solid; transform: translateY(-50%) scale(1.08); }
.meal-chip__kind { font-size: 11px; font-weight: 700; color: var(--text-dim); }
.meal-chip--breakfast { border-left-color: var(--warn); }
.meal-chip--lunch { border-left-color: var(--ok); }
.meal-chip--snack { border-left-color: var(--border-strong); }
.cal-cell { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 34px; padding: 3px 6px; border-radius: var(--radius-sm); }
.cal-cell__kind { min-width: 64px; }
.cal-add { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); color: var(--text-dim); text-decoration: none; }
.cal-add:hover { border-color: var(--accent); color: var(--accent); }
.cal-today > div:first-child strong { color: var(--accent-strong); }
.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; padding: var(--space-2); }
.cal-month__head { text-align: center; padding: 2px 0; }
.cal-day { display: flex; flex-direction: column; gap: 3px; min-height: 84px; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); min-width: 0; }
.cal-day .meal-chip { font-size: 12px; padding: 2px 5px; border-left-width: 3px; }
.cal-day--other { opacity: .55; }
.cal-day.cal-today { border-color: var(--accent); }
.cal-day__num { color: var(--text-dim); }
@media (max-width: 600px) { .cal-day { min-height: 64px; padding: 2px; } .cal-day .meal-chip__title { display: none; } .cal-day .meal-chip { justify-content: center; } }

/* Plan in three steps (D-055): gather, sort, assign. */
.step-head { align-items: flex-start; flex-wrap: nowrap; }
.step-num { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; }
.pool-group { display: flex; flex-direction: column; gap: 6px; padding: var(--space-2) var(--space-3); border: 1px dashed var(--border-strong); border-radius: var(--radius); min-height: 70px; }
.pool-group__empty { margin: 0; }
.pool-sort { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.meal-chip--unsorted { border-left-color: var(--text-dim); border-left-style: dashed; }

/* Good for: little B, L, D, S circles that travel with a meal (D-057). */
.flags { display: inline-flex; gap: 2px; flex: none; }
.flag { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; font-size: 10px; font-weight: 700; line-height: 1; color: #fff; background: var(--text-dim); }
.flag--breakfast { background: var(--warn); }
.flag--lunch { background: var(--ok); }
.flag--dinner { background: var(--accent); }
.flag--snack { background: var(--border-strong); color: var(--text); }

/* Cook today (D-056): this shop's meals in a bar at the bottom, to swap with today's. */
.shop-strip { position: sticky; bottom: 0; z-index: 5; box-shadow: var(--shadow-md); max-height: 45vh; overflow-y: auto; }
.shop-strip__days { display: flex; gap: var(--space-2); overflow-x: auto; padding-bottom: 4px; }
.shop-strip__day { flex: 0 0 140px; display: flex; flex-direction: column; gap: 4px; min-height: 64px; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.shop-strip__day.is-today { border-color: var(--accent); background: var(--accent-soft); }
.shop-strip__day .meal-chip { font-size: 13px; }

/* Finance calculators (D-066) */
.fin-tag { font-weight: 400; font-size: 12px; color: var(--text-dim); }
.fin-tag:not(:empty)::before { content: "· "; }
.fin-group { border: 0; padding: 0; margin: 0; }
.fin-group legend { font-weight: 700; margin-bottom: var(--space-2); }
table.plain .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.fin-sums__total td { font-weight: 700; border-top: 2px solid var(--text-dim); }
.table-scroll { overflow-x: auto; }
.fin-better { color: var(--ok); }
.fin-worse { color: var(--warn); }
.fin-chart svg { display: block; max-width: 100%; height: auto; }
.fin-chart svg { touch-action: pan-y; }
.fin-read { min-height: 1.4em; font-variant-numeric: tabular-nums; }
.home-figs > summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: var(--space-1); flex-wrap: wrap; }
.home-figs > summary::-webkit-details-marker { display: none; }
.home-figs > summary::before { content: '▸'; margin-right: var(--space-1); }
.home-figs[open] > summary::before { content: '▾'; }
.home-figs[open] > summary { margin-bottom: var(--space-3); }
.fin-key { display: inline-block; width: 14px; height: 4px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.fin-tagno { display: inline-grid; place-items: center; width: 18px; height: 18px; border: 1.5px solid var(--text); border-radius: 50%; font-size: 11px; line-height: 1; }
.fin-step { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius); }
.fin-formula { display: block; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; padding: var(--space-1) var(--space-2); border-radius: 6px; background: color-mix(in srgb, var(--text) 6%, transparent); }
.fin-formula--worked { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.fin-overlap td { background: color-mix(in srgb, var(--warn) 10%, transparent); }

/* Where the money goes (D-074): a falling staircase of bars */
.money-steps { display: grid; gap: var(--space-2); }
.money-steps__row { display: grid; grid-template-columns: minmax(110px, 30%) 1fr auto; gap: var(--space-2); align-items: center; font-size: 14px; }
.money-steps__track { height: 14px; background: color-mix(in srgb, var(--text) 5%, transparent); border-radius: 4px; overflow: hidden; }
.money-steps__bar { display: block; height: 100%; border-radius: 4px; }
.money-steps__bar--total { background: var(--accent-strong); }
.money-steps__bar--cost { background: var(--warn); }
.money-steps__bar--kept { background: var(--text-dim); }
.money-steps__bar--deposit { background: var(--ok); }
.money-steps__amount { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* The (i) beside a heading or figure (D-078) */
.info-btn { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin-left: 4px; padding: 0; border-radius: 50%; border: 1px solid var(--border); background: var(--panel); color: var(--accent-strong); font: italic 700 12px/1 Georgia, serif; cursor: pointer; vertical-align: middle; }
.info-btn[aria-expanded="true"] { background: var(--accent-strong); color: var(--panel); border-color: var(--accent-strong); }
.info-box { font-size: 13px; line-height: 1.45; padding: var(--space-2) var(--space-3); border-radius: var(--radius); background: var(--panel-2); border-left: 3px solid var(--accent-strong); }
/* A section of the Home page: a tick to count it, and folding away */
.home-sec { padding: 0; }
.home-sec__head { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); flex-wrap: wrap; }
.home-sec__head h2 { margin: 0; font-size: 18px; flex: 1 1 auto; }
.home-sec__body { padding: 0 var(--space-4) var(--space-4); }
.home-sec--off .home-sec__head h2 { color: var(--text-dim); text-decoration: line-through; text-decoration-thickness: 1px; }
.home-sec__fold { border: 0; background: none; color: var(--text-dim); font-size: 18px; cursor: pointer; padding: 4px 8px; }
.fin-group--off legend { color: var(--text-dim); }

/* The note shown when an update arrived half-way (js/boot.js, D-132). */
.load-failed { max-width: 520px; margin: 15vh auto; padding: 24px; font: 16px/1.5 system-ui, sans-serif; text-align: center; }
.load-failed h1 { font-size: 22px; }
.load-failed button { font: inherit; padding: 10px 20px; border-radius: 999px; border: 1px solid #a8461f; background: #a8461f; color: #fff; cursor: pointer; }
