/*
  app.css
  Said & Done: base, layout, every shared component, and screen scaffolding (TECH_SPEC 16.2:
  exactly 3 stylesheets; this is the third). Reads semantic tokens from tokens.css only. Never a
  hex value here: a missing color becomes a token (DESIGN_SYSTEM 2 "Rules of use").

  Sections
   1. Base and resets          10. Measurement chip, dots, week strip, segmented bar
   2. Forced reduced motion    11. Goal card, Today rows, week card
   3. Shell, screens, docks    12. Rings, meters, stat tiles
   4. Top bar, banners, pills  13. Charts
   5. Cards, lists, rows       14. Winning-week banner, sparks, locked-in banner
   6. Buttons and links        15. Sheets, keypad, rating, stepper
   7. Forms and segmented      16. Toasts, coach marks, install hint, notices
   8. Domain, avatars          17. Food, journal, partners, reactions, books
   9. Check circle             18. Empty states, skeletons, gestures, utilities
*/

/* ------------------------------------------------------------------ */
/* 1. Base and resets                                                   */
/* ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { background-color: var(--bg); scroll-padding-top: calc(var(--safe-top) + 72px); }
body { min-height: 100vh; min-height: 100dvh; background: var(--bg); overflow-x: hidden; }
img, svg, video { max-width: 100%; }
img { display: block; }
h1, h2, h3, h4, p, ul, ol, figure, blockquote { margin: 0; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
button { cursor: pointer; }
button:disabled, [aria-disabled="true"] { cursor: default; }
a { color: var(--link); }
[hidden] { display: none !important; }
table { border-collapse: collapse; }
input, textarea, select { font-size: max(16px, var(--fs-input)); }

.sr-only, .visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

.icon {
  width: var(--icon-size); height: var(--icon-size); flex: none;
  fill: none; stroke: currentColor; stroke-width: var(--icon-stroke);
  stroke-linecap: round; stroke-linejoin: round; vertical-align: middle;
}
.icon--20 { width: 20px; height: 20px; }
.icon--16 { width: 16px; height: 16px; }
.icon--14 { width: 14px; height: 14px; }
.icon * { vector-effect: non-scaling-stroke; }

.tabular { font-variant-numeric: tabular-nums lining-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }

/* Long-press targets never select text, show the magnifier, or wait on double-tap zoom (16.5). */
.check, .mchip, .chip, .row, .item-row, .kp-key, .stepbtn, .tab, .seg__btn, .rating__btn, .qchip, .swipe > :first-child {
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}

/* ------------------------------------------------------------------ */
/* 2. "Reduce motion: Always" (settings.reduce_motion) mirrors the OS   */
/*    rules in tokens.css section 8.                                    */
/* ------------------------------------------------------------------ */
:root[data-motion="reduce"] {
  --dur-instant: 0ms; --dur-fast: 0ms; --dur-base: 0ms; --dur-slow: 0ms; --dur-slower: 0ms; --dur-celebrate: 0ms;
  --dur-fade: 160ms; --ease-spring: ease-out; --ease-spring-soft: ease-out;
}
:root[data-motion="reduce"] :where(.spark, .confetti, .float-up, .sparks) { display: none !important; }
:root[data-motion="reduce"] :where(*, *::before, *::after) {
  animation-duration: 1ms !important; animation-iteration-count: 1 !important;
  animation-delay: 0ms !important; scroll-behavior: auto !important;
}

/* ------------------------------------------------------------------ */
/* 3. Shell, screens, docks                                             */
/* ------------------------------------------------------------------ */
:root {
  --dock-offset: var(--safe-bottom);
  --toast-offset: calc(var(--safe-bottom) + 16px);
  --screen-bottom: calc(var(--safe-bottom) + var(--space-7));
}
:root[data-chrome="tabs"] {
  --dock-offset: calc(var(--tabbar-h) + var(--safe-bottom));
  --toast-offset: calc(var(--tabbar-h) + var(--safe-bottom) + 12px);
  --screen-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--space-7));
}
:root.kb-open { --dock-offset: 0px; --toast-offset: 12px; }
:root.sheet-open, :root.sheet-open body { overflow: hidden; }

.boot { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; }
.boot__mark {
  font: var(--fw-heavy) 28px/1 var(--font-ui); font-stretch: 88%; letter-spacing: -0.03em; color: var(--text-1);
  opacity: 0; animation: rise-in var(--dur-slower) var(--ease-out) 450ms both;
}
.boot__mark i { font-family: var(--font-voice); font-style: italic; font-weight: 400; }
.noscript { padding: var(--space-8) var(--gutter); text-align: center; color: var(--text-2); }

.shell { min-height: 100vh; min-height: 100dvh; }
.view { position: relative; }
.screen {
  position: relative; z-index: 1;
  max-width: var(--content-max); margin: 0 auto;
  min-height: 100vh; min-height: 100dvh;
  padding: 0 max(var(--gutter), var(--safe-right)) var(--screen-bottom) max(var(--gutter), var(--safe-left));
  outline: none;
}
.screen--fade { animation: backdrop-in var(--dur-fade) linear both; }
.screen__pad { padding-top: calc(var(--safe-top) + var(--space-8)); }
/* Full-screen views (wizard, Weekly Review, timer, welcome, season reset): 100dvh with a 100vh fallback */
.full { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.full__body { flex: 1 1 auto; }

/* The floodlight behind Today's and Reflect's titles; green only while the week is winning. */
.floodlight {
  position: absolute; inset: 0 0 auto 0; height: 420px; z-index: -1; pointer-events: none;
  background: var(--floodlight); transition: background var(--dur-slow) linear;
}
.is-winning .floodlight, .floodlight.is-winning { background: var(--floodlight-win); }

.section { margin-top: var(--space-8); }
.section:first-child { margin-top: 0; }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); margin: 0 var(--space-1) var(--space-4); }
.stack > * + * { margin-top: var(--space-4); }
.stack--l > * + * { margin-top: var(--space-6); }
.stack--s > * + * { margin-top: var(--space-3); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.spread { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.grow { flex: 1 1 auto; min-width: 0; }

/* A bar pinned to the bottom that rides above the tab bar and the iOS keyboard (5.8 rule 1):
   the Food composer, the wizard's Back/Next, the comment field. Add .dock-spacer at the end of
   the screen so content can scroll clear of it. */
.dock {
  position: fixed; left: 0; right: 0; bottom: calc(var(--kb-inset, 0px) + var(--dock-offset));
  z-index: calc(var(--z-tabbar) - 1);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--line);
  padding: var(--space-4) max(var(--gutter), var(--safe-right)) var(--space-4) max(var(--gutter), var(--safe-left));
}
:root[data-chrome="bare"] .dock:not(.dock--flush) { padding-bottom: calc(var(--space-4) + var(--safe-bottom)); bottom: calc(var(--kb-inset, 0px)); }
:root.kb-open .dock { padding-bottom: var(--space-4); }
.dock__inner { max-width: var(--content-max); margin: 0 auto; }
.dock--surface { background: var(--surface); }
.dock-spacer { height: 88px; }

/* Wizard / story progress segments */
.progress-segs { display: grid; grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr)); gap: 4px; }
.progress-segs i { height: 3px; border-radius: 2px; background: var(--line-strong); }
.progress-segs i.is-done, .progress-segs i.is-current { background: var(--brand); }

.rise { animation: rise-in var(--dur-slower) var(--ease-out) both; animation-delay: calc(var(--i, 0) * 60ms); }

/* ------------------------------------------------------------------ */
/* 4. Top bar, banners, status pills, verdict pills                     */
/* ------------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; gap: var(--space-3);
  margin: 0 calc(-1 * var(--gutter));
  padding: calc(var(--safe-top) + var(--space-3)) var(--gutter) var(--space-3);
  min-height: calc(var(--topbar-h) + var(--safe-top));
  background: transparent;
  transition: background-color var(--dur-fast) linear, box-shadow var(--dur-fast) linear;
}
.topbar.is-scrolled {
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px);
  box-shadow: 0 1px 0 var(--line);
}
.topbar--large { align-items: flex-end; padding-top: calc(var(--safe-top) + var(--space-7)); padding-bottom: var(--space-5); }
.topbar__titles { flex: 1 1 auto; min-width: 0; }
.topbar__title { margin: 0; overflow-wrap: anywhere; }
.topbar__sub { margin-top: 2px; }
.topbar__right { display: flex; align-items: center; gap: var(--space-2); flex: none; }
.topbar__back {
  width: var(--tap); height: var(--tap); margin-left: calc(-1 * var(--space-3)); flex: none;
  display: grid; place-items: center; border: 0; border-radius: var(--radius-pill);
  background: none; color: var(--text-1);
}
.topbar__back:active { background: var(--surface-2); }

.icon-btn {
  width: var(--tap); height: var(--tap); flex: none; display: grid; place-items: center;
  border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--surface);
  color: var(--text-2); box-shadow: var(--shadow-1); padding: 0;
}
.icon-btn--plain { border: 0; background: none; box-shadow: none; color: var(--text-1); }
.icon-btn:active { transform: scale(0.96); }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  margin: 0 0 var(--space-4); padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md); background: var(--surface-2); color: var(--text-2);
  font-size: var(--fs-body-s); font-weight: var(--fw-medium);
}
.banner .link { font-size: var(--fs-body-s); }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 var(--space-4) 0 var(--space-3);
  border-radius: var(--radius-pill); background: var(--surface-2); color: var(--text-2);
  font: var(--fw-semibold) var(--fs-body-s)/1.2 var(--font-ui); text-decoration: none;
}
.status-pill u { color: var(--text-1); text-underline-offset: 3px; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; max-height: 30px;
  padding: 0 var(--space-4) 0 var(--space-3); border-radius: var(--radius-pill);
  font: var(--fw-semibold) var(--fs-body-s)/1 var(--font-ui); white-space: nowrap;
}
.pill .icon { width: 14px; height: 14px; stroke-width: 2.2px; }
.pill--good { background: var(--status-done-tint); color: var(--status-done-text); }
.pill--close { background: var(--status-partial-tint); color: var(--status-partial-text); }
.pill--behind { background: var(--status-missed-tint); color: var(--status-missed-text); }
.pill--neutral { background: var(--surface-2); color: var(--text-2); }
.pill--win { background: color-mix(in srgb, var(--on-win) 12%, transparent); color: var(--on-win); height: 26px; }
.pill--win .icon { color: var(--win-accent); stroke-width: 2.4px; }
.pills { display: flex; flex-wrap: wrap; gap: var(--space-3); }

/* ------------------------------------------------------------------ */
/* 5. Cards, lists, rows                                                */
/* ------------------------------------------------------------------ */
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-1), var(--inner-highlight);
  padding: var(--space-5);
}
.card--hero { padding: var(--space-6) var(--space-6) var(--space-7); }
.card--well { background: var(--surface-2); box-shadow: none; }
.card--flat { box-shadow: none; }
.card--link { display: block; color: inherit; text-decoration: none; }
.card--link:active { transform: scale(0.995); }
.cards > * + * { margin-top: var(--space-4); }
.divider { height: 1px; background: var(--line); border: 0; margin: var(--space-5) 0; }

.list {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1); overflow: hidden;
}
.list > * + * { border-top: 1px solid var(--line); }
.list__label { margin: var(--space-7) var(--space-2) var(--space-3); }
.list__note { margin: var(--space-3) var(--space-2) 0; font-size: var(--fs-body-s); color: var(--text-3); }

.row {
  display: flex; align-items: center; gap: var(--space-4); width: 100%; min-height: 52px;
  padding: var(--space-3) var(--space-5); border: 0; background: none; color: var(--text-1);
  text-align: left; text-decoration: none; font: inherit;
}
button.row:active, a.row:active { background: var(--surface-2); }
.row__icon { flex: none; color: var(--text-2); display: grid; place-items: center; }
.row__text { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; }
.row__title { font-size: var(--fs-body); font-weight: var(--fw-medium); color: var(--text-1); overflow-wrap: anywhere; }
.row__sub { font-size: var(--fs-body-s); color: var(--text-2); }
.row__value { color: var(--text-2); font-size: var(--fs-body-s); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row__chev { color: var(--text-3); }
.row--danger .row__title, .row--danger .row__icon { color: var(--danger-text); }
.row--switch { cursor: pointer; }
.row[role="radio"][aria-checked="true"] { background: var(--brand-tint); }
.row.is-dragging { box-shadow: var(--shadow-2); border-radius: var(--radius-md); }

/* ------------------------------------------------------------------ */
/* 6. Buttons and links (DESIGN_SYSTEM 7.13)                            */
/* ------------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-3);
  min-height: 52px; padding: 0 var(--space-6); border-radius: var(--radius-md); border: 0;
  font: var(--fw-bold) var(--fs-title-s)/1.1 var(--font-ui); letter-spacing: -0.005em;
  text-decoration: none; text-align: center;
  transition: transform var(--dur-fast) var(--ease-out), background-color var(--dur-fast) linear, opacity var(--dur-fast) linear;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn .icon { width: 18px; height: 18px; }
.btn:disabled { opacity: 0.45; }
.btn--primary {
  background: var(--brand); color: var(--on-brand);
  box-shadow: var(--shadow-brand), inset 0 1px 0 color-mix(in srgb, var(--on-brand) 10%, transparent);
}
.btn--primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn--primary:active:not(:disabled) { background: var(--brand-press); }
.btn--verdict { background: var(--accent-deep); color: var(--on-accent-deep); box-shadow: var(--shadow-accent); }
.btn--quiet { background: var(--surface-2); color: var(--text-1); box-shadow: inset 0 0 0 1px var(--line); }
.btn--danger { background: var(--surface-2); color: var(--danger-text); box-shadow: inset 0 0 0 1px var(--line); }
.btn--ghost { background: none; color: var(--text-1); }
.btn--small { min-height: var(--tap); padding: 0 var(--space-5); font-size: var(--fs-body); }
.btn--block { width: 100%; }
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after {
  content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--on-brand) transparent var(--on-brand) var(--on-brand);
  animation: spin 800ms linear infinite;
}
.btn--quiet.is-busy::after, .btn--danger.is-busy::after { border-color: var(--text-1) transparent var(--text-1) var(--text-1); }
.btn-row { display: flex; gap: var(--space-3); }
.btn-row > .btn { flex: 1 1 0; }
.btn-col { display: grid; gap: var(--space-3); }

.link {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--tap);
  color: var(--link); font: var(--fw-semibold) var(--fs-body)/1.3 var(--font-ui);
  text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px;
  background: none; border: 0; padding: 0;
}
.link--s { font-size: var(--fs-body-s); }
/* A link inside a sentence that wraps (the consent line on sign-up and invite): inline, so the line
   box keeps the paragraph's height; the vertical padding still gives a finger about 44px to hit. */
.link--inline { display: inline; min-height: 0; padding-block: 12px; }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--text-1); animation: spin 800ms linear infinite;
}

