/* UI primitives shared by every page. No framework, no build.
 *
 * Two shells only:
 *   .screen — funnel step: fixed viewport, scrolling body, one action panel at the
 *             bottom. Used by the quiz, /plan, /pay, success, fail, login.
 *   .page   — document flow: header + stacked cards. Used by /account and legal.
 */

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  min-height: 100dvh;
  font-family: var(--font);
  font-size: var(--fs-body);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}
svg { display: block; }
a { color: var(--green-deep); text-decoration: none; }
b, strong { font-weight: 800; }
[hidden] { display: none !important; }
.hidden { display: none !important; }

/* ── shell: funnel step ────────────────────────────────────────────────────── */
.screen { display: flex; flex-direction: column; min-height: 100dvh; }
.screen > .body {
  flex: 1 1 auto;
  display: flex; flex-direction: column;
  width: 100%;
  max-width: var(--w-app);
  margin: 0 auto;
  padding: var(--s5) var(--s5) var(--s6);
}
/* Elastic gap: pushes the answer group toward the thumb on tall screens and
   collapses to nothing on a 375×667 viewport. */
.fill { flex: 1 1 auto; min-height: var(--s4); }
/* Quiz steps centre their content instead: a 390×844 screen is much taller than
   one question with four answers, and a void looks intentional only when it is
   split evenly above and below. */
.screen > .body.center { justify-content: center; }
.screen > .bottom {
  flex: none;
  position: sticky;
  bottom: 0;
  background: var(--panel);
  box-shadow: var(--shadow-panel);
  border-radius: var(--r-card) var(--r-card) 0 0;
  padding: var(--s4) var(--s5) calc(var(--s5) + var(--sheet));
}
.screen > .bottom > .inner { width: 100%; max-width: var(--w-app); margin: 0 auto; }
/* Flat variant: no panel chrome, for screens where the action sits in the flow. */
.screen > .bottom.plain { background: none; box-shadow: none; }

/* ── shell: document ──────────────────────────────────────────────────────── */
.page { width: 100%; max-width: var(--w-app); margin: 0 auto; padding: var(--s5) var(--s4) var(--s8); }

