/* Onboarding wizard (js/onboarding.js) + sign-in screens. Everything is scoped to #onboarding-screen,
   #auth-screen, #reset-password-screen and #loading-screen, so the .ob-label / .ob-tooltip classes
   that Profile and the Today plan card reuse keep their app.css look. */

/* The 96 px bottom padding is for the app's bottom nav — none of these screens has one. */
body:has(> #onboarding-screen[style*="block"]), body:has(> #auth-screen[style*="flex"]), body:has(> #reset-password-screen[style*="flex"]) { padding-bottom: env(safe-area-inset-bottom, 0px); }

/* ---------- loading ---------- */
.boot-spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--accent-light); border-top-color: var(--accent); animation: boot-spin 900ms linear infinite; }
@keyframes boot-spin { to { transform: rotate(360deg); } }
.boot-text { color: var(--text-secondary); font-size: 14px; }
@media (prefers-reduced-motion: reduce) { .boot-spinner { animation: none; border-top-color: var(--accent-2); } }
html[data-motion="reduced"] .boot-spinner, html[data-motion="off"] .boot-spinner { animation: none; }

/* ---------- auth ---------- */
#auth-screen a, #reset-password-screen a { color: var(--accent-strong); font-weight: 700; text-underline-offset: 2px; }
#auth-screen a:focus-visible, #reset-password-screen a:focus-visible { outline: 3px solid var(--accent-strong); outline-offset: 2px; border-radius: 4px; }
/* The brand mark (a leaf glyph in a mint tile — the same mark as the top bar, not the mascot). */
.auth-form-logo .auth-sprout { width: 48px; height: 48px; margin: 0 auto; border-radius: 15px; box-shadow: 0 0 0 1px var(--line), var(--shadow-1); }
.auth-form-logo .auth-sprout svg { width: 26px; height: 26px; }
.auth-form-logo h1 { margin: 8px 0 2px; font-family: var(--font-display, inherit); font-size: 22px; letter-spacing: 0.1em; color: var(--accent-strong); }
.auth-form-logo .note { margin-bottom: 0; }
.auth-card { padding: 16px 16px 12px; }
.auth-card h2 { margin: 0 0 12px; font-size: 20px; }
.auth-field { margin: 0 0 10px; }
.auth-label { display: block; font-size: 13.5px; font-weight: 700; color: var(--text-primary); margin: 0 0 4px; }
.auth-field input { width: 100%; margin: 0; }
.auth-help { margin: 4px 0 0; font-size: 12.5px; color: var(--text-secondary); }
.pw-field { position: relative; }
.pw-field input { padding-right: 76px; }
.pw-toggle { position: absolute; top: 50%; right: 4px; transform: translateY(-50%); min-height: 36px; min-width: 64px; margin: 0; padding: 0 10px; border-radius: 10px;
  background: transparent; color: var(--accent-strong); font-size: 13.5px; font-weight: 800; box-shadow: none; }