/* ------------------------------------------------------------------ */
/* 7. Forms and segmented controls                                      */
/* ------------------------------------------------------------------ */
.field { display: grid; gap: var(--space-2); }
.field + .field { margin-top: var(--space-5); }
.field__label { font-size: var(--fs-body-s); font-weight: var(--fw-semibold); color: var(--text-2); }
.input {
  width: 100%; min-height: 52px; padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--control); border-radius: var(--radius-md);
  background: var(--raised); color: var(--text-1); font: var(--fw-body) max(16px, var(--fs-input))/1.35 var(--font-ui);
  -webkit-appearance: none; appearance: none;
  transition: border-color var(--dur-fast) linear, box-shadow var(--dur-fast) linear;
}
.input::placeholder { color: var(--text-3); opacity: 1; }
.input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 18%, transparent); }
.input--area { min-height: 88px; resize: none; line-height: 1.5; overflow: hidden; }
.input--l { font-size: var(--fs-body-l); }
.field__hint { font-size: var(--fs-body-s); color: var(--text-3); }
.field__hint.is-met { color: var(--status-done-text); }
/* One message per field: the username's live hint steps aside for an error, and so does any hint on
   the sign-in forms (Login, Sign up, Invite, Reset). Typing clears the error and brings it back. */
.has-error [data-unhint], .card--hero .has-error .field__hint { display: none; }
.field__error { display: flex; gap: var(--space-2); align-items: flex-start; font-size: var(--fs-body-s); color: var(--danger-text); font-weight: var(--fw-medium); }
.has-error .input { border-color: var(--danger); }
.form-error { display: flex; gap: var(--space-2); align-items: flex-start; margin-top: var(--space-4); color: var(--danger-text); font-size: var(--fs-body-s); font-weight: var(--fw-medium); }
select.input { background-image: none; padding-right: var(--space-7); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 72px; }
.input-wrap__btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); min-height: var(--tap); padding: 0 var(--space-4); border: 0; background: none; color: var(--text-1); font: var(--fw-semibold) var(--fs-body-s)/1 var(--font-ui); text-decoration: underline; text-underline-offset: 3px; }

/* Switch: a real checkbox with role="switch". Ink when on: a switch is chrome, not a verdict.
   Off, the track draws a 1.5px --control ring (3:1+ on every surface, DESIGN_SYSTEM 3.9, 13) and
   the knob a --line-strong edge, so an off switch reads in both themes. */
.switch {
  -webkit-appearance: none; appearance: none; flex: none; position: relative; margin: 0;
  width: 51px; height: 31px; border-radius: var(--radius-pill);
  background: var(--surface-3); box-shadow: inset 0 0 0 1.5px var(--control);
  transition: background-color var(--dur-fast) linear;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: var(--switch-knob); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line-strong);
  transition: transform var(--dur-base) var(--ease-spring);
}
.switch:checked { background: var(--brand); box-shadow: none; }
.switch:checked::after { background: var(--surface); box-shadow: var(--shadow-1); }
.switch:checked::after { transform: translateX(20px); }
.switch:disabled { opacity: 0.45; }
.switch:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.seg {
  display: inline-flex; align-items: stretch; gap: 2px; padding: 3px; min-height: var(--tap);
  border-radius: var(--radius-pill); background: var(--surface-2); max-width: 100%;
}
.seg--block { display: flex; width: 100%; }
.seg--block .seg__btn { flex: 1 1 0; }
.seg__btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 var(--space-4); border: 0; border-radius: var(--radius-pill);
  background: none; color: var(--text-2); text-decoration: none; white-space: nowrap;
  font: var(--fw-semibold) var(--fs-body-s)/1 var(--font-ui);
  transition: background-color var(--dur-fast) linear, color var(--dur-fast) linear;
}
.seg__btn[aria-pressed="true"], .seg__btn[aria-current="page"] {
  background: var(--raised); color: var(--text-1); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line);
}
.seg--nav { display: flex; width: 100%; }
.seg--nav .seg__btn { flex: 1 1 0; }
.seg__dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
.seg__btn:disabled { opacity: 0.4; }
/* Activity rows: the actions wrap under the text, lined up with it (40px avatar + the row gap). */
.row--act { flex-wrap: wrap; }
.row--act > .row__text { flex: 1 1 0; }
.act__actions { flex: 1 0 100%; display: flex; gap: var(--space-3); padding-left: calc(40px + var(--space-4)); margin-top: calc(-1 * var(--space-2)); }
/* DESIGN_SYSTEM 7.10: Patient / Defensive, 44px pill, the chosen segment in --brand-tint. */
.seg--tint { background: none; box-shadow: inset 0 0 0 1px var(--line-strong); }
.seg--tint .seg__btn[aria-pressed="true"] { background: var(--brand-tint); box-shadow: none; }

.qchip {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px;
  padding: 0 var(--space-4); border-radius: var(--radius-pill); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text-1); font: var(--fw-semibold) var(--fs-body-s)/1 var(--font-ui);
  font-variant-numeric: tabular-nums; position: relative;
}
.qchip::after { content: ""; position: absolute; inset: -4px -2px; }
.qchip[aria-pressed="true"] { background: var(--brand-tint); border: 1.5px solid var(--brand); }
.qchip:disabled { opacity: 0.4; }
/* A horizontal chip row fades out at its right edge, so a chip past the edge reads as "more this
   way" instead of a hard cut; the end padding lets the last chip scroll clear of the fade. */
.chips-row {
  display: flex; gap: var(--space-3); overflow-x: auto; padding: 4px 28px 4px 2px; scrollbar-width: none; overscroll-behavior-x: contain;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
}
.chips-row::-webkit-scrollbar { display: none; }
/* Choice chips (the wizard's Domain, How often): every option in view, wrapped. */
.chips-row--wrap { flex-wrap: wrap; overflow: visible; padding: 4px 2px; -webkit-mask-image: none; mask-image: none; }

/* ------------------------------------------------------------------ */
/* 8. Domain identity, avatars                                          */
/* ------------------------------------------------------------------ */
.dom-dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--dom); }
.dom-rule { border-left: 2px solid var(--dom); padding-left: var(--space-4); }
.dom-tile {
  width: 36px; height: 36px; flex: none; display: grid; place-items: center;
  border-radius: var(--radius-sm); background: var(--dom-tint); color: var(--dom);
}
.dom-tile--l { width: 44px; height: 44px; }
.dom-tile--s { width: 28px; height: 28px; border-radius: 8px; }
.dom-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 var(--space-3);
  border-radius: var(--radius-pill); background: var(--dom-tint); color: var(--text-1);
  font: var(--fw-semibold) var(--fs-body-s)/1 var(--font-ui);
}

.avatar {
  width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center;
  font: var(--fw-bold) 16px/1 var(--font-ui); color: var(--on-warm);
  background: linear-gradient(145deg, var(--warm), var(--warm-deep));
}
.avatar--40 { width: 40px; height: 40px; font-size: 15px; }
.avatar--28 { width: 28px; height: 28px; font-size: 11px; }
.avatar--64 { width: 64px; height: 64px; font-size: 22px; }
.avatar.is-in { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--status-done); }

/* ------------------------------------------------------------------ */
/* 9. Check circle (DESIGN_SYSTEM 7.1, 6.2)                             */
/* ------------------------------------------------------------------ */
.check {
  position: relative; width: var(--tap); height: var(--tap); flex: none;
  display: grid; place-items: center; padding: 0; margin: 0; border: 0; background: none;
  border-radius: 50%; color: inherit;
}
.check:focus-visible { outline: none; }
.check:focus-visible .check__disc { box-shadow: inset 0 0 0 var(--check-stroke) var(--control), 0 0 0 2px var(--focus-gap), 0 0 0 4px var(--focus); }
.check[data-state="done"]:focus-visible .check__disc { box-shadow: 0 0 0 2px var(--focus-gap), 0 0 0 4px var(--focus); }
.check__disc {
  position: relative; width: var(--check-size); height: var(--check-size); border-radius: 50%; overflow: hidden;
  background: var(--surface); box-shadow: inset 0 0 0 var(--check-stroke) var(--control);
  transition: transform var(--dur-instant) var(--ease-out), background-color var(--dur-fast) linear;
  isolation: isolate; display: grid; place-items: center;
}
.check__disc::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none; z-index: 2;
  box-shadow: inset 0 0 0 var(--ring-w, 0px) var(--ring-c, transparent);
}
.check__fill {
  position: absolute; inset: 0; background: var(--status-done);
  transform: translateY(calc((1 - var(--fill, 0)) * 100%));
  transition: transform var(--dur-slow) var(--ease-out), background-color var(--dur-base) linear;
}
.check__fill::after {
  content: ""; position: absolute; left: 0; top: -5px; width: 200%; height: 6px; background: inherit;
  -webkit-mask: var(--wave) repeat-x 0 0 / 17px 6px; mask: var(--wave) repeat-x 0 0 / 17px 6px; opacity: 0;
}
.check__glyph, .check__x { position: absolute; fill: none; stroke-linecap: round; stroke-linejoin: round; opacity: 0; z-index: 3; pointer-events: none; }
.check__glyph { width: 20px; height: 20px; stroke: var(--on-status-done); stroke-width: 2.4; transition: opacity var(--dur-fast) linear; }
.check__glyph path { stroke-dasharray: 20; stroke-dashoffset: 0; --check-len: 20; }
.check__x { width: 14px; height: 14px; stroke: var(--status-missed); stroke-width: 2.5; transition: opacity var(--dur-fast) linear; }
.check__trace {
  position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); pointer-events: none;
  fill: none; stroke: var(--brand); stroke-width: 2; stroke-linecap: round;
  stroke-dasharray: 128.8; stroke-dashoffset: 128.8; opacity: 0; z-index: 4;
}
.check__disc > .icon { position: relative; z-index: 3; }

.check:active:not([aria-disabled="true"]) .check__disc, .check.is-down .check__disc { transform: scale(0.92); }
.check.is-pressing .check__trace { opacity: 1; animation: trace calc(var(--lp-trace, 300ms)) linear forwards; }
@keyframes trace { to { stroke-dashoffset: 0; } }

.check[data-state="done"] { --fill: 1; }
.check[data-state="done"] .check__glyph { opacity: 1; }
.check[data-state="partial"] .check__fill { background: var(--status-partial); box-shadow: inset 0 2px 0 var(--horizon); }
.check[data-state="partial"] .check__disc { --ring-w: 2px; --ring-c: var(--status-partial-edge); box-shadow: none; }
.check[data-state="missed"] .check__disc { box-shadow: inset 0 0 0 var(--check-stroke) var(--status-missed-ring); }
.check[data-state="missed"] .check__x { opacity: 1; }
.check.is-today[data-state="open"] .check__disc { --ring-w: 2px; --ring-c: var(--status-today); }
.check[data-state="future"], .check[data-state="rest"] { cursor: default; }
.check[data-state="future"] .check__disc, .check[data-state="rest"] .check__disc { background: transparent; box-shadow: inset 0 0 0 1.25px var(--status-future); }
.check[data-state="rest"] .check__disc { color: var(--status-rest); }
.check[data-state="rest"] .check__disc .icon { width: 15px; height: 15px; }
.check.is-today[data-state="rest"] .check__disc { --ring-w: 1.5px; --ring-c: var(--status-today); }
.check[data-state="covered"] .check__disc { background: var(--status-done-tint); box-shadow: none; color: var(--status-done-text); }
.check[data-state="covered"] .check__disc .icon { width: 16px; height: 16px; stroke-width: 2.25px; }
.check[data-auto]::after {
  content: ""; position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--status-auto); box-shadow: 0 0 0 2px var(--surface); z-index: 4;
}
.check[data-bonus] .check__disc { background: transparent; box-shadow: none; outline: 2px dashed var(--status-done); outline-offset: -2px; }
.check[data-bonus] .check__fill { display: none; }
.check[data-bonus] .check__glyph { stroke: var(--status-done-text); }
.check--out { visibility: hidden; }
/* A check-in note: a small graphite tab, bottom right (the auto dot is a circle, top right). Never a verdict color. */
.check__note {
  position: absolute; bottom: 4px; right: 4px; width: 7px; height: 5px; border-radius: 2px;
  background: var(--text-3); box-shadow: 0 0 0 2px var(--surface); z-index: 4; pointer-events: none;
}

/* The light-up (fresh taps only) */
.check.is-animating .check__fill { animation: fill-rise var(--dur-slower) var(--ease-spring-soft) both; }
.check.is-animating .check__fill::after { opacity: 1; animation: wave-slosh var(--dur-slower) linear both; transition: opacity var(--dur-fast) var(--dur-slow); }
.check.is-animating .check__glyph path, .check.is-completing .check__glyph path { animation: check-draw var(--dur-base) var(--ease-out) calc(var(--dur-slow) - 80ms) both; }
.check.is-animating .check__disc { animation: done-pulse var(--dur-slower) var(--ease-out) var(--dur-base) both; }
.check.is-draining .check__fill { animation: fill-drain var(--dur-base) var(--ease-in) both; }
.check.is-draining .check__glyph { opacity: 0; }
.check.is-perfect .check__disc { animation: perfect-pulse 420ms var(--ease-spring) var(--pulse-delay, 0ms) both; }
@keyframes perfect-pulse { 0% { transform: scale(1); } 45% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* Compact (partner cards, Week mode) */
.check--sm { width: 32px; height: 32px; }
.check--sm .check__disc { width: var(--check-size-sm); height: var(--check-size-sm); }
.check--sm .check__glyph { width: 14px; height: 14px; }
.check--sm .check__x { width: 10px; height: 10px; stroke-width: 2px; }
.check--sm[data-state="partial"] .check__disc { --ring-w: 1.5px; }
.check--sm[data-auto]::after { width: 6px; height: 6px; top: 3px; right: 3px; }
.check--sm .check__note { width: 5px; height: 4px; bottom: 3px; right: 3px; }
.check--sm .check__disc > .icon { width: 12px; height: 12px; }
/* A button compact circle keeps the 44px hit area (DESIGN_SYSTEM 7.1). */
button.check--sm::before { content: ""; position: absolute; inset: -6px; }

@media (prefers-reduced-motion: reduce) {
  .check__fill, .check__glyph { transition: opacity var(--dur-fade) linear; }
}
:root[data-motion="reduce"] .check__fill, :root[data-motion="reduce"] .check__glyph { transition: opacity var(--dur-fade) linear; }

/* ------------------------------------------------------------------ */
/* 10. Measurement chip, micro dots, week strip, segmented bar          */
/* ------------------------------------------------------------------ */
.mchip {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 4px; flex: none;
  min-width: 64px; height: var(--tap); padding: 0 var(--space-4); border-radius: 12px;
  border: 1.5px dashed var(--control); background: transparent; color: var(--text-2);
  font: var(--fw-semibold) var(--fs-body-s)/1 var(--font-ui);
}
.mchip.is-logged { border: 0; background: var(--surface-2); color: var(--text-1); }
.mchip__val { font: var(--fw-semibold) 16px/1 var(--font-ui); font-variant-numeric: tabular-nums; }
.mchip.is-future { opacity: 0.35; }
.mchip:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.mchip:active:not([aria-disabled="true"]) { transform: scale(0.96); }
.mchip .icon { width: 16px; height: 16px; }
.mchip.is-new { animation: pop var(--dur-slow) var(--ease-spring) both; }
.mchip[data-note]::after {
  content: ""; position: absolute; bottom: 4px; right: 6px; width: 7px; height: 5px; border-radius: 2px;
  background: var(--text-3); box-shadow: 0 0 0 2px var(--surface); pointer-events: none;
}
.mchip.is-logged[data-note]::after { box-shadow: 0 0 0 2px var(--surface-2); }
.week .mchip[data-note]::after { bottom: 3px; right: 4px; width: 5px; height: 4px; }

.dots { display: inline-flex; gap: 4px; align-items: center; vertical-align: middle; }
.dots .dot { display: block; width: 6px; height: 6px; border-radius: 50%; box-shadow: inset 0 0 0 1.25px var(--line-strong); }
.dots .dot--done { background: var(--status-done); box-shadow: none; }
.dots .dot--partial { background: var(--status-partial); box-shadow: inset 0 0 0 1px var(--status-partial-edge); }
.dots .dot--missed { box-shadow: inset 0 0 0 1.5px var(--status-missed); }
.dots .dot--covered { background: var(--status-done-tint); box-shadow: inset 0 0 0 1px var(--status-done-text); }
.dots .dot--today { box-shadow: inset 0 0 0 1.5px var(--status-today); }
.dots .dot--logged { background: var(--text-3); box-shadow: none; }
.dots .dot--off { box-shadow: none; background: var(--line); transform: scaleY(0.34); border-radius: 2px; }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); justify-items: center; }
.week__day { display: grid; justify-items: center; gap: 2px; width: 100%; }
.week__letter {
  display: grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-pill);
  font: var(--fw-semibold) var(--fs-micro)/1 var(--font-ui); color: var(--text-3); letter-spacing: 0.04em;
}
.week__day.is-today .week__letter { background: var(--brand); color: var(--on-brand); font-weight: var(--fw-heavy); }
/* The sticky day header is opaque, so a row passing under it never shows through its letters.
   In a card it takes the card's surface; Today's (.week--page) is a full-width --bg band with a
   hairline, inset by the goal card's 1px border + --space-5 padding so each letter sits over its
   circle column (.goal-sec__body). */