/* ── top bar: back + progress ─────────────────────────────────────────────── */
.topbar {
  flex: none; display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4) 0;
  width: 100%; max-width: var(--w-app); margin: 0 auto;
}
.iconbtn {
  flex: none; width: var(--tap); height: var(--tap); margin-left: calc(var(--s3) * -1);
  border: 0; background: none; color: var(--ink-soft);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.iconbtn svg { width: 24px; height: 24px; }
.iconbtn:active { transform: scale(.92); }
.iconbtn[disabled] { opacity: 0; pointer-events: none; }

.progress { flex: 1; height: 3px; border-radius: var(--r-pill); background: var(--hair); overflow: hidden; }
.progress > i {
  display: block; height: 100%; border-radius: var(--r-pill); background: var(--green);
  transition: width .35s cubic-bezier(.2, .7, .2, 1);
}

/* ── type ─────────────────────────────────────────────────────────────────── */
h1, .h1 {
  font-size: var(--fs-display); font-weight: 800; letter-spacing: -.03em; line-height: 1.12;
}
h2, .h2 { font-size: var(--fs-title); font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
h3, .h3 { font-size: var(--fs-body); font-weight: 800; letter-spacing: -.01em; }
.hint { margin-top: var(--s3); font-size: var(--fs-meta); font-weight: 600; color: var(--muted); line-height: 1.5; }
.copy { font-size: var(--fs-body); font-weight: 600; color: var(--ink-soft); line-height: 1.55; }
.copy + .copy { margin-top: var(--s3); }
.copy b { color: var(--ink); }
.note { font-size: var(--fs-micro); font-weight: 500; color: var(--muted); line-height: 1.5; }
.num { font-variant-numeric: tabular-nums; }
.accent { color: var(--green-deep); }

/* ── head block of a funnel step ──────────────────────────────────────────── */
.head { margin: var(--s4) 0 var(--s6); }
.head .hint { margin-top: var(--s2); }

/* ── card ─────────────────────────────────────────────────────────────────── */
.card { background: var(--card); border-radius: var(--r-card); padding: var(--s5); box-shadow: var(--shadow); }
.card + .card { margin-top: var(--s3); }
.card.flat { box-shadow: none; border: 1px solid var(--hair); }

/* ── section label ────────────────────────────────────────────────────────── */
.sect {
  display: flex; align-items: center; gap: 7px;
  margin: var(--s6) var(--s1) var(--s3);
  font-size: var(--fs-micro); font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em;
}
.sect svg { width: 14px; height: 14px; }

/* ── options ──────────────────────────────────────────────────────────────── */
.opts { display: flex; flex-direction: column; gap: 10px; }
.opts.two { flex-direction: row; flex-wrap: wrap; }
.opts.two > .opt { flex: 1 1 calc(50% - 5px); position: relative; justify-content: center; text-align: center; }
/* In two-column mode the tick leaves the flow: a 168 px cell cannot afford 32 px
   of reserved gutter, and the label must not jump sideways when it is chosen. */
.opts.two > .opt > .tick { position: absolute; top: 7px; right: 7px; width: 16px; height: 16px; }
.opts.two > .opt > .lab { flex: 0 1 auto; }

.opt {
  display: flex; align-items: center; gap: var(--s3);
  min-height: 58px; padding: 13px var(--s4);
  background: var(--card); border: 1.5px solid var(--hair); border-radius: var(--r-row);
  cursor: pointer; transition: border-color .15s ease, background .15s ease, transform .12s ease;
}
.opt:active { transform: scale(.99); }
.opt.sel { border-color: var(--green); background: var(--green-wash); }
.opt .tick { flex: none; width: 20px; height: 20px; opacity: 0; transition: opacity .15s ease; }
.opt.sel .tick { opacity: 1; }
.opt .lab { flex: 1; min-width: 0; }
.opt .lab > b { display: block; font-size: var(--fs-body); font-weight: 700; letter-spacing: -.01em; }
.opt .lab > span { display: block; margin-top: 2px; font-size: var(--fs-meta); font-weight: 600; color: var(--muted); }
.opt .trail { flex: none; font-size: var(--fs-meta); font-weight: 700; color: var(--muted); }
.opt.sel .trail { color: var(--green-deep); }

/* ── stepper: value + coarse slider + fine buttons ────────────────────────── */
.stepper { text-align: center; }
.stepper .val {
  display: flex; align-items: baseline; justify-content: center; gap: 6px;
  padding: var(--s4) 0 var(--s2); cursor: text;
}
.stepper .val b { font-size: 56px; font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.stepper .val span { font-size: var(--fs-title); font-weight: 800; color: var(--muted); }
.stepper .val input {
  width: 4.2ch; font: inherit; font-size: 56px; font-weight: 800; letter-spacing: -.04em;
  text-align: right; border: 0; background: none; color: var(--ink);
  -moz-appearance: textfield;
}
.stepper .val input::-webkit-outer-spin-button,
.stepper .val input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper .rail { display: flex; align-items: center; gap: var(--s4); margin-top: var(--s5); }
.stepper .rail button {
  flex: none; width: var(--tap); height: var(--tap); border: 0; border-radius: 50%;
  background: var(--field); color: var(--ink); display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform .1s ease;
}
.stepper .rail button svg { width: 22px; height: 22px; }
.stepper .rail button:active { transform: scale(.9); }

input[type=range] {
  flex: 1; height: var(--tap); background: none; -webkit-appearance: none; appearance: none; cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: var(--r-pill); background: var(--field);
}
input[type=range]::-moz-range-track { height: 4px; border-radius: var(--r-pill); background: var(--field); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 26px; height: 26px; margin-top: -11px;
  border-radius: 50%; background: var(--card); border: 1px solid var(--hair); box-shadow: var(--shadow);
}
input[type=range]::-moz-range-thumb {
  width: 26px; height: 26px; border-radius: 50%; background: var(--card);
  border: 1px solid var(--hair); box-shadow: var(--shadow);
}
.stepper .scale {
  display: flex; justify-content: space-between; margin: var(--s2) 60px 0;
  font-size: var(--fs-micro); font-weight: 600; color: var(--muted);
}

/* ── field ────────────────────────────────────────────────────────────────── */
.field label { display: block; margin: 0 var(--s1) 7px; font-size: var(--fs-meta); font-weight: 700; }
.field input {
  width: 100%; height: 54px; padding: 0 var(--s4);
  font: inherit; font-size: var(--fs-body); font-weight: 600; color: var(--ink);
  background: var(--field); border: 1.5px solid transparent; border-radius: var(--r-btn);
  transition: border-color .15s ease, background .15s ease;
}
.field input::placeholder { color: var(--muted); font-weight: 600; }
.field input:focus { outline: none; border-color: var(--ring); background: var(--card); }
.field input:disabled { color: var(--muted); }
.field .help { margin: 7px var(--s1) 0; font-size: var(--fs-micro); font-weight: 500; color: var(--muted); }
.field.err input { border-color: var(--over); background: var(--danger-wash); }
.field.err .help { color: var(--over); }

/* OTP: six characters, one box, wide tracking — cheaper than six inputs and it
   never fights the mobile keyboard or autofill. */
.otp input {
  text-align: center; font-size: var(--fs-title); font-weight: 800;
  letter-spacing: .48em; text-indent: .48em; font-variant-numeric: tabular-nums;
}

/* ── buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: flex; align-items: center; justify-content: center; gap: var(--s2);
  width: 100%; min-height: 54px; padding: var(--s3) var(--s4);
  border: 0; border-radius: var(--r-btn); cursor: pointer;
  font-family: inherit; font-size: 16px; font-weight: 800; letter-spacing: -.01em;
  transition: transform .12s ease, opacity .15s ease;
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: scale(.99); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn.primary { background: var(--green); color: #fff; box-shadow: var(--shadow-btn); }
.btn.ghost { background: var(--field); color: var(--ink-soft); }
.btn.quiet { background: none; color: var(--ink-soft); min-height: var(--tap); font-size: var(--fs-body); font-weight: 700; }
.btn.danger { background: var(--danger-wash); color: var(--over); }
.btn + .btn { margin-top: var(--s2); }
.btn .spin { width: 20px; height: 20px; border-width: 2.5px; border-color: rgba(255,255,255,.4); border-top-color: #fff; }

/* ── consent (bank pattern, pre-checked, quiet) ───────────────────────────── */
.legal { display: flex; flex-direction: column; gap: var(--s2); }
.consent { display: flex; gap: 10px; align-items: flex-start; text-align: left; cursor: pointer; }
.consent .box { flex: none; margin-top: 1px; }
.consent .box .ring { stroke: var(--ring); }
.consent .box .tick { stroke: var(--consent); transition: opacity .15s ease; }
.consent.off .box .tick { opacity: 0; }
.consent p { font-size: var(--fs-micro); line-height: 1.5; font-weight: 500; color: var(--consent); }
.consent a { color: #8A8C82; text-decoration: underline; text-decoration-color: var(--ring); }

/* ── trust / offer line ───────────────────────────────────────────────────── */
.trust {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: var(--fs-micro); font-weight: 600; letter-spacing: .01em; color: #B6B8AF;
}
.trust svg { flex: none; width: 12px; height: 12px; color: #C3C5BC; }

/* The renewal terms. §7.4: large, above the button, never in a footer. */
.terms-line {
  font-size: var(--fs-meta); font-weight: 700; line-height: 1.5; text-align: center;
  color: var(--ink); padding: 0 var(--s2) var(--s3);
}
.terms-line .soft { color: var(--ink-soft); font-weight: 600; }

/* ── key/value rows ───────────────────────────────────────────────────────── */
.kv { display: flex; flex-direction: column; }
.kv > div { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s4); padding: var(--s3) 0; }
.kv > div + div { border-top: 1px solid var(--hair); }
.kv dt, .kv .k { font-size: var(--fs-meta); font-weight: 600; color: var(--muted); }
.kv dd, .kv .v { font-size: var(--fs-body); font-weight: 700; letter-spacing: -.01em; text-align: right; }

/* ── pills / badges ───────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 3px var(--s2); border-radius: var(--r-pill);
  font-size: 10px; font-weight: 800; letter-spacing: .01em; color: #fff; background: var(--green-deep);
}
.badge.hot { background: var(--gold); color: #5B4300; }
.badge.grey { background: var(--field); color: var(--muted); }
.status {
  display: inline-flex; align-items: center; gap: 6px; flex: none; white-space: nowrap;
  font-size: var(--fs-meta); font-weight: 700;
}
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.status.warn .dot { background: var(--under); }
.status.bad .dot { background: var(--over); }
.status.off .dot { background: var(--chev); }

/* ── notice banner ────────────────────────────────────────────────────────── */
.banner {
  display: flex; gap: var(--s3); align-items: flex-start;
  padding: var(--s3) var(--s4); border-radius: var(--r-row);
  background: var(--field); font-size: var(--fs-meta); font-weight: 600; line-height: 1.5; color: var(--ink-soft);
}
.banner svg { flex: none; width: 16px; height: 16px; margin-top: 1px; color: var(--muted); }
.banner b { color: var(--ink); }
.banner.warn { background: #FDF6E6; color: #6B5518; }
.banner.warn svg { color: var(--gold); }
.banner.bad { background: var(--danger-wash); color: #7A3524; }
.banner.bad svg { color: var(--over); }

/* ── calorie ring + macro bars (identical geometry to the diary) ───────────── */
.hero-ring { display: flex; align-items: center; gap: var(--s4); }
.ring { position: relative; width: 124px; height: 124px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring .center b { font-size: 31px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.ring .center span {
  margin-top: 5px; font-size: 10.5px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.macros { flex: 1; display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.macro .top { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; margin-bottom: 6px; }
.macro .top b { font-weight: 700; letter-spacing: -.01em; }
.macro .top span { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.bar { height: 4px; border-radius: var(--r-pill); background: var(--field); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: var(--r-pill); transition: width .6s cubic-bezier(.2,.7,.2,1); }

/* three macro columns split by hairlines */
.mac3 { display: flex; }
.mac3 .m { flex: 1; text-align: center; padding: 2px var(--s1); }
.mac3 .m + .m { border-left: 1px solid var(--hair); }
.mac3 .m b { font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.mac3 .m b small { font-size: 12px; font-weight: 700; color: var(--muted); margin-left: 2px; }
.mac3 .m > span { display: block; margin-top: 5px; font-size: var(--fs-micro); font-weight: 600; color: var(--muted); }
.mac3 .m .tickline { width: 18px; height: 3px; border-radius: 2px; margin: 8px auto 0; }

/* ── numbered how-it-works list (not three feature cards — §8.2) ──────────── */
.steps { display: flex; flex-direction: column; }
.steps > li { display: flex; gap: var(--s3); padding: var(--s3) 0; list-style: none; }
.steps > li + li { border-top: 1px solid var(--hair); }
.steps .n {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--green-wash); color: var(--green-deep);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-meta); font-weight: 800;
}
.steps .t { flex: 1; }
.steps .t b { display: block; font-size: var(--fs-body); font-weight: 700; letter-spacing: -.01em; }
.steps .t span { display: block; margin-top: 3px; font-size: var(--fs-meta); font-weight: 600; color: var(--muted); line-height: 1.5; }

/* ── checklist for the "assembling your plan" screen ──────────────────────── */
.checks { display: flex; flex-direction: column; gap: var(--s3); }
.checks > li { display: flex; align-items: flex-start; gap: 10px; list-style: none; font-size: var(--fs-body); font-weight: 600; color: var(--muted); line-height: 1.4; transition: color .25s ease; }
.checks > li .mark { flex: none; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; }
.checks > li .mark i { width: 6px; height: 6px; border-radius: 50%; background: var(--chev); }
.checks > li.work { color: var(--ink); }
.checks > li.work .mark i { display: none; }
.checks > li.done { color: var(--ink); }
.checks > li.done .mark i { display: none; }
.checks > li .spin { width: 16px; height: 16px; border-width: 2px; }
.checks > li .ok { color: var(--green); }
.checks > li .ok svg { width: 18px; height: 18px; }

/* ── success mark ─────────────────────────────────────────────────────────── */
.mark-ok {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto var(--s5);
  background: var(--green); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 24px -8px rgba(46, 158, 79, .4);
}
.mark-ok svg { width: 30px; height: 30px; color: #fff; }
.mark-soft {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto var(--s5);
  background: var(--field); color: var(--muted); display: flex; align-items: center; justify-content: center;
}
.mark-soft svg { width: 28px; height: 28px; }
.mark-soft.bad { background: var(--danger-wash); color: var(--over); }

/* ── spinner ──────────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin {
  width: 26px; height: 26px; border: 3px solid var(--hair); border-top-color: var(--green);
  border-radius: 50%; animation: spin .8s linear infinite;
}

/* ── bottom sheet (confirm) ───────────────────────────────────────────────── */
.scrim {
  position: fixed; inset: 0; z-index: 40; background: rgba(20, 22, 18, .32);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease both;
}
.scrim > .sheet {
  width: 100%; max-width: var(--w-app);
  background: var(--panel); border-radius: var(--r-card) var(--r-card) 0 0;
  padding: var(--s6) var(--s5) calc(var(--s5) + var(--sheet));
  animation: up .28s cubic-bezier(.22, .61, .36, 1) both;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes up { from { transform: translateY(24px) } to { transform: none } }

/* ── motion ───────────────────────────────────────────────────────────────── */
@keyframes stepin { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }
.stepin { animation: stepin .26s cubic-bezier(.22, .61, .36, 1) both; }
@keyframes shake { 0%,100% { transform: translateX(0) } 25% { transform: translateX(-9px) } 75% { transform: translateX(9px) } }
.shake { animation: shake .4s ease-in-out; }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── legal document typography ────────────────────────────────────────────── */
.doc h1 { margin-bottom: var(--s5); }
.doc h2 { margin: var(--s7) 0 var(--s3); font-size: var(--fs-body); }
.doc p, .doc li { font-size: 13.5px; font-weight: 500; line-height: 1.62; color: var(--ink-soft); }
.doc p + p { margin-top: var(--s3); }
.doc ul, .doc ol { margin: var(--s3) 0 0 var(--s5); display: flex; flex-direction: column; gap: 6px; }
.doc .updated { margin-top: var(--s2); font-size: var(--fs-micro); font-weight: 600; color: var(--muted); }
/* Everything the lawyer/owner must fill in is marked, never silently invented. */
.doc .todo, .todo {
  background: #FDF6E6; color: #6B5518; border-radius: 4px; padding: 0 4px;
  font-weight: 700; box-shadow: inset 0 0 0 1px rgba(232, 181, 58, .45);
}

/* ── photo slot: swap the file, never the CSS ──────────────────────────────── */
.photo { display: block; width: 100%; height: auto; background: var(--field); }
.photo.square { aspect-ratio: 1 / 1; object-fit: cover; }