.pw-toggle:hover { background: var(--accent-light); transform: translateY(-50%); }
.pw-toggle:focus-visible { outline: 3px solid var(--accent-strong); outline-offset: 0; }
@media (pointer: coarse) { .pw-toggle { min-height: 44px; } .pw-field input { padding-right: 80px; } }
.auth-submit { width: 100%; min-height: 48px; margin-top: 4px; }
.auth-links { text-align: center; margin-top: 8px; font-size: 14px; }
.auth-links a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 6px; }
.auth-privacy { margin: 10px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--text-secondary); text-align: center; }
.auth-msg { margin: 8px 0 0; font-size: 13.5px; line-height: 1.45; font-weight: 600; }
.auth-msg.auth-error { color: #A4231B; }
.auth-msg.auth-ok { color: #1A6B3E; }
.auth-switch { text-align: center; margin-top: 12px; padding-top: 6px; font-size: 14px; color: var(--text-secondary); border-top: 1px solid var(--line); }
.auth-switch a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; }
/* The screens fill the view without a stray scroll: body already has 16 px of top padding. */
#auth-screen, #reset-password-screen, #loading-screen { min-height: calc(100dvh - 16px - env(safe-area-inset-top, 0px)) !important; }
#auth-screen .auth-form-panel, #auth-screen .auth-illustration { min-height: 0; }

/* ---------- onboarding: frame ---------- */
#onboarding-screen { padding: 8px 0 0; }
.ob-wrap { max-width: 560px; margin: 0 auto; }
.ob-top { margin-bottom: 12px; }
#onboarding-screen .ob-progress-row { display: flex; align-items: center; justify-content: space-between; gap: 4px 8px; flex-wrap: wrap; margin-bottom: 6px; }
#onboarding-screen .ob-progress-label { font-size: 13.5px; font-weight: 700; color: var(--text-secondary); }
#onboarding-screen .ob-progress-label #ob-step-name { color: var(--text-primary); }
/* Phones: the step name repeats the heading right below — it stays for screen readers only, so
   the counter and Skip / Log out share one line. */
@media (max-width: 480px) {
  #onboarding-screen .ob-progress-label:has(#ob-step-label:not([hidden])) #ob-step-sep,
  #onboarding-screen .ob-progress-label:has(#ob-step-label:not([hidden])) #ob-step-name { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
.ob-top-actions { display: flex; gap: 2px; margin-left: auto; }
#onboarding-screen .ob-top-actions .ghost-btn { font-size: 14px; font-weight: 700; min-height: 44px; padding: 0 10px; color: var(--accent-strong); border-radius: 10px; }
#onboarding-screen .ob-progress-track { margin-bottom: 0; height: 6px; }
.ob-edit-title { font-size: 22px; margin: 0 0 8px; }
.ob-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 4px; }
.ob-tab { margin: 0; min-height: 40px; padding: 4px 12px; border-radius: var(--radius-pill); border: 0;
  background: var(--surface); color: var(--text-primary); font-size: 13.5px; font-weight: 700; box-shadow: inset 0 0 0 1px var(--line-strong); }
.ob-tab:hover { background: var(--accent-light); color: var(--text-primary); }
.ob-tab[aria-current="step"] { background: var(--accent); color: var(--text-on-accent); box-shadow: none; }
.ob-tab:focus-visible { outline: 3px solid var(--accent-strong); outline-offset: 2px; }
@media (pointer: coarse) { .ob-tab { min-height: 44px; } }

/* ---------- onboarding: steps ---------- */
#onboarding-screen .ob-heading { font-size: 22px; line-height: 1.25; margin: 0 0 4px; }
#onboarding-screen .ob-heading:focus { outline: none; }
#onboarding-screen .ob-heading:focus-visible { outline: 3px solid var(--accent-strong); outline-offset: 4px; border-radius: 6px; }
.ob-help { font-size: 14px; line-height: 1.45; color: var(--text-secondary); margin: 0 0 8px; }
.ob-help-tight { margin: -2px 0 6px; font-size: 13px; }
.ob-help-under { margin: 4px 0 0; font-size: 12.5px; }
#onboarding-screen .ob-label { display: block; margin: 16px 0 6px; font-size: 14px; font-weight: 700; color: var(--text-primary); }
#onboarding-screen .ob-row .ob-label { margin-top: 8px; }
.ob-unit { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.ob-row { display: grid; gap: 10px; }
.ob-row3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ob-row2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ob-field { min-width: 0; }
#onboarding-screen .ob-field input, #onboarding-screen .ob-field select, #onboarding-screen .ob-step > input { width: 100%; min-width: 0; }
.ob-field-error { margin: 4px 0 0; font-size: 12.5px; line-height: 1.35; font-weight: 600; color: #A4231B; }
#onboarding-screen input[aria-invalid="true"] { border-color: #B3261E; box-shadow: 0 0 0 1px #B3261E; }
#onboarding-screen .ob-chip-group[aria-invalid="true"], #onboarding-screen .ob-choice-grid[aria-invalid="true"] { outline: 2px solid #b3261e; outline-offset: 4px; border-radius: 14px; }

#onboarding-screen .ob-bmi-preview { margin-top: 10px; padding: 6px 12px; border-radius: var(--radius-md); font-size: 13.5px; line-height: 1.5; }
#onboarding-screen .ob-bmi-preview b { font-size: 15px; }
.ob-inline-btn { font-size: 13.5px; padding: 0 4px; }
.ob-bmi-more { display: block; font-size: 12.5px; color: var(--text-secondary); margin: 2px 0 4px; }
.ob-inline-note { margin: 8px 0 0; padding: 8px 10px; border-radius: 12px; background: var(--peach-light); color: var(--text-primary); font-size: 13.5px; line-height: 1.45; }

#onboarding-screen .ob-chip { margin: 0; min-height: 44px; padding: 7px 14px; font-size: 14px; }
#onboarding-screen .ob-chip:focus-visible, #onboarding-screen .ob-choice-card:focus-visible { outline: 3px solid var(--accent-strong); outline-offset: 2px; }
.ob-chip-list { flex-direction: column; flex-wrap: nowrap; gap: 6px; }
#onboarding-screen .ob-chip-list .ob-chip { width: 100%; text-align: left; border-radius: 14px; font-weight: 500; }
.ob-chip-list .ob-chip b { font-weight: 800; }
#onboarding-screen .ob-chip-num { min-width: 48px; padding: 7px 10px; }
#onboarding-screen .ob-choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
#onboarding-screen .ob-choice-card { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 56px; margin: 0; padding: 8px 12px; text-align: left;
  font-size: 14.5px; font-weight: 700; line-height: 1.25; background: var(--surface); color: var(--text-primary); border: 0; border-radius: 16px; box-shadow: inset 0 0 0 1px var(--line-strong), var(--shadow-1); }
#onboarding-screen .ob-choice-card:hover { background: var(--accent-light); color: var(--text-primary); }
#onboarding-screen .ob-choice-card.active { background: var(--accent-light); color: var(--accent-strong); box-shadow: inset 0 0 0 2px var(--accent); }
#onboarding-screen .ob-choice-card .ob-choice-icon { flex: 0 0 34px; width: 34px; height: 34px; margin: 0; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; background: var(--surface-soft); color: var(--accent-strong); font-size: 20px; }
#onboarding-screen .ob-choice-card .ob-choice-icon svg { width: 18px; height: 18px; }
#onboarding-screen .ob-choice-card.active .ob-choice-icon { background: var(--surface); }
.ob-caution { margin: 10px 0 0; font-size: 13px; line-height: 1.45; color: var(--text-secondary); }
.ob-warn { margin: 8px 0 0; padding: 8px 10px; border-radius: 12px; background: #FDECEA; color: #8C1D18; box-shadow: inset 3px 0 0 #D9776F; font-size: 13.5px; line-height: 1.45; font-weight: 600; }

.ob-more { margin-top: 14px; padding: 0 12px; border-radius: 16px; background: var(--surface); box-shadow: 0 0 0 1px var(--line), var(--shadow-1); }
.ob-more > summary { display: flex; align-items: center; gap: 8px; min-height: 48px; cursor: pointer; list-style: none; font-size: 14.5px; font-weight: 800; color: var(--text-primary); }
.ob-more > summary::-webkit-details-marker { display: none; }
.ob-more > summary::after { content: ""; margin: -3px 4px 0 auto; flex: 0 0 auto; width: 7px; height: 7px; border-right: 2px solid var(--text-secondary); border-bottom: 2px solid var(--text-secondary); border-radius: 1px; transform: rotate(45deg); transition: transform 150ms ease; }
.ob-more[open] > summary::after { transform: translateY(3px) rotate(-135deg); }
.ob-more > summary:focus-visible { outline: 3px solid var(--accent-strong); outline-offset: 2px; border-radius: 12px; }
.ob-more[open] { padding-bottom: 12px; }
.ob-more > summary + * { margin-top: 0; }
.ob-opt { font-size: 11.5px; font-weight: 700; color: var(--text-secondary); background: var(--surface-soft); border-radius: var(--radius-pill); padding: 1px 8px; }
.ob-checks { display: grid; margin-top: 10px; }
.ob-check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; line-height: 1.35; cursor: pointer; }
.ob-check input { flex: 0 0 auto; width: 22px; height: 22px; min-height: 0; margin: 0; accent-color: var(--accent); }

/* ---------- step 5: the starting plan ---------- */
.ob-targets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 6px 0 10px; }
.ob-targets > div { background: var(--surface); border-radius: var(--radius-md); padding: 8px 12px; box-shadow: 0 0 0 1px var(--line), var(--shadow-1); }
.ob-targets dt { font-size: 12px; font-weight: 700; color: var(--text-secondary); }
.ob-targets dd { margin: 0; font-family: var(--font-display); font-size: 16px; font-weight: 800; line-height: 1.3; color: var(--text-primary); }
.ob-cautions { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; }
.ob-cautions li { display: block; margin: 0; padding: 8px 10px 8px 12px; border-radius: 12px; border: 0; box-shadow: inset 3px 0 0 var(--lavender); background: var(--lavender-light); color: var(--text-primary); font-size: 13.5px; line-height: 1.45; }
.ob-why p { margin: 4px 0; font-size: 13px; line-height: 1.45; color: var(--text-secondary); }
#onboarding-screen .ob-sub-head { margin-top: 18px; }
.ob-sec { margin-top: 8px; }

/* ---------- footer: always reachable ---------- */
.ob-footer { position: sticky; bottom: 0; z-index: 5; margin-top: 18px; padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--app-bg-bottom, #F8F7F2) 78%, color-mix(in srgb, var(--app-bg-bottom, #F8F7F2) 0%, transparent)); }
#onboarding-screen .ob-nav-row { display: flex; gap: 10px; margin: 0; }
#onboarding-screen .ob-nav-row button { flex: 1 1 0; min-height: 48px; margin: 0; }
#onboarding-screen #ob-back-btn { flex: 0 0 auto; padding: 0 18px; }
.ob-error { margin: 0 0 8px; padding: 8px 10px; border-radius: 12px; background: #FDECEA; color: #8C1D18; box-shadow: var(--shadow-1); font-size: 13.5px; line-height: 1.45; font-weight: 600; text-align: center; }
.ob-recalc { margin: 0; font-size: 14.5px; font-weight: 700; }
.ob-recalc-note { margin: -4px 0 6px 32px; font-size: 12.5px; color: var(--text-secondary); }

@media (max-width: 360px) {
  #onboarding-screen .ob-choice-card { font-size: 14px; padding: 8px 10px; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) { .ob-more > summary::after { transition: none; } #onboarding-screen .ob-progress-fill { transition: none; } }
html[data-motion="reduced"] #onboarding-screen .ob-progress-fill, html[data-motion="off"] #onboarding-screen .ob-progress-fill { transition: none; }