.week--head { position: sticky; top: calc(var(--safe-top) + var(--topbar-h)); z-index: calc(var(--z-sticky) - 1); padding: var(--space-2) 0; background: var(--surface); }
.week--page {
  margin: var(--space-4) calc(-1 * max(var(--gutter), var(--safe-right))) 0 calc(-1 * max(var(--gutter), var(--safe-left)));
  padding: 6px calc(max(var(--gutter), var(--safe-right)) + var(--space-5) + 1px) 6px calc(max(var(--gutter), var(--safe-left)) + var(--space-5) + 1px);
  background: var(--bg); box-shadow: 0 1px 0 var(--line);
}
.week .mchip { min-width: 0; width: 40px; height: 32px; padding: 0; border-radius: 9px; font-size: 11px; }
.week .mchip .mchip__val { font-size: 12px; }
.week .mchip .mchip__unit { display: none; }
/* Week mode: today's column sits on --surface-2; circles there get a 2px --surface halo (3.7). */
.week--cols .week__day.is-today { background: var(--surface-2); }
.week--cols .week__day.is-today .check__disc { box-shadow: inset 0 0 0 var(--check-stroke) var(--control), 0 0 0 2px var(--surface); }
.week--cols .week__day.is-today .check[data-state="done"] .check__disc,
.week--cols .week__day.is-today .check[data-state="covered"] .check__disc { box-shadow: 0 0 0 2px var(--surface); }
.week--cols .week__day.is-today .check__note { box-shadow: 0 0 0 2px var(--surface-2); }
.week-pill {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: var(--tap);
  padding: 0 var(--space-4); border-radius: var(--radius-pill); background: var(--surface-2); color: var(--text-1);
  font: var(--fw-semibold) var(--fs-body-s)/1.2 var(--font-ui); border: 0; width: 100%;
}

.segs { display: grid; grid-template-columns: repeat(var(--n, 7), minmax(0, 1fr)); gap: 3px; height: 10px; align-items: end; }
.segs i { display: block; height: 10px; border-radius: 3px; box-shadow: inset 0 0 0 1px var(--line-strong); }
.segs i.s-done { background: var(--status-done); box-shadow: none; }
.segs i.s-partial { background: var(--status-partial); box-shadow: inset 0 0 0 1.5px var(--status-partial-edge); }
.segs i.s-missed { height: 3px; background: var(--status-missed); box-shadow: none; }
.segs i.s-today { box-shadow: inset 0 0 0 1.5px var(--status-today); }
.segs--mini { height: 6px; }
.segs--mini i { height: 6px; border-radius: 2px; }
.segs--mini i.s-missed { height: 2px; }

/* ------------------------------------------------------------------ */
/* 11. Goal card, Today rows, week card (DESIGN_SYSTEM 7.3, 10)         */
/* ------------------------------------------------------------------ */
.goal-card { padding: var(--space-5); }
.goal__head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--space-4); align-items: center; }
.goal__name { margin: 0; }
.goal__meta { margin: 2px 0 0; }
.goal__identity {
  margin: var(--space-4) 0 0; padding-left: var(--space-4); border-left: 2px solid var(--dom);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.goal__identity.is-open { -webkit-line-clamp: unset; display: block; }
.whisper-slot { min-height: 0; }
.whisper { margin: var(--space-2) 0 var(--space-3); animation: whisper 3440ms var(--ease-out) both; }
/* The whisper never moves the page (ui/celebrate.js whisper): a slot with data-cover or data-echo
   takes no height, and its line is laid over the covered element (the goal's name, the day's
   date), bottom edge on its bottom edge, growing upward. The covered element fades out under it. */
.whisper-slot[data-cover], .whisper-slot[data-echo] { position: relative; height: 0; }
.whisper--over {
  position: absolute; z-index: 2; margin: 0; display: flex; align-items: center; pointer-events: none;
}
.whisper--over .whisper__t {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden;
  font-size: 15px; line-height: 1.3; color: var(--text-1);
}
.whisper--center { justify-content: center; text-align: center; }
.is-whispered { opacity: 0; transition: opacity 180ms linear; }
:where(.goal-sec__name, .log-date__mid, .goal__identity) { transition: opacity 320ms linear; }
/* Goal detail: the identity card already shows the words, so they replay in place (no echo). */
.goal__identity.is-echo { animation: whisper-echo 1400ms var(--ease-out) both; }
@keyframes whisper-echo {
  0% { opacity: 0.25; transform: translateY(8px); }
  22% { opacity: 1; transform: translateY(0); }
  100% { opacity: 1; transform: none; }
}
:root[data-motion="reduce"] .whisper { animation: none; }
@media (prefers-reduced-motion: reduce) { .whisper { animation: none; } }
@keyframes whisper {
  0% { opacity: 0; transform: translateY(8px); }
  7% { opacity: 1; transform: translateY(0); }
  88% { opacity: 1; }
  100% { opacity: 0; }
}
.measure { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--line); }
.measure__row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); margin-bottom: var(--space-2); }
.measure__label { font-weight: var(--fw-semibold); font-size: var(--fs-body); color: var(--text-1); }
.measure__count { font-size: var(--fs-body-s); color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.measure__count b { font-family: var(--font-num); font-variation-settings: var(--num-variation); font-weight: var(--fw-num); font-size: 20px; color: var(--text-1); }
.outcome { display: grid; grid-template-columns: auto 1fr; gap: var(--space-3) var(--space-4); align-items: center; margin-top: var(--space-5); padding: var(--space-4); border-radius: var(--radius-md); background: var(--surface-2); }
.outcome__bar { height: 6px; border-radius: 6px; background: var(--surface-3); position: relative; }
.outcome__bar i { position: absolute; inset: 0 auto 0 0; width: var(--p, 0%); border-radius: 6px; background: var(--status-done); }
.outcome__bar b { position: absolute; top: -4px; bottom: -4px; left: var(--pace, 0%); width: 2px; border-radius: 2px; background: var(--text-1); }
.outcome__txt { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); font-size: var(--fs-body-s); color: var(--text-2); font-variant-numeric: tabular-nums; }

/* Today goal sections and item rows (PRODUCT_SPEC 6.3) */
.goal-sec { margin-top: var(--space-6); }
.goal-sec__head {
  display: flex; align-items: center; gap: var(--space-3); min-height: 48px; width: 100%;
  border: 0; background: none; padding: 0; color: var(--text-1); text-align: left; text-decoration: none;
}
.goal-sec__name { flex: 1 1 auto; min-width: 0; font: var(--fw-semibold) var(--fs-title-s)/1.3 var(--font-ui); }
.goal-sec__score { font-size: var(--fs-body-s); color: var(--text-2); font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 4px; }
.goal-sec__score > .icon { width: 14px; height: 14px; color: var(--status-done-text); }
.goal-sec__body { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); padding: 0 var(--space-5); }
.item-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-4);
  min-height: 64px; padding: var(--space-3) 0;
}
.item-row + .item-row { border-top: 1px solid var(--line); }
.item-row__main { display: grid; gap: 3px; min-width: 0; text-align: left; background: none; border: 0; padding: 0; color: inherit; font: inherit; }
.item-row__name { font: var(--fw-medium) 16px/1.35 var(--font-ui); color: var(--text-1); overflow-wrap: anywhere; }
.item-row__status { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); font-size: var(--fs-body-s); color: var(--text-2); font-variant-numeric: tabular-nums; }
/* The day's check-in note under the status line (Day mode): one quiet line. */
.item-row__note { display: flex; align-items: center; gap: var(--space-2); min-width: 0; font-size: var(--fs-body-s); color: var(--text-2); }
.item-row__note .icon { width: 14px; height: 14px; flex: none; color: var(--text-3); }
.item-row__ctrl { display: flex; align-items: center; justify-content: flex-end; }
.item-row--week { grid-template-columns: 1fr; gap: var(--space-2); }
/* Goal detail: leads that start after this week ("Starts Mon 10/19"). */
.upcoming { display: grid; margin: 0; padding: 0; list-style: none; }
.upcoming__row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-4); padding: var(--space-3) 0; }
.upcoming__row + .upcoming__row { border-top: 1px solid var(--line); }
.upcoming__row .body-s { white-space: nowrap; color: var(--text-2); }

.weekcard { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-5); align-items: center; color: inherit; text-decoration: none; }
.weekcard__big { font-family: var(--font-num); font-variation-settings: var(--num-variation); font-weight: var(--fw-num); font-size: 22px; color: var(--text-1); }
.weekcard__line { font-size: var(--fs-body); color: var(--text-1); text-wrap: balance; }
.weekcard__sub { font-size: var(--fs-body-s); color: var(--text-2); margin-top: 2px; }
.weekcard__foot { grid-column: 1 / -1; display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); }
.weekcard__hint { font-size: var(--fs-body-s); color: var(--text-2); }
.minibars { display: flex; align-items: flex-end; gap: var(--space-3); }
.minibar { display: grid; justify-items: center; gap: 5px; }
.minibar__track { position: relative; width: 6px; height: 36px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.minibar__track i { position: absolute; left: 0; right: 0; bottom: 0; height: var(--p, 4%); border-radius: 3px; background: var(--chart-below); transition: height var(--dur-slower) var(--ease-out); }
.minibar.is-locked .minibar__track i { background: var(--status-done); }
.minibar .dom-dot { width: 6px; height: 6px; }

.now-card { display: grid; gap: var(--space-3); }
.now-card__close { position: absolute; top: 4px; right: 4px; }
.date-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.date-chip {
  position: relative; display: grid; justify-items: center; gap: 2px; min-height: 52px; padding: 6px 0;
  border-radius: var(--radius-md); border: 0; background: var(--surface-2); color: var(--text-1); text-decoration: none;
  font: var(--fw-semibold) 13px/1 var(--font-ui); font-variant-numeric: tabular-nums;
}
.date-chip small { font-size: 10.5px; color: var(--text-3); font-weight: var(--fw-semibold); }
.date-chip[aria-current="date"], .date-chip.is-selected { background: var(--brand); color: var(--on-brand); }
.date-chip[aria-current="date"] small, .date-chip.is-selected small { color: var(--on-brand); }
.date-chip.is-future { opacity: 0.4; pointer-events: none; }
.date-chip .dom-dot, .date-chip__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--status-done); }

/* ------------------------------------------------------------------ */
/* 12. Rings, meters, stat tiles (DESIGN_SYSTEM 7.4, 7.5)               */
/* ------------------------------------------------------------------ */
.ring { position: relative; width: var(--size); height: var(--size); flex: none; display: grid; place-items: center; }
.ring svg { position: absolute; inset: 0; display: block; transform: rotate(-90deg); overflow: visible; }
.ring__track { fill: none; stroke: var(--surface-2); }
.ring__arc { fill: none; stroke: var(--status-done); stroke-linecap: round; transition: stroke-dashoffset var(--dur-slower) var(--ease-out), stroke var(--dur-base) linear; }
.ring__arc.is-zero { stroke: transparent; }
.ring__arc--close { stroke: var(--status-partial); }
.ring__arc--below { stroke: var(--chart-below); }
.ring__over { fill: none; stroke: var(--status-missed); stroke-linecap: round; }
.ring__tick { stroke: var(--text-1); stroke-width: 2; stroke-linecap: round; }
.ring--40 .ring__tick { stroke-width: 1.5; }
.ring__num, .ring__center { position: relative; z-index: 1; text-align: center; color: var(--text-1); }
.ring__num { font-family: var(--font-num); font-variation-settings: var(--num-variation); font-weight: var(--fw-num); letter-spacing: -0.03em; line-height: 1; }
.ring__num sup { font-size: 0.45em; vertical-align: 0.8em; margin-left: 1px; letter-spacing: 0; }
.ring__num--xs { font: var(--fw-semibold) 11px/1 var(--font-ui); letter-spacing: 0; font-variant-numeric: tabular-nums; }
.ring__num--s { font-size: 17px; }
.ring__num--l { font-size: 46px; }
.ring__num--xl { font-size: 64px; }
.ring--timer .ring__num--xl { font-size: 56px; }
.ring__center--stack { display: grid; justify-items: center; gap: 2px; }
.ring__of { font-size: var(--fs-micro); color: var(--text-2); font-weight: var(--fw-semibold); }
.ring.is-win svg { filter: drop-shadow(0 0 3px color-mix(in srgb, var(--pulse-color) 45%, transparent)); }
.ring.is-flaring svg { animation: ring-flare var(--dur-celebrate) var(--ease-out) both; }
/* The lock badge sits just outside the ring at 4:30, clear of the arc (its center is at least the
   stroke's outer radius + the badge's radius from the ring's center): a solid padlock with the
   check knocked out, on the done tint. */
.ring__lock {
  position: absolute; right: -2px; bottom: -2px; z-index: 2; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; background: var(--status-done-tint); color: var(--status-done-text);
  box-shadow: 0 0 0 2px var(--surface); --icon-knock: var(--status-done-tint);
}
.ring__lock .icon { stroke-width: 2px; }
/* The ring's own svg is rotated -90deg and pinned to the box; the badge's glyph must be neither
   (rotated, the padlock read as a chain link). */
.ring .ring__lock svg { position: static; inset: auto; transform: none; display: block; }
.ring--64 .ring__lock { width: 20px; height: 20px; right: -7px; bottom: -7px; }
.ring--64 .ring__lock .icon { width: 13px; height: 13px; }
.ring--40 .ring__lock, .ring--28 .ring__lock { width: 15px; height: 15px; right: -7px; bottom: -7px; }
.ring--40 .ring__lock .icon, .ring--28 .ring__lock .icon { width: 10px; height: 10px; }
.ring--timer .ring__arc { stroke: var(--brand); }
.ring--timer.is-done .ring__arc { stroke: var(--status-done); }

.meter { position: relative; height: 8px; border-radius: 4px; background: var(--surface-2); margin-top: var(--space-4); }
.meter__fill { position: absolute; left: 0; top: 0; bottom: 0; width: var(--p); border-radius: 4px; background: var(--status-done); transition: width var(--dur-slower) var(--ease-out), background-color var(--dur-base) linear; }
.meter.is-close .meter__fill { background: var(--status-partial); }
.meter.is-over .meter__fill { width: calc(var(--t) - 3px); background: var(--chart-below); border-radius: 4px 0 0 4px; }
.meter__over { position: absolute; top: 0; bottom: 0; left: calc(var(--t) + 3px); width: var(--o); border-radius: 0 4px 4px 0; background: var(--status-missed); }
.meter__tick { position: absolute; top: -3px; bottom: -3px; left: calc(var(--t) - 1px); width: 2px; border-radius: 1px; background: var(--text-1); }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.tile { padding: var(--space-5) var(--space-5) var(--space-4); min-width: 0; }
.tile__label { display: flex; align-items: center; gap: var(--space-2); color: var(--text-2); font-size: var(--fs-body-s); font-weight: var(--fw-medium); }
.tile__label .icon { color: var(--dom); width: 16px; height: 16px; }
.tile__value { margin-top: var(--space-4); display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--space-1) var(--space-2); color: var(--text-1); }
.tile__unit { font-size: var(--fs-body-s); color: var(--text-3); font-weight: var(--fw-medium); }
.tile__foot { margin-top: var(--space-3); font-size: var(--fs-body-s); color: var(--text-2); display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: var(--fw-semibold); }
.delta .icon { width: 14px; height: 14px; stroke-width: 2.2px; }
.delta--good { color: var(--status-done-text); }
.delta--over { color: var(--status-missed-text); }
.delta--close { color: var(--status-partial-text); }
.spark-svg { display: block; width: 100%; height: 28px; margin-top: var(--space-3); overflow: visible; }
.glow-good { animation: glow-good 600ms var(--ease-out) both; }
@keyframes glow-good { 0% { text-shadow: 0 0 0 transparent; } 40% { text-shadow: 0 0 18px var(--pulse-color); } 100% { text-shadow: 0 0 0 transparent; } }

/* ------------------------------------------------------------------ */
/* 13. Charts (DESIGN_SYSTEM 9)                                         */
/* ------------------------------------------------------------------ */
.chart { padding: var(--space-5) var(--space-4) var(--space-4) var(--space-5); }
.chart__head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); padding-right: var(--space-2); }
.chart__titles { min-width: 0; }
.chart__right { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-2); }
.chart__controls { margin-top: var(--space-3); }
.chart__plot { margin-top: var(--space-3); }
.chart__foot { margin-top: var(--space-3); }
.chart__svgwrap { position: relative; touch-action: pan-y; }
.chart__svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart__svg .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart__svg .axis { font: 11px/1 var(--font-ui); fill: var(--chart-axis); font-variant-numeric: tabular-nums; }
.chart__svg .axis--today, .chart__svg .axis--win { fill: var(--text-2); font-weight: 620; }
.chart__svg .axis--val { fill: var(--text-1); font-weight: 620; }
.chart__svg .axis--note { font-style: italic; }
.chart__svg .axis--tiny { font-size: 9px; }
.chart__svg .band { fill: var(--chart-band); }
.chart__svg .wash-ahead { fill: var(--chart-ahead); }
.chart__svg .wash-behind { fill: var(--chart-behind); }
.chart__svg .pace { fill: none; stroke: var(--chart-pace); stroke-width: 1.5; stroke-dasharray: 4 4; stroke-linecap: round; }
.chart__svg .target { fill: var(--surface); stroke: var(--chart-pace); stroke-width: 1.5; }
.chart__svg .dot { fill: var(--chart-dot); stroke: var(--surface); stroke-width: 1.5; }
.chart__svg .dot--line { fill: var(--chart-line); }
.chart__svg .line { fill: none; stroke: var(--chart-line); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart__svg .end { fill: var(--chart-line); stroke: var(--surface); stroke-width: 2; }
.chart__svg .end--ahead { fill: var(--status-done); }
.chart__svg .today { stroke: var(--line-strong); stroke-width: 1; }
.chart__svg .crosshair { stroke: var(--text-3); stroke-width: 1; }
.chart__svg .crosshair.is-off { display: none; }
.chart__svg .winline { stroke: var(--text-1); stroke-width: 1.5; }
.chart__svg .col--win { fill: var(--chart-win); }
.chart__svg .col--close { fill: var(--chart-close); }
.chart__svg .col--below { fill: var(--chart-below); }
.chart__svg .col--none { fill: var(--line-strong); }
.chart__svg .col--over { fill: var(--status-missed); }
.chart__svg .col--open { fill: none; stroke: var(--line-strong); stroke-width: 1; }
.chart__svg .col--live { fill-opacity: 0.55; stroke: var(--text-1); stroke-width: 1.5; stroke-dasharray: 3 2; }
/* The week in progress at 80%+ of what's due so far, not won yet: on pace, a light green column. */
.chart__svg .col--pace { fill: var(--status-done-tint); }
.chart__svg .col--pace.col--live { fill-opacity: 1; }
.chart__tip {
  position: absolute; top: 2px; transform: translateX(-50%); z-index: 2; pointer-events: none;
  padding: 6px 9px; border-radius: var(--radius-sm); background: var(--raised); box-shadow: var(--shadow-2);
  font: 12px/1.4 var(--font-ui); color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.chart__tip b { color: var(--text-1); }
.chart--placeholder { padding: var(--space-4) var(--space-5); }
.chart--placeholder p { display: flex; align-items: center; gap: var(--space-3); margin-top: var(--space-2); }
.chart--placeholder p:first-child { margin-top: 0; }
.chart__multi + .chart__multi { margin-top: var(--space-5); }
.chart__multi-t { font-size: var(--fs-body-s); color: var(--text-2); }
.chart__multi-t b { color: var(--text-1); font-weight: var(--fw-semibold); }

.legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); margin-top: var(--space-3); font-size: var(--fs-body-s); color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: var(--space-3); }
.key { display: inline-block; width: 16px; height: 0; border-top: 2.5px solid var(--chart-line); }
.key--line { border-top: 2.5px solid var(--chart-line); }
.key--pace { border-top: 1.5px dashed var(--chart-pace); }
.key--band, .key--ahead, .key--win, .key--below, .key--empty, .key--heat0, .key--heat3, .key--heat5, .key--heatpace { height: 10px; border: 0; border-radius: 3px; }
.key--band { background: var(--chart-band); }
.key--ahead { background: var(--chart-ahead); }
.key--win { background: var(--chart-win); }
.key--below { background: var(--chart-below); }
.key--empty { box-shadow: inset 0 0 0 1px var(--line-strong); }
.key--heat0 { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.key--heat3 { background: var(--chart-close); }
.key--heat5 { background: var(--chart-win); }
.key--heatpace { background: var(--status-done-tint); box-shadow: inset 0 0 0 1px var(--status-done); }
.key--over { height: 3px; border: 0; border-radius: 2px; background: var(--status-missed); }
.key--dot { width: 7px; height: 7px; border: 0; border-radius: 50%; background: var(--chart-dot); }

.chart__table { margin-top: var(--space-3); font-size: var(--fs-body-s); color: var(--text-2); }
.chart__table summary {
  display: inline-flex; align-items: center; min-height: var(--tap); cursor: pointer; list-style: none;
  color: var(--link); font-weight: var(--fw-semibold); text-decoration: underline; text-underline-offset: 3px;
}
.chart__table summary::-webkit-details-marker { display: none; }
.chart__table[open] summary { margin-bottom: var(--space-2); }
.chart__table table { width: 100%; font-variant-numeric: tabular-nums; }
.chart__table th, .chart__table td { padding: 6px 4px; text-align: right; border-top: 1px solid var(--line); }
.chart__table th:first-child { text-align: left; font-weight: var(--fw-medium); color: var(--text-1); }
.chart__table thead th { color: var(--text-3); font-weight: var(--fw-semibold); border-top: 0; }

/* Weekly score by goal (9.2) */
.bars { display: grid; gap: var(--space-4); }
.bar { display: grid; grid-template-columns: 22px minmax(0, 1fr) 70px; align-items: center; gap: var(--space-3); color: inherit; text-decoration: none; }
.bar__icon { width: 18px; height: 18px; color: var(--dom); }
.bar__main { display: grid; gap: 4px; min-width: 0; }
.bar__name { font-size: var(--fs-body-s); color: var(--text-1); font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar__track { position: relative; height: 12px; }
.bar__track i { position: absolute; left: 0; top: 0; bottom: 0; width: var(--p); border-radius: 0 4px 4px 0; background: var(--chart-below); }
.bar--win .bar__track i { background: var(--chart-win); }
.bar--close .bar__track i { background: var(--chart-close); }
.bar__track b { position: absolute; left: var(--win, 80%); top: -4px; bottom: -4px; width: 2px; background: var(--text-1); border-radius: 1px; }
.bar__val { display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px; font: var(--fw-semibold) var(--fs-body-s)/1 var(--font-ui); color: var(--text-1); }
.bar__val .icon { width: 14px; height: 14px; stroke-width: 2.2px; }
.bar--win .bar__val .icon { color: var(--status-done-text); }
.bar--close .bar__val .icon { color: var(--status-partial-text); }
.bars__axis { display: grid; grid-template-columns: 22px minmax(0, 1fr) 70px; gap: var(--space-3); font-size: var(--fs-micro); color: var(--text-3); }
.bars__axis span:nth-child(2) { position: relative; height: 12px; }
.bars__axis em { position: absolute; left: var(--win, 80%); transform: translateX(-50%); font-style: normal; font-weight: var(--fw-semibold); color: var(--text-2); white-space: nowrap; }

/* Heat grid (C2) and calendars */
.heat { margin-top: var(--space-3); }
.heat__row { display: grid; grid-template-columns: minmax(64px, 30%) minmax(0, 1fr); align-items: center; gap: var(--space-3); margin-top: 6px; }
.heat__name { font-size: var(--fs-body-s); color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.heat__cells { display: grid; grid-template-columns: repeat(var(--cols, 14), minmax(0, 26px)); gap: 3px; }
.heat__cell { aspect-ratio: 1; border-radius: 4px; display: grid; place-items: center; color: var(--on-status-done); max-height: 26px; }
.heat__cell.is-win { background: var(--chart-win); }
.heat__cell.is-close { background: var(--chart-close); }
.heat__cell.is-below { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-strong); }
.heat__cell.is-none { background: transparent; border: 1px dashed var(--line-strong); }
/* The week in progress, not won yet: 80%+ so far is "on pace" (light green, no check); nothing due
   yet is an empty cell under the current outline, never the dashed no-plan cell. */
.heat__cell.is-pace { background: var(--status-done-tint); box-shadow: inset 0 0 0 1px var(--status-done); }
.heat__cell.is-wait { background: transparent; }
/* The week in progress: a 1.5px ink outline just outside the cell (PRODUCT_SPEC C2), so the cell
   keeps its own verdict fill and border under it. */
.heat__cell.is-current { outline: 1.5px solid var(--text-1); outline-offset: 1px; }
.heat__row--head { margin-top: 0; margin-bottom: 2px; }
.heat__row--head .heat__name { font-size: var(--fs-micro); color: var(--text-3); }
.heat__wk { display: flex; justify-content: center; white-space: nowrap; font: var(--fw-medium) 11px/1 var(--font-ui); color: var(--text-3); font-variant-numeric: tabular-nums; }
.heat__cell .icon { width: 10px; height: 10px; stroke-width: 2.6px; }
.heat__legend { margin-top: var(--space-4); }

.cal { margin-top: var(--space-3); }
.cal__head, .cal__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal__head span { text-align: center; font: var(--fw-semibold) var(--fs-micro)/1 var(--font-ui); color: var(--text-3); padding-bottom: 6px; }
.cal__day { position: relative; aspect-ratio: 1; border-radius: 8px; display: grid; place-items: center; max-height: 48px; }
.cal__heat { position: absolute; inset: 0; border-radius: 8px; }
.cal__num { position: relative; z-index: 1; font: var(--fw-semibold) 11px/1 var(--font-ui); color: var(--text-2); font-variant-numeric: tabular-nums; }
.cal__day[data-level="4"] .cal__num, .cal__day[data-level="5"] .cal__num { color: var(--on-accent); }
.cal__day.is-today { box-shadow: inset 0 0 0 2px var(--text-1); }
.cal__day.is-future { opacity: 0.45; }
.cal__pad { aspect-ratio: 1; }
button.cal__day { border: 0; background: none; padding: 0; }

.dotgrid { display: grid; gap: 5px; margin-top: var(--space-3); }
.dotgrid__row { display: grid; grid-template-columns: 40px minmax(0, 1fr) 20px; align-items: center; gap: var(--space-3); }
.dotgrid__label { font-size: var(--fs-micro); color: var(--text-3); font-variant-numeric: tabular-nums; }
.dotgrid__cells { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.dotgrid__count { font-size: var(--fs-body-s); color: var(--text-1); text-align: right; }
.dg { height: 12px; border-radius: 3px; }
.dg--done { background: var(--status-done); }
.dg--empty { box-shadow: inset 0 0 0 1px var(--line-strong); }
.dg--before { background: transparent; }
.dg--future { box-shadow: inset 0 0 0 1px var(--line); opacity: 0.5; }

.mtiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.mtile { display: grid; gap: 6px; padding: var(--space-4); border-radius: var(--radius-md); background: var(--surface-2); color: var(--text-2); }
.mtile--within { background: var(--status-done-tint); color: var(--status-done-text); }
.mtile--open { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
.mtile__name { font: var(--fw-bold) var(--fs-title-s)/1.1 var(--font-ui); color: var(--text-1); }
.mtile__res { display: inline-flex; align-items: center; gap: 4px; font: var(--fw-semibold) 12px/1.2 var(--font-ui); }

/* C11 reading: one row per week (its Monday on the left), M to S letters on top. Days before the
   reading lead started are blank; days still ahead are hairline outlines, never "missed". */
.rdgrid { display: grid; gap: 4px; margin-top: var(--space-3); }
.rdgrid__row { display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: center; gap: var(--space-3); }
.rdgrid__label { font-size: var(--fs-micro); color: var(--text-3); font-variant-numeric: tabular-nums; }
.rdgrid__cells { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.rdgrid__letters b, .dotgrid__letters b { font: var(--fw-semibold) var(--fs-micro)/1 var(--font-ui); color: var(--text-3); text-align: center; }
.rd { aspect-ratio: 1; border-radius: 6px; background: var(--heat-0); max-height: 40px; }
.rd.is-read { background: var(--heat-4); }
.rd--before { background: transparent; }
.rd--future { background: transparent; box-shadow: inset 0 0 0 1px var(--status-future); }

/* ------------------------------------------------------------------ */
/* 14. Winning-week banner, sparks, locked-in banner (7.15, 6.3)        */
/* ------------------------------------------------------------------ */
.win {
  position: relative; overflow: hidden; border-radius: var(--radius-lg); padding: 18px 18px 20px;
  background: linear-gradient(140deg, var(--win-bg) 0%, var(--win-bg-2) 100%); color: var(--on-win); box-shadow: var(--shadow-2);
}
.win__bulbs {
  position: absolute; inset: 0; background: var(--win-texture); background-size: 10px 10px; pointer-events: none;
  -webkit-mask: linear-gradient(115deg, transparent 35%, black 100%); mask: linear-gradient(115deg, transparent 35%, black 100%);
}
.win > *:not(.win__bulbs) { position: relative; }
.win__top { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.win__wk { font-size: 12px; color: var(--on-win-2); font-variant-numeric: tabular-nums; }
.win__mid { display: grid; grid-template-columns: auto 1fr; gap: var(--space-5); align-items: center; margin-top: var(--space-4); }
.win__ring { position: relative; width: var(--size, 88px); height: var(--size, 88px); display: grid; place-items: center; }
.win__ring svg { position: absolute; inset: 0; display: block; transform: rotate(-90deg); overflow: visible; }
.win__track { fill: none; stroke: var(--win-track); }
.win__arc { fill: none; stroke: var(--win-accent); stroke-linecap: round; transition: stroke-dashoffset var(--dur-slower) var(--ease-out); }
.win__tick { stroke: color-mix(in srgb, var(--on-win) 60%, transparent); stroke-width: 2; stroke-linecap: round; }
.win__num { position: relative; color: var(--win-accent); font-family: var(--font-num); font-variation-settings: var(--num-variation); font-weight: var(--fw-num); font-size: 30px; letter-spacing: -0.03em; }
.win__num sup { font-size: 0.45em; vertical-align: 0.8em; margin-left: 1px; }
.win__t { font: var(--fw-heavy) 22px/1.1 var(--font-ui); font-stretch: 92%; letter-spacing: -0.02em; color: var(--on-win); }
.win__s { font-size: var(--fs-body); color: var(--on-win-2); margin-top: 4px; }
.win__quote { font-size: var(--fs-voice-l); color: var(--on-win); }
.win .progress-segs i { background: color-mix(in srgb, var(--on-win) 28%, transparent); }
.win .progress-segs i.is-done, .win .progress-segs i.is-current { background: var(--on-win); }
.win--full {
  min-height: 100vh; min-height: 100dvh; border-radius: 0; box-shadow: none;
  padding: calc(var(--safe-top) + var(--space-8)) var(--gutter) calc(var(--safe-bottom) + var(--space-8));
  background: var(--win-bg-2) url("/img/win-bg.webp") center top / cover no-repeat;
  display: flex; flex-direction: column; justify-content: center;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .win--full {
    background-image: linear-gradient(color-mix(in srgb, var(--win-bg-2) 45%, transparent), color-mix(in srgb, var(--win-bg-2) 45%, transparent)), url("/img/win-bg.webp");
  }
}
:root[data-theme="dark"] .win--full {
  background-image: linear-gradient(color-mix(in srgb, var(--win-bg-2) 45%, transparent), color-mix(in srgb, var(--win-bg-2) 45%, transparent)), url("/img/win-bg.webp");
}
.win--full .win__num--hero { font-size: 72px; }
/* The ink primary on the deep-green winning card: a light ring gives its edge 3:1 against the
   green in the light theme (in dark it's paper and the ring disappears into it). */
.win .btn--primary { box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--on-win) 55%, transparent), var(--shadow-brand); }

.sparks { position: fixed; pointer-events: none; z-index: var(--z-celebrate); }
.spark {
  position: absolute; left: var(--x); top: var(--y); width: var(--s, 6px); height: var(--s, 6px); border-radius: 50%;
  background: var(--c); box-shadow: 0 0 8px var(--c);
  animation: spark-rise var(--dur-celebrate) var(--ease-out) var(--delay, 0ms) both;
}
.spark--streak { width: 3px; height: 12px; border-radius: 2px; }

.lock-banner {
  position: fixed; left: 0; right: 0; top: calc(var(--safe-top) + 8px); z-index: var(--z-celebrate);
  padding: 0 var(--gutter); pointer-events: auto; animation: banner-drop 240ms var(--ease-out) both;
}
.lock-banner.is-leaving { animation: banner-up 240ms var(--ease-in) both; }
.lock-banner__inner { max-width: calc(var(--content-max) - 2 * var(--gutter)); margin: 0 auto; display: grid; gap: var(--space-2); padding: 14px 16px; }
.lock-banner__inner .pill { justify-self: start; }
.lock-banner__row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-4); align-items: center; }
.lock-banner__body { display: grid; gap: var(--space-2); min-width: 0; }
.win__ring.is-flaring svg { animation: ring-flare var(--dur-celebrate) var(--ease-out) both; }
.lock-banner__text { color: var(--on-win); font-size: var(--fs-body); }
.lock-banner__text b { font-weight: var(--fw-heavy); }
@keyframes banner-drop { from { transform: translateY(-130%); } to { transform: translateY(0); } }
@keyframes banner-up { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-130%); opacity: 0; } }

/* ------------------------------------------------------------------ */
/* 15. Sheets, keypad, rating, stepper (7.6, 7.8)                       */
/* ------------------------------------------------------------------ */
.sheet-layer { position: fixed; inset: 0; z-index: var(--z-sheet); }
.sheet-backdrop { position: absolute; inset: 0; background: var(--overlay); opacity: 0; transition: opacity 220ms linear; touch-action: none; }
.sheet-layer.is-open .sheet-backdrop { opacity: 1; }
.sheet-layer.is-closing .sheet-backdrop { opacity: 0; transition-duration: 220ms; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: var(--kb-inset, 0px); margin: 0 auto; max-width: var(--content-max);
  max-height: calc(92vh - var(--kb-inset, 0px)); max-height: calc(92dvh - var(--kb-inset, 0px));
  display: flex; flex-direction: column; outline: none;
  background: var(--raised); border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-3), var(--inner-highlight);
  padding: var(--space-3) max(20px, var(--safe-right)) 0 max(20px, var(--safe-left));
  transform: translateY(100%); transition: transform var(--dur-slow) var(--ease-spring-soft);
}
.sheet-layer.is-open .sheet { transform: translateY(0); }
.sheet-layer.is-closing .sheet { transform: translateY(100%); transition: transform 220ms var(--ease-in); }
@media (prefers-reduced-motion: reduce) {
  .sheet { transform: none; opacity: 0; transition: opacity 160ms linear; }
  .sheet-layer.is-open .sheet { transform: none; opacity: 1; }
  .sheet-layer.is-closing .sheet { transform: none; opacity: 0; transition: opacity 160ms linear; }
}
:root[data-motion="reduce"] .sheet { transform: none; opacity: 0; transition: opacity 160ms linear; }
:root[data-motion="reduce"] .sheet-layer.is-open .sheet { transform: none; opacity: 1; }
:root[data-motion="reduce"] .sheet-layer.is-closing .sheet { transform: none; opacity: 0; }
.sheet__grab { flex: none; width: 36px; height: 5px; border-radius: 5px; background: var(--line-strong); margin: 0 auto var(--space-4); }
.sheet__head { flex: none; display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.sheet__titles { flex: 1 1 auto; min-width: 0; padding-top: 2px; }
.sheet__title { margin: 0; outline: none; overflow-wrap: anywhere; }
.sheet__sub { margin-top: var(--space-2); }
.sheet__close { width: var(--tap); height: var(--tap); margin: -8px -10px 0 0; flex: none; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: var(--text-3); }
.sheet__close:active { background: var(--surface-2); }
/* The body reaches 8px into the sheet's side padding (and pads it back), so an .action-list's -8px
   margin fits inside it instead of making the body scroll sideways. */
.sheet__body { flex: 1 1 auto; min-height: 0; margin: 0 -8px; padding: 0 8px var(--space-4); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet__foot { flex: none; padding: var(--space-4) 0 calc(20px + var(--safe-bottom)); border-top: 1px solid var(--line); margin: 0 -2px; }
:root.kb-open .sheet__foot { padding-bottom: var(--space-4); }
.sheet__text { color: var(--text-2); }
.sheet__error { margin-top: var(--space-3); color: var(--danger-text); font-size: var(--fs-body-s); font-weight: var(--fw-medium); }
.sheet--confirm .sheet__foot { border-top: 0; padding-top: var(--space-2); }
.sheet--confirm .sheet__head { margin-bottom: var(--space-3); }
.sheet--confirm .sheet__title { font-size: var(--fs-title-m); line-height: 1.3; }
.sheet--tall { height: calc(92vh - var(--kb-inset, 0px)); height: calc(92dvh - var(--kb-inset, 0px)); }

.action-list { display: grid; gap: 2px; margin: 0 -8px; }
/* The doc sheet's Open button sits in the scrolling body, which clips its drop shadow into a gray box. */
.gdoc-sheet .sheet__body .btn--primary { box-shadow: none; }
.action-row {
  position: relative; display: flex; align-items: center; gap: var(--space-4); width: 100%; min-height: 52px;
  padding: 0 var(--space-3); border: 0; border-radius: var(--radius-md); background: none; color: var(--text-1);
  font: var(--fw-medium) var(--fs-title-s)/1.2 var(--font-ui); text-align: left; cursor: pointer;
}
.action-row:active, .action-row:focus-within { background: var(--surface-2); }
.action-row small { margin-left: auto; color: var(--text-3); font-size: var(--fs-body-s); }
.action-row--danger { color: var(--danger-text); }
.action-row input[type="file"] { position: absolute; inset: 0; opacity: 0; width: 1px; height: 1px; }

.readout { display: flex; align-items: center; justify-content: center; gap: var(--space-4); margin: var(--space-4) 0 var(--space-2); }
.readout__val { display: inline-flex; align-items: baseline; gap: var(--space-3); min-width: 0; }
.readout__num { font-size: 72px; color: var(--text-1); font-variant-numeric: lining-nums; border-radius: 10px; padding: 0 6px; }
.readout__num.is-selected { background: var(--brand-tint); }
.readout__unit { font-size: var(--fs-title-s); color: var(--text-3); font-weight: var(--fw-medium); }
.readout-hint { text-align: center; font-size: var(--fs-body-s); color: var(--text-2); margin: 0 0 var(--space-2); }
.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: var(--space-4) 0 0; }
.kp-key {
  height: 64px; border-radius: var(--radius-md); border: 0; background: var(--surface-2); color: var(--text-1);
  font: var(--fw-semibold) 22px/1 var(--font-ui); font-variant-numeric: tabular-nums;
  display: grid; place-items: center; transition: background-color var(--dur-instant) linear, transform var(--dur-instant) linear;
}
.kp-key:active { background: var(--surface-3); transform: scale(0.97); }
.kp-key--blank { background: transparent; }
.kp-key--back { color: var(--text-2); }
.stepbtn {
  width: var(--tap); height: var(--tap); flex: none; display: grid; place-items: center; border-radius: 50%;
  border: 0; background: var(--surface-2); color: var(--text-1); box-shadow: inset 0 0 0 1px var(--line);
}
.stepbtn:active:not(:disabled) { transform: scale(0.94); background: var(--surface-3); }
.stepbtn:disabled { opacity: 0.35; }
.quick-chips { display: flex; justify-content: center; gap: var(--space-3); margin-top: var(--space-3); }
.stepper { display: flex; align-items: center; justify-content: center; gap: var(--space-6); }
.stepper__val { min-width: 3ch; text-align: center; color: var(--text-1); }
.stepper--big .stepbtn { width: 64px; height: 64px; }
.stepper--big .stepbtn .icon { width: 28px; height: 28px; }

.rating { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-top: var(--space-4); }
.rating__btn {
  height: 56px; border-radius: var(--radius-sm); border: 1.5px solid var(--control); background: var(--raised);
  font: var(--fw-semibold) 17px/1 var(--font-ui); color: var(--text-1); padding: 0; font-variant-numeric: tabular-nums;
}
.rating__btn[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.rating__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-4); }
.rating__marks { display: flex; gap: var(--space-4); font-size: var(--fs-body-s); color: var(--text-3); }
.rating__context { padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--surface-2); color: var(--text-2); font-size: var(--fs-body-s); }
.readout--rating .readout__num { font-size: 64px; }

/* ------------------------------------------------------------------ */
/* 16. Toasts, coach marks, install hint, notices                       */
/* ------------------------------------------------------------------ */
/* --toast-dock (ui/toast.js) lifts toasts 12px above a bottom dock: the Food composer, a pager, Next. */
.toast-host {
  position: fixed; left: 0; right: 0; bottom: max(calc(var(--kb-inset, 0px) + var(--toast-offset)), var(--toast-dock, 0px)); z-index: var(--z-toast);
  display: flex; justify-content: center; padding: 0 var(--gutter); pointer-events: none;
}
.toast {
  pointer-events: auto; width: 100%; max-width: calc(var(--content-max) - 2 * var(--gutter));
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  min-height: 48px; padding: 12px var(--space-4) 12px var(--space-5); border-radius: 12px;
  background: var(--brand); color: var(--on-brand); font-size: var(--fs-body); box-shadow: var(--shadow-2);
  animation: toast-in 200ms var(--ease-out) both; touch-action: none;
}
.toast.is-leaving { animation: toast-out 160ms linear both; }
/* While a sheet is up, toasts sit at the top so they never cover its footer (Save, the composer). */
:root.sheet-open:not(.kb-open) .toast-host { bottom: auto; top: calc(var(--safe-top) + var(--space-3)); }
.toast__msg { flex: 1 1 auto; min-width: 0; }
.toast__icon { display: grid; place-items: center; }
.toast__action {
  flex: none; min-height: var(--tap); padding: 0 var(--space-2); border: 0; background: none; color: var(--on-brand);
  font: var(--fw-semibold) var(--fs-body)/1 var(--font-ui); text-decoration: underline; text-underline-offset: 3px;
}
@keyframes toast-in { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toast-out { to { opacity: 0; } }

.coach { position: fixed; inset: 0; z-index: calc(var(--z-celebrate) + 5); cursor: pointer; opacity: 0; transition: opacity var(--dur-base) linear; }
.coach.is-open { opacity: 1; }
.coach.is-leaving { opacity: 0; }
.coach__hole { position: fixed; border-radius: 50%; box-shadow: 0 0 0 9999px var(--overlay); pointer-events: none; transition: left var(--dur-slow) var(--ease-out), top var(--dur-slow) var(--ease-out), width var(--dur-slow) var(--ease-out), height var(--dur-slow) var(--ease-out); }
.coach__bubble {
  position: fixed; left: var(--gutter); right: var(--gutter); max-width: 360px; margin: 0 auto;
  padding: var(--space-5); border-radius: var(--radius-lg); background: var(--raised); box-shadow: var(--shadow-2);
}
.coach__text { font: var(--fw-semibold) var(--fs-body-l)/1.4 var(--font-ui); color: var(--text-1); }
.coach__step { margin-top: var(--space-3); font-size: var(--fs-body-s); color: var(--text-3); }
.coach__skip {
  position: fixed; top: calc(var(--safe-top) + 12px); right: var(--gutter); min-height: var(--tap); padding: 0 var(--space-5);
  border-radius: var(--radius-pill); border: 0; background: var(--raised); color: var(--text-1); box-shadow: var(--shadow-2);
  font: var(--fw-semibold) var(--fs-body)/1 var(--font-ui);
}

.install-hint {
  position: fixed; left: var(--gutter); right: var(--gutter); bottom: calc(var(--kb-inset, 0px) + var(--dock-offset) + 12px);
  z-index: calc(var(--z-toast) - 1); max-width: calc(var(--content-max) - 2 * var(--gutter)); margin: 0 auto;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: var(--space-3);
  padding: var(--space-4) var(--space-2) var(--space-4) var(--space-4);
  border-radius: var(--radius-lg); background: var(--raised); border: 1px solid var(--line); box-shadow: var(--shadow-2);
  animation: rise-in var(--dur-slower) var(--ease-out) both;
}
.install-hint__icon { color: var(--text-1); padding-top: 2px; }
.install-hint__text { font-size: var(--fs-body-s); color: var(--text-1); line-height: 1.45; }
.install-hint__close { width: var(--tap); height: var(--tap); margin: -10px 0 -10px 0; display: grid; place-items: center; border: 0; background: none; color: var(--text-3); border-radius: 50%; }
:root.kb-open .install-hint, :root.sheet-open .install-hint { display: none; }

.notice-banner {
  position: fixed; left: var(--gutter); right: var(--gutter); top: calc(var(--safe-top) + 8px); z-index: var(--z-toast);
  max-width: calc(var(--content-max) - 2 * var(--gutter)); margin: 0 auto;
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-3); align-items: start;
  padding: var(--space-4); border-radius: var(--radius-lg); background: var(--raised); border: 1px solid var(--line);
  box-shadow: var(--shadow-2); color: var(--text-1); font-size: var(--fs-body-s); animation: banner-drop 240ms var(--ease-out) both;
}
.notice-banner .icon { color: var(--text-1); }
.notice-banner .btn { grid-column: 2; justify-self: start; margin-top: var(--space-2); }

/* ------------------------------------------------------------------ */
/* 17. Food, journal, partners, reactions, books (7.9 to 7.12)          */
/* ------------------------------------------------------------------ */
.food { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: var(--space-4); color: inherit; text-decoration: none; text-align: left; background: none; border: 0; padding: 0; width: 100%; font: inherit; }
.food__photo { position: relative; width: 76px; height: 76px; border-radius: var(--radius-md); overflow: hidden; background: var(--surface-2); display: grid; place-items: center; color: var(--dom-food); }
.food__photo img { width: 100%; height: 100%; object-fit: cover; }
.food__photo.is-estimating::after {
  content: ""; position: absolute; inset: 0; background: var(--shimmer); background-size: 60% 100%; background-repeat: no-repeat;
  animation: ai-shimmer 1.4s var(--ease-in-out) infinite;
}
.food__top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); }
.food__title { font-size: var(--fs-body); font-weight: var(--fw-medium); color: var(--text-1); }
.food__meta { font-size: var(--fs-body-s); color: var(--text-2); }
.food__items { list-style: none; margin: var(--space-3) 0 0; padding: 0; font-size: var(--fs-body-s); color: var(--text-2); }
.food__items li { display: flex; justify-content: space-between; gap: var(--space-3); padding: 3px 0; font-variant-numeric: tabular-nums; }
.food__items li span:last-child { color: var(--text-1); font-weight: var(--fw-medium); }
.food__items li.is-low span:last-child { text-decoration: underline dotted; text-underline-offset: 3px; }
.ai-note { display: inline-flex; align-items: center; gap: var(--space-2); margin-top: var(--space-3); font-size: var(--fs-body-s); color: var(--text-2); font-weight: var(--fw-semibold); }
.ai-note .icon { width: 16px; height: 16px; }
.ai-note--edited { color: var(--text-3); font-weight: var(--fw-medium); }
.food-fail { display: flex; align-items: center; gap: var(--space-3); margin-top: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--surface-2); color: var(--text-2); font-size: var(--fs-body-s); }
.food-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: var(--space-3); min-height: 56px; }
.food-row__thumb { width: 40px; height: 40px; border-radius: 10px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; color: var(--dom-food); }
.food-row__thumb img { width: 100%; height: 100%; object-fit: cover; }
.food-row__cal { font: var(--fw-semibold) var(--fs-body)/1 var(--font-ui); font-variant-numeric: tabular-nums; color: var(--text-1); }
.tag-review { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--radius-xs); background: var(--surface-2); color: var(--text-2); font: var(--fw-semibold) 12px/1 var(--font-ui); }
.composer { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: end; gap: var(--space-3); }
.composer .input { min-height: var(--tap); border-radius: 22px; padding: 10px var(--space-4); }
.send-btn { width: var(--tap); height: var(--tap); flex: none; display: grid; place-items: center; border-radius: 50%; border: 0; background: var(--brand); color: var(--on-brand); box-shadow: var(--shadow-brand); }
.send-btn:disabled { opacity: 0.35; box-shadow: none; }

.journal__prompt { margin: 0 0 var(--space-3); }
.joys { list-style: none; margin: 0; padding: 0; }
.joys li { display: grid; grid-template-columns: 20px 1fr; gap: var(--space-3); padding: 5px 0; font-size: var(--fs-body-l); line-height: 1.4; color: var(--text-1); }
.joys li .icon { width: 18px; height: 18px; margin-top: 3px; color: var(--dom-heart); }
.journal__block { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--line); }
.tag { display: inline-flex; align-items: center; gap: var(--space-2); height: 26px; padding: 0 var(--space-3); border-radius: var(--radius-xs); font-size: var(--fs-body-s); font-weight: var(--fw-semibold); }
.tag .icon { width: 14px; height: 14px; }
.tag--patient { background: var(--status-done-tint); color: var(--status-done-text); }
.tag--defensive { background: var(--surface-2); color: var(--text-2); }
.jar-card { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-4); align-items: center; }
.jar-card img { width: 64px; height: 64px; }
.jar-card.is-shaking img { animation: shake 300ms var(--ease-in-out) both; }
@keyframes shake { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }

.partner__head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--space-4); align-items: center; }
.admin-id { overflow-wrap: anywhere; }
/* Names and handles are typed by anyone who has the link (open sign-up), with no spaces if they like:
   they wrap inside their box instead of widening the page and pushing the tab bar off screen. */
body { overflow-wrap: break-word; }
.name-wrap { overflow-wrap: anywhere; min-width: 0; }
.partner__goals { margin-top: var(--space-4); display: grid; gap: var(--space-2); }
.pg { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-3); font-size: var(--fs-body); min-height: 36px; }
.pg .dom-dot { width: 8px; height: 8px; }
.reactions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-4); }
.chip {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 var(--space-4);
  border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2);
  font: var(--fw-semibold) var(--fs-body-s)/1 var(--font-ui); font-variant-numeric: tabular-nums;
}
.chip::after { content: ""; position: absolute; inset: -4px -2px; }
.chip .emo { font-size: 17px; line-height: 1; display: inline-block; }
.chip.is-mine, .chip[aria-pressed="true"] { background: var(--brand-tint); border: 1.5px solid var(--brand); color: var(--text-1); }
.chip.is-popping .emo { animation: reaction-pop var(--dur-slow) var(--ease-spring) both; }
.plus1 { position: absolute; right: 8px; top: -6px; font-size: 11px; color: var(--text-1); animation: float-up var(--dur-slower) var(--ease-out) both; }
.react-pop { display: flex; gap: var(--space-3); padding: var(--space-3); border-radius: var(--radius-pill); background: var(--raised); box-shadow: var(--shadow-2); }
.comment { margin-top: var(--space-4); display: flex; gap: var(--space-3); align-items: flex-start; font-size: var(--fs-body); color: var(--text-1); }
.comment small { color: var(--text-3); display: block; font-size: var(--fs-body-s); }
.comment__body { overflow-wrap: anywhere; white-space: pre-wrap; }
/* A partner's check-in note: a line under the item's week (partner day), and the top of its comment sheet. */
.entry-note--row { display: flex; align-items: flex-start; gap: var(--space-2); margin-top: var(--space-2); font-size: var(--fs-body-s); color: var(--text-2); }
.entry-note--row .icon { width: 14px; height: 14px; flex: none; margin-top: 2px; color: var(--text-3); }
/* On the partner day the line is a button: tapping the note opens its cell's sheet (the full text, comments). */
button.entry-note--row {
  width: 100%; min-height: var(--tap); margin-top: 0; padding: var(--space-2) 0;
  border: 0; border-radius: var(--radius-sm); background: none; font: inherit; font-size: var(--fs-body-s); color: var(--text-2); text-align: left;
}
button.entry-note--row:active { background: var(--surface-2); }
button.entry-note--row:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.entry-note--sheet { padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--surface-2); color: var(--text-1); }
.entry-note__label { color: var(--text-3); margin-bottom: var(--space-2); }
.entry-note__text { color: var(--text-2); }
/* The item detail Notes card: the opened day, then the month's other notes as rows. */
.notes-card__date { color: var(--text-3); }
.notes-card__list { display: grid; }
.notes-card__row {
  display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: var(--tap); padding: var(--space-3) 0;
  border: 0; background: none; color: var(--text-1); font: inherit; text-align: left;
}
.notes-card__text { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; }
.notes-card__row + .notes-card__row, .notes-card__day + .notes-card__list .notes-card__row:first-child { border-top: 1px solid var(--line); }
button.notes-card__row:active { background: var(--surface-2); }
button.notes-card__row:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* The number and rating sheets keep the note behind "Add a note" until asked for. */
.note-slot { display: grid; justify-items: center; margin-top: var(--space-3); }
.note-slot > .note-field { justify-self: stretch; }

/* Generated book covers: one of the six identity hues, mixed into the surface (DESIGN_SYSTEM 3.8). */
.cover {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: var(--space-3);
  width: 160px; aspect-ratio: 160 / 220; padding: var(--space-4); border-radius: var(--radius-md);
  background: color-mix(in oklab, var(--cov, var(--dom-work)) 24%, var(--surface)); border: 1px solid var(--line);
  box-shadow: var(--shadow-1); color: var(--text-1); overflow: hidden;
}
.cover::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--cov, var(--dom-work)); }
.cover__title { font: var(--fw-bold) 17px/1.15 var(--font-ui); font-stretch: 94%; overflow-wrap: anywhere; }
.cover__author { font-size: var(--fs-body-s); color: var(--text-2); }
.cover[data-cover="0"] { --cov: var(--dom-fitness); }
.cover[data-cover="1"] { --cov: var(--dom-food); }
.cover[data-cover="2"] { --cov: var(--dom-heart); }
.cover[data-cover="3"] { --cov: var(--dom-people); }
.cover[data-cover="4"] { --cov: var(--dom-work); }
.cover[data-cover="5"] { --cov: var(--dom-money); }
.cover--s { width: 56px; padding: 6px; border-radius: 8px; }
.cover--s .cover__title { font-size: 9px; }
.cover--s .cover__author { display: none; }
.cover.is-flipping { animation: flip 400ms var(--ease-in-out) both; }
@keyframes flip { 0% { transform: perspective(600px) rotateY(0); } 50% { transform: perspective(600px) rotateY(90deg); } 100% { transform: perspective(600px) rotateY(0); } }
.shelf { display: flex; gap: var(--space-4); overflow-x: auto; padding: 4px 2px 12px; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none; }
.shelf::-webkit-scrollbar { display: none; }
.shelf > * { scroll-snap-align: start; flex: none; }

/* Story cards (Weekly Review) */
.story { position: relative; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding: calc(var(--safe-top) + var(--space-4)) var(--gutter) calc(var(--safe-bottom) + var(--space-6)); }
.story__progress { position: relative; z-index: 2; }
.story__card { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center; }
.story--plain { background: var(--surface-2); }
.story__tap { position: absolute; top: 0; bottom: 0; width: 50%; z-index: 1; background: none; border: 0; }
.story__tap--prev { left: 0; }
.story__tap--next { right: 0; }

/* Login, Invite, Reset hero (PRODUCT_SPEC 6.1; art from docs/ART.md) */
.login-hero {
  position: relative; height: 38vh; height: 38dvh; min-height: 220px;
  margin: 0 calc(-1 * var(--gutter)); display: grid; place-items: center; align-content: center; gap: var(--space-3);
  background: var(--bg) url("/img/hero-login.webp") center top / cover no-repeat;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .login-hero { background-image: url("/img/hero-login-dark.webp"); }
}
:root[data-theme="dark"] .login-hero { background-image: url("/img/hero-login-dark.webp"); }
/* Sign-up's long form: a shorter hero keeps "Create my account" closer (docs/changes/signup.md 1.2). */
.login-hero--compact { height: 22vh; height: 22dvh; min-height: 168px; }
.app-mark { width: 64px; height: 64px; border-radius: 15px; box-shadow: var(--shadow-2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .app-mark { box-shadow: 0 0 0 1px var(--line-strong), var(--shadow-2); } }
:root[data-theme="dark"] .app-mark { box-shadow: 0 0 0 1px var(--line-strong), var(--shadow-2); }

/* The wordmark (DESIGN_SYSTEM 11): Bricolage 800 with the ampersand in Fraunces italic and a lit cell. */
.wordmark { display: inline-flex; align-items: baseline; gap: 0.18em; font: 800 30px/1 var(--font-ui); font-stretch: 88%; letter-spacing: -0.03em; color: var(--text-1); }
.wordmark i { font-family: var(--font-voice); font-style: italic; font-weight: 400; letter-spacing: 0; }
.wordmark__cell { width: 0.42em; height: 0.42em; border-radius: 50%; background: var(--status-done); display: inline-grid; place-items: center; transform: translateY(-0.02em); }
.wordmark__cell .icon { width: 0.34em; height: 0.34em; color: var(--on-status-done); stroke-width: 3px; }

/* Log screens (food, weight, journal, books, reading timer): layout from B6, tokens only. */
.log-seg { margin: var(--space-1) 0 0; }
.books-meta { margin: var(--space-4) var(--space-1) 0; }
/* The Log tabs (Food, Weight, Journal, Books) keep the same top bar height, so the segment control
   under it never moves when he switches: a right-side button (Books' Add, an offline pill) hangs
   from the title's bottom edge instead of making the bar taller. */
[data-top]:has(+ .log-seg) .topbar__right { height: 0; align-self: flex-end; display: flex; align-items: flex-end; }
.log-date { display: grid; grid-template-columns: var(--tap) minmax(0, 1fr) var(--tap); align-items: center; gap: var(--space-3); margin: var(--space-5) 0 var(--space-4); }
.log-date__mid { min-width: 0; text-align: center; }
.log-date__title { font: var(--fw-bold) var(--fs-title-m)/1.2 var(--font-ui); letter-spacing: var(--track-snug); color: var(--text-1); }
.log-date__sub { margin-top: 2px; font-size: var(--fs-body-s); color: var(--text-2); }
.log-date .icon-btn:disabled { opacity: 0.3; box-shadow: none; }
.log-note { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-body-s); color: var(--text-3); }
.log-note .icon { width: 14px; height: 14px; flex: none; }
.log-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin: var(--space-7) var(--space-2) var(--space-3); }
.log-head__side { font-size: var(--fs-body-s); color: var(--text-2); font-variant-numeric: tabular-nums; }

.food-day { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-5); align-items: center; }
.food-day__line { font: var(--fw-semibold) var(--fs-title-s)/1.35 var(--font-ui); color: var(--text-1); }
.food-day__line .delta { font-size: var(--fs-title-s); }
.food-day__sub { margin-top: var(--space-2); font-size: var(--fs-body-s); color: var(--text-2); font-variant-numeric: tabular-nums; }
.meal__empty { padding: var(--space-4) var(--space-5); border: 1.5px dashed var(--line-strong); border-radius: var(--radius-lg); font-size: var(--fs-body-s); color: var(--text-3); }
.food-row { width: 100%; text-align: left; }
.food-row .row__sub { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2) var(--space-3); }
.food-row .row__sub .icon { width: 14px; height: 14px; }
.food-row__cal .skel { width: 44px; height: 10px; }
.food-row__note { display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); }
.food-row__note.is-ai { color: var(--text-2); }
.food-row__thumb .icon { width: 22px; height: 22px; }
.food-row.is-pending .food-row__cal { color: var(--text-3); }
.food-closed { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-4); }
.food-closed > .icon { color: var(--status-done-text); }
.food-closed__t { font-size: var(--fs-body); color: var(--text-1); font-weight: var(--fw-medium); }
.food-dock .dock__inner > * + * { margin-top: var(--space-3); }
.food-dock .composer textarea.input { display: block; resize: none; max-height: 132px; overflow-y: auto; line-height: 1.35; }
.food-dock .chips-row { margin: 0 calc(-1 * var(--space-1)); }
.food-dock .chips-row:empty { display: none; }
.chips-row .micro { align-self: center; flex: none; white-space: nowrap; padding: 0 var(--space-1); }
.qchip .icon { width: 14px; height: 14px; }
.qchip { white-space: nowrap; flex: none; }

.est__head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-4); align-items: center; }
.est__photo { width: 76px; height: 76px; border-radius: var(--radius-md); object-fit: cover; background: var(--surface-2); }
.est__total { display: flex; align-items: baseline; gap: var(--space-2); }
.est__unit { font-size: var(--fs-title-s); color: var(--text-3); font-weight: var(--fw-medium); }
.est__note { margin-top: var(--space-2); }
.est__items { margin-top: var(--space-5); border-top: 1px solid var(--line); transition: opacity var(--dur-fast) linear; }
.est__items.is-busy { opacity: 0.45; pointer-events: none; }
.est-item { border-bottom: 1px solid var(--line); background: var(--raised); }
.est-item__body { padding: var(--space-4) 0; background: var(--raised); }
.est-item.swipe > :first-child { background: var(--raised); }
.est-item__main { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-3); align-items: center; }
.est-in {
  display: block; width: 100%; min-height: var(--tap); margin: 0 0 0 calc(-1 * var(--space-3)); padding: var(--space-2) var(--space-3);
  border: 1.5px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--text-1);
  font: var(--fw-semibold) max(16px, var(--fs-input))/1.3 var(--font-ui); -webkit-appearance: none; appearance: none;
  transition: border-color var(--dur-fast) linear, background-color var(--dur-fast) linear;
}
.est-in:focus { outline: none; border-color: var(--focus); background: var(--surface); box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 18%, transparent); }
.est-in::placeholder { color: var(--text-3); opacity: 1; }
.est-in--portion { min-height: 36px; font-weight: var(--fw-body); color: var(--text-2); }
.est-cal {
  min-width: 80px; min-height: var(--tap); padding: 0 var(--space-4); border-radius: var(--radius-pill);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text-1);
  font: var(--fw-semibold) var(--fs-body)/1 var(--font-ui); font-variant-numeric: tabular-nums;
}
.est-cal.is-low span { text-decoration: underline dotted; text-underline-offset: 3px; }
.est-item__check { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-1); font-size: var(--fs-body-s); color: var(--text-2); }
.est-item__check .icon { width: 14px; height: 14px; }
.est-item__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-3); }
.est-mult { display: flex; gap: var(--space-2); }
.est-mult .qchip { min-width: 46px; padding: 0 var(--space-3); }
.est__fix { margin-top: var(--space-6); }
.est__fixrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-3); align-items: end; margin-top: var(--space-2); }
.est__fixrow .input { min-height: var(--tap); resize: none; overflow: hidden; }
.est__section { margin-top: var(--space-6); }
.est__section > .field__label { display: block; margin-bottom: var(--space-2); }
.est-preview { display: block; width: 100%; max-height: 42vh; max-height: 42dvh; object-fit: cover; border-radius: var(--radius-md); background: var(--surface-2); }
.est__text { padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--surface-2); color: var(--text-1); font-size: var(--fs-body); overflow-wrap: anywhere; }


/* Food macros (docs/changes/food-macros.md 1.2 to 1.7): the Macros panel on the Food day, the macro
   bars, the calorie split, the row and sheet macro lines, the Macros keypad sheet, the trend screen.
   Ink and graphite only: protein at or past its target is the one verdict (--status-done). */
.macros { margin-top: var(--space-4); padding: var(--space-3) var(--space-5) var(--space-5); }
.macros.is-closed { padding-bottom: var(--space-4); }
.macros__head { display: flex; align-items: center; gap: var(--space-1); margin-right: calc(-1 * var(--space-3)); }
.macros__head .eyebrow { flex: 1 1 auto; min-width: 0; }
.macros__trend { padding: 0 var(--space-2); }
.macros__trend .icon { width: 16px; height: 16px; }
.macros__toggle .icon { transition: transform var(--dur-fast) var(--ease-out); }
.macros.is-closed .macros__toggle .icon { transform: rotate(180deg); }
.macros__sum { font-size: var(--fs-body-s); color: var(--text-2); font-variant-numeric: tabular-nums; }
.macros__sum-line { display: block; font: var(--fw-semibold) var(--fs-body)/1.35 var(--font-ui); color: var(--text-1); }
.macros__sum-miss { display: block; margin-top: 2px; color: var(--text-3); }
.mrow.is-none .mrow__val { font-weight: var(--fw-medium); color: var(--text-3); }
/* An empty day: no panel, just the way to the trend (right under the day card). */
.macros-link { display: flex; justify-content: flex-end; margin: var(--space-2) calc(-1 * var(--space-2)) 0 0; }
.macros-link .link { display: inline-flex; align-items: center; gap: var(--space-1); min-height: var(--tap); }
.macros__rows { display: grid; grid-template-columns: max-content max-content minmax(56px, 1fr); align-items: center; gap: var(--space-3) var(--space-4); margin-top: var(--space-2); }
.mrow { display: contents; }
.mrow__name { font-size: var(--fs-body); color: var(--text-2); }
.mrow__val { font: var(--fw-semibold) var(--fs-body)/1.3 var(--font-ui); color: var(--text-1); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mrow__val small { font-size: var(--fs-body-s); font-weight: var(--fw-medium); color: var(--text-2); }
.macros__note { margin-top: var(--space-2); font-size: var(--fs-body-s); color: var(--text-3); }
.macros__meals { margin-top: var(--space-4); }
.macros__meals summary {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--tap); cursor: pointer; list-style: none;
  color: var(--link); font: var(--fw-semibold) var(--fs-body-s)/1.3 var(--font-ui); text-decoration: underline; text-underline-offset: 3px;
}
.macros__meals summary::-webkit-details-marker { display: none; }
.macros__meals summary .icon { width: 16px; height: 16px; transition: transform var(--dur-fast) var(--ease-out); }
.macros__meals[open] summary .icon { transform: rotate(180deg); }
.macros__table { width: 100%; border-collapse: collapse; font-size: var(--fs-body-s); color: var(--text-2); font-variant-numeric: tabular-nums; }
.macros__table th, .macros__table td { padding: 7px 4px; text-align: right; border-top: 1px solid var(--line); vertical-align: top; }
.macros__table th:first-child { text-align: left; padding-left: 0; color: var(--text-1); font-weight: var(--fw-medium); }
.macros__table td:last-child { padding-right: 0; }
.macros__table thead th { border-top: 0; color: var(--text-3); font-weight: var(--fw-semibold); }
.macros__table abbr { text-decoration: none; }
.macros__table .is-day th, .macros__table .is-day td { border-top: 1.5px solid var(--line-strong); color: var(--text-1); font-weight: var(--fw-semibold); }
.macros__miss { display: block; margin-top: 2px; font-size: var(--fs-micro); font-weight: var(--fw-medium); color: var(--text-3); }
.macros__missing { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-3); margin-top: var(--space-4); padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--surface-2); }
.macros__missing p { display: flex; gap: var(--space-2); align-items: flex-start; font-size: var(--fs-body-s); color: var(--text-2); }
.macros__missing p .icon { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.macros__missing .btn { box-shadow: none; padding: 0 var(--space-4); white-space: nowrap; }
.macros__missing .btn[aria-busy="true"] { opacity: 0.7; }
.macros__pending { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-3); font-size: var(--fs-body-s); color: var(--text-3); }
.macros__pending .icon { width: 14px; height: 14px; }

.mbar { position: relative; height: 8px; border-radius: 4px; background: var(--surface-2); }
.mbar__fill { position: absolute; left: 0; top: 0; bottom: 0; width: var(--p); border-radius: 4px; background: var(--macro-fill); transition: width var(--dur-slower) var(--ease-out), background-color var(--dur-base) linear; }
.mbar.is-met .mbar__fill { background: var(--status-done); }
.mbar__tick { position: absolute; top: -3px; bottom: -3px; left: calc(var(--t) - 1px); width: 2px; border-radius: 1px; background: var(--text-1); }

.macro-split { margin-top: var(--space-5); }
.macro-split__label { font-size: var(--fs-body-s); font-weight: var(--fw-medium); color: var(--text-2); }
.macro-split__bar { display: flex; gap: 2px; height: 12px; margin-top: var(--space-3); border-radius: 6px; overflow: hidden; }
.macro-split__seg { flex: var(--w) 1 0; min-width: 3px; }
.macro-split__seg--protein, .macro-split__key--protein { background: var(--macro-protein); }
.macro-split__seg--carbs, .macro-split__key--carbs { background: var(--macro-carbs); }
.macro-split__seg--fat, .macro-split__key--fat { background: var(--macro-fat); box-shadow: inset 0 0 0 1px var(--line-strong); }
.macro-split__legend { display: flex; flex-wrap: wrap; align-items: center; margin-top: var(--space-3); font-size: var(--fs-body-s); color: var(--text-1); font-variant-numeric: tabular-nums; }
.macro-split__part { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.macro-split__key { flex: none; width: 10px; height: 10px; border-radius: 3px; }
.macro-split__dot { white-space: pre; color: var(--text-3); }

.food-row__macros { font-size: var(--fs-body-s); color: var(--text-3); font-variant-numeric: tabular-nums; }
.est__macros { margin-top: var(--space-2); font-size: var(--fs-body-s); color: var(--text-2); font-variant-numeric: tabular-nums; }
.est__macros .faint { color: var(--text-3); }
.est-item__macros {
  position: relative; display: inline-flex; align-items: center; gap: var(--space-2); min-height: 36px; margin-top: var(--space-2);
  padding: 0 var(--space-4); border-radius: var(--radius-pill); border: 1px solid var(--line); background: none;
  color: var(--text-2); font: var(--fw-medium) var(--fs-body-s)/1 var(--font-ui); font-variant-numeric: tabular-nums;
}
.est-item__macros::after { content: ""; position: absolute; inset: -4px -2px; }
.est-item__macros:active { background: var(--surface-2); }
.est-item__macros.is-unset { color: var(--text-1); font-weight: var(--fw-semibold); border-style: dashed; border-color: var(--line-strong); }
.est-item__macros .icon { width: 14px; height: 14px; }
.food-fail__macros { display: flex; justify-content: center; margin-top: var(--space-2); }

/* The Macros keypad sheet: four readout tiles in a 2 x 2 grid over one shared keypad. */
.mpad { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin-top: var(--space-2); }
.mpad__cell {
  display: grid; gap: 4px; justify-items: start; min-height: 64px; padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md); border: 1.5px solid var(--line); background: var(--surface-2); color: var(--text-1);
  font: inherit; text-align: left;
}
.mpad__cell[aria-pressed="true"] { border-color: var(--brand); background: var(--raised); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 14%, transparent); }
.mpad__label { font-size: var(--fs-body-s); font-weight: var(--fw-semibold); color: var(--text-2); }
.mpad__val { font: var(--fw-semibold) var(--fs-title-m)/1.1 var(--font-ui); font-variant-numeric: tabular-nums; color: var(--text-1); border-radius: 6px; padding: 0 3px; margin-left: -3px; }
.mpad__cell.is-selected .mpad__val { background: var(--brand-tint); }
.mpad__cell.is-over .mpad__val { color: var(--danger-text); }
.mpad__sum { margin: var(--space-3) 0 0; }
.mpad__note { margin-top: var(--space-1); text-align: center; font-size: var(--fs-body-s); color: var(--text-3); }
.sheet--macros .keypad { margin-top: var(--space-3); }
.sheet--macros .kp-key { height: 56px; }

/* The trend screen (/log/food/macros). */
.fm-range { margin: var(--space-5) 0 var(--space-3); }
.fm-body.is-busy { opacity: 0.55; transition: opacity var(--dur-fast) linear; }
.fm-avg .tile__value .num-m { font-size: 30px; }
.fm-avg__more { margin-top: var(--space-4); padding: var(--space-4) var(--space-5) var(--space-5); }
.fm-avg__more .macro-split { margin-top: var(--space-4); }
.fm-fiber { font-size: var(--fs-body); color: var(--text-2); }
.fm-fiber b { color: var(--text-1); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
.fm-charts { margin-top: var(--space-5); }
.fm-charts > * + * { margin-top: var(--space-4); }
.fm-day { justify-content: space-between; }
.fm-day .row__value { font: var(--fw-semibold) var(--fs-body)/1 var(--font-ui); color: var(--text-1); }
.fm-day .row__sub { font-variant-numeric: tabular-nums; }
/* A run of empty days at 30 days: one quiet line, not a link. */
.fm-gap .row__title { color: var(--text-2); font-weight: var(--fw-body); }
.fm-gap .row__sub { color: var(--text-3); }
.fm-fill { margin-top: 0; margin-bottom: var(--space-4); }
.chart__svg .col--macro { fill: var(--chart-col); }
/* Today and partial days: outlined in the column gray at 1.5px (the hairline --line-strong vanished in dark). */
.chart__svg .col--mopen { fill: none; stroke: var(--chart-col); stroke-width: 1.5; }
/* A day whose entries have no macros yet: a short dashed stub at the baseline. */
.chart__svg .col--nomacro { fill: none; stroke: var(--chart-col); stroke-width: 1.5; stroke-dasharray: 3 2; }
.chart__svg .pace--ink { stroke: var(--chart-line); stroke-dasharray: 5 4; }
.chart__svg .axis--halo { paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.key--col, .key--open, .key--nomacro { height: 10px; border: 0; border-radius: 3px; }
.key--col { background: var(--chart-col); }
.key--open { box-shadow: inset 0 0 0 1.5px var(--chart-col); }
.key--nomacro { border: 1.5px dashed var(--chart-col); }
.key--target { border-top: 1.5px dashed var(--chart-line); }
.wt-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-4); align-items: end; }
.wt-hero__label { font-size: var(--fs-body-s); color: var(--text-2); font-weight: var(--fw-medium); }
.wt-hero__num { display: flex; align-items: baseline; gap: var(--space-2); margin-top: var(--space-2); }
.wt-hero__num .num-xl { color: var(--text-1); }
.wt-hero__unit { font-size: var(--fs-title-s); color: var(--text-3); font-weight: var(--fw-medium); }
.wt-hero__change { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-2); font-size: var(--fs-body-s); color: var(--text-2); }
.wt-today { display: grid; justify-items: end; gap: 2px; min-height: var(--tap); padding: var(--space-2) var(--space-3); margin: 0 calc(-1 * var(--space-3)) 0 0; border: 0; border-radius: var(--radius-md); background: none; color: inherit; text-align: right; font: inherit; }
.wt-today:active { background: var(--surface-2); }
.wt-today__label { font-size: var(--fs-body-s); color: var(--text-2); }
.wt-today__val { font: var(--fw-semibold) var(--fs-title-m)/1.1 var(--font-ui); font-variant-numeric: tabular-nums; color: var(--text-1); }
.wt-status { margin-top: var(--space-4); font-size: var(--fs-body); color: var(--text-2); }
.wt-status a { color: var(--link); font-weight: var(--fw-semibold); }
.wt-fluct { display: flex; gap: var(--space-3); align-items: flex-start; margin-top: var(--space-4); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--surface-2); font-size: var(--fs-body-s); color: var(--text-2); }
.wt-fluct .icon { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.wt-range { margin: var(--space-6) 0 var(--space-3); }
.wt-chart.is-busy { opacity: 0.55; transition: opacity var(--dur-fast) linear; }
.wt-proj { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-4) var(--space-2) 0; font-size: var(--fs-body-s); color: var(--text-2); }
.wt-proj .icon { width: 16px; height: 16px; }
.wt-row { justify-content: space-between; }
.wt-row .row__value { display: inline-flex; align-items: baseline; gap: var(--space-3); }
.wt-row__v { font: var(--fw-semibold) var(--fs-body)/1 var(--font-ui); color: var(--text-1); font-variant-numeric: tabular-nums; }
.wt-row__d { min-width: 3.4em; text-align: right; color: var(--text-3); }

.jr-sec + .jr-sec { margin-top: var(--space-8); }
.jr-sec .voice-l { margin-bottom: var(--space-4); }
/* Joys are 1-line textareas that grow as they wrap (TECH_SPEC 23.15): the input's height and line
   height, and the number stays beside the first line. */
.jr-joy { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: var(--space-3); align-items: start; }
.jr-joy + .jr-joy { margin-top: var(--space-3); }
.jr-joy__n { padding-top: 16px; text-align: center; color: var(--text-3); font-family: var(--font-num); font-variation-settings: var(--num-variation); font-weight: var(--fw-num); font-size: 20px; line-height: 1; }
.jr-form .input--area { min-height: 76px; }
.jr-joy .input--area { min-height: 52px; line-height: 1.35; padding-block: 13px; }
.jr-hint { margin-top: var(--space-2); font-variant-numeric: tabular-nums; }
.jr-joy .jr-hint { grid-column: 2; margin-top: 0; }
.jr-reply { min-height: 1.45em; margin-top: var(--space-3); font-size: var(--fs-body-s); color: var(--text-2); }
.jr-more { margin-top: var(--space-7); }
.jr-more summary { display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--tap); cursor: pointer; list-style: none; color: var(--link); font-weight: var(--fw-semibold); text-decoration: underline; text-underline-offset: 3px; }
.jr-more summary::-webkit-details-marker { display: none; }
.jr-more[open] summary { margin-bottom: var(--space-2); }
.jr-parts { display: flex; flex-wrap: wrap; gap: var(--space-3); margin: 0 0 var(--space-5); }
.jr-read .joys li { align-items: start; }
.jr-well li .icon { color: var(--dom-people); }
/* The reading takeaway (TECH_SPEC 23.19): the Reader goal's indigo. */
.jr-take li .icon { color: var(--dom-work); }
.jr-past__read { flex: none; color: var(--dom-work); }
.jr-read__moment { font-size: var(--fs-body-l); line-height: 1.45; color: var(--text-1); }
.jr-read .tag { margin-top: var(--space-3); }
.jr-jar { margin: 0 0 var(--space-5); transition: opacity 400ms linear; }
.jr-jar.is-leaving { opacity: 0; }
.jr-jar__t { font-size: var(--fs-body); color: var(--text-1); line-height: 1.45; overflow-wrap: anywhere; }
.jr-jar__t .voice { color: var(--text-1); }
.jr-past .row__title { display: flex; align-items: center; gap: var(--space-3); }
/* A member's own journal prompts (docs/changes/appstore/wp-journal-prompts.md 10.3): the prompts sheet's
   rows (tap the words to edit in place; up, down, and remove beside them) and its "Write your own" field. */
.jp-row__actions { display: flex; gap: var(--space-1); flex: none; }
.jp-row { padding-right: var(--space-3); }
.jp-row__text { min-height: var(--tap); padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.jp-row--edit .input, .jp-add .input { flex: 1 1 auto; min-width: 0; }
.jp-add { display: flex; gap: var(--space-3); align-items: center; }

.book { width: 160px; display: grid; align-content: start; gap: var(--space-3); }
button.cover { font: inherit; text-align: left; cursor: pointer; }
.book__meta { font-size: var(--fs-body-s); color: var(--text-2); font-variant-numeric: tabular-nums; }
.book__meta b { color: var(--text-1); font-weight: var(--fw-semibold); }
.book .btn { width: 100%; }
.book .btn--primary { box-shadow: none; }
.book-add {
  width: 160px; aspect-ratio: 160 / 220; display: grid; place-items: center; align-content: center; gap: var(--space-3);
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius-md); background: none; color: var(--text-2);
  font: var(--fw-semibold) var(--fs-body)/1.2 var(--font-ui);
}
.book-add .icon { width: 28px; height: 28px; }
.done-book { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-4); align-items: start; width: 100%; padding: var(--space-4) var(--space-5); border: 0; background: none; color: inherit; font: inherit; text-align: left; }
.done-book:active { background: var(--surface-2); }
.done-book__t { font: var(--fw-semibold) var(--fs-title-s)/1.3 var(--font-ui); color: var(--text-1); overflow-wrap: anywhere; }
.done-book__by, .done-book__when { font-size: var(--fs-body-s); color: var(--text-2); }
.done-book__take { margin-top: var(--space-3); font-size: var(--fs-voice); }
.done-book__t, .done-book__by, .done-book__when, .done-book__take, .timer__book-t, .timer__book-a { display: block; }
.book .cover__title { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.done-book .cover--s, .timer__book .cover--s { padding: 0; }

.timer { min-height: calc(100vh - var(--screen-bottom)); min-height: calc(100dvh - var(--screen-bottom)); display: flex; flex-direction: column; }
.timer__body { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-6); padding: var(--space-5) 0 var(--space-6); text-align: center; }
.timer__book { display: flex; align-items: center; gap: var(--space-4); max-width: 100%; padding: var(--space-2) var(--space-3); border: 0; border-radius: var(--radius-md); background: none; color: inherit; font: inherit; text-align: left; }
.timer__book:active { background: var(--surface-2); }
.timer__book-t { font: var(--fw-bold) var(--fs-title-s)/1.25 var(--font-ui); color: var(--text-1); overflow-wrap: anywhere; }
.timer__book-a { font-size: var(--fs-body-s); color: var(--text-2); }
.timer__status { min-height: 1.4em; font: var(--fw-semibold) var(--fs-title-s)/1.4 var(--font-ui); color: var(--text-2); }
.timer__status.is-done { color: var(--status-done-text); }
.timer__sub { min-height: 1.4em; font-size: var(--fs-body-s); color: var(--text-2); }
.timer .ring--timer { max-width: 100%; }
.timer .dock__inner .btn .icon { width: 18px; height: 18px; }

/* ------------------------------------------------------------------ */
/* 18. Empty states, skeletons, gestures, tab bar, utilities            */
/* ------------------------------------------------------------------ */
.empty { display: grid; justify-items: center; gap: var(--space-4); text-align: center; padding: var(--space-8) var(--space-4); }
.empty__art { width: min(100%, 300px); aspect-ratio: 3 / 2; height: auto; display: block; margin: 0 auto; }
.empty__title { max-width: 30ch; }
.empty__body { max-width: 34ch; color: var(--text-2); }
.empty .btn { min-width: 200px; }

.skel-card { display: grid; gap: var(--space-3); }
.skel { display: block; height: 12px; width: var(--w, 80%); border-radius: 6px; background: var(--surface-3); animation: skel 1.4s var(--ease-in-out) infinite; }
@keyframes skel { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* Swipe-to-delete rows (dom.js swipeToDelete) */
.swipe { position: relative; overflow: hidden; }
.swipe > :first-child { position: relative; z-index: 1; background: var(--surface); touch-action: pan-y; }
.swipe__action {
  position: absolute; right: 0; top: 0; bottom: 0; width: 96px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; background: var(--surface-2); color: var(--danger-text); font: var(--fw-semibold) 12px/1 var(--font-ui);
}

/* Pull to refresh (Today) */
.ptr { height: calc(var(--pull, 0) * 48px); display: grid; place-items: center; overflow: hidden; transition: height var(--dur-fast) var(--ease-out); }
.ptr.is-pulling { transition: none; }
.ptr .spinner { opacity: var(--pull, 0); animation-play-state: paused; }
.ptr.is-refreshing { height: 48px; }
.ptr.is-refreshing .spinner { opacity: 1; animation-play-state: running; }

/* Tab bar (DESIGN_SYSTEM 7.7) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-tabbar);
  padding: 0 max(var(--space-3), var(--safe-right)) var(--safe-bottom) max(var(--space-3), var(--safe-left));
  background: var(--tabbar-bg); -webkit-backdrop-filter: saturate(1.6) blur(20px); backdrop-filter: saturate(1.6) blur(20px);
  border-top: 1px solid var(--line);
  transition: transform var(--dur-base) var(--ease-out);
}
:root[data-chrome="bare"] .tabbar { display: none; }
:root.kb-open .tabbar { transform: translateY(110%); }
.tabbar__inner { max-width: var(--content-max); margin: 0 auto; height: var(--tabbar-h); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center; }
.tab {
  position: relative; display: grid; justify-items: center; align-content: center; gap: 3px; height: 100%;
  background: none; border: 0; color: var(--text-3); text-decoration: none;
  font: var(--fw-semibold) 10.5px/1 var(--font-ui); letter-spacing: 0.01em;
}
.tab[aria-current="page"] { color: var(--text-1); }
.tab[aria-current="page"] .icon { --icon-fill: var(--brand-tint); fill: none; }
.tab:focus-visible { outline: 2px solid var(--focus); outline-offset: -4px; border-radius: 12px; }
.tab__badge { position: absolute; top: 10px; left: calc(50% + 7px); width: 8px; height: 8px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 2px var(--tabbar-bg); }
.tab--log { align-content: end; padding-bottom: 7px; gap: 4px; }
.tab__plus {
  width: 50px; height: 50px; margin-top: -22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand); color: var(--on-brand); box-shadow: var(--shadow-brand), 0 0 0 5px var(--bg);
  transition: transform var(--dur-fast) var(--ease-out);
}
.tab__plus .icon { width: 26px; height: 26px; stroke-width: 2.25px; }
.tab--log:active .tab__plus { transform: scale(0.94); }
.tab--log:focus-visible { outline: none; }
.tab--log:focus-visible .tab__plus { box-shadow: 0 0 0 2px var(--focus-gap), 0 0 0 4px var(--focus); }
.tab--wiggle .icon { animation: wiggle 300ms var(--ease-in-out) both; }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-10deg); } 75% { transform: rotate(10deg); } }

/* The 18+ attestation (wp-accounts 5.12): a real checkbox, a 44px tap target. */
.attest { display: flex; align-items: center; gap: var(--space-3); min-height: var(--tap); font-size: var(--fs-body); color: var(--text-1); cursor: pointer; }
.attest__box { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--brand); }
.field.has-error .attest__box { outline: 2px solid var(--danger); outline-offset: 2px; }

/* A recovery code: 6 groups of 4 in a 3-column grid, so it never wraps mid-group at 390px. */
.recovery-code { display: grid; grid-template-columns: repeat(3, auto); justify-content: center; gap: var(--space-2) var(--space-4);
  margin-top: var(--space-4); padding: var(--space-5) var(--space-4); background: var(--surface-2); border-radius: var(--radius-md);
  font: 600 var(--fs-title-l)/1.2 ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.08em;
  color: var(--text-1); -webkit-user-select: all; user-select: all; }
.recovery-code__g { white-space: nowrap; }

/* Utilities */
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.clamp-1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pre-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.hide-kb { transition: opacity var(--dur-fast) linear; }
:root.kb-open .hide-kb { display: none; }
