:root {
  --green: #1daa3e;
  --green-dark: #117d2d;
  --green-soft: #e8f8eb;
  --ink: #111713;
  --muted: #68726b;
  --line: #e3e9e5;
  --surface: #ffffff;
  --surface-2: #f6f8f7;
  --shadow: 0 14px 40px rgba(20, 45, 27, .08);
  --radius: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { background: #eef4ef; color-scheme: light; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(circle at top, #ffffff 0, #f4f8f5 38%, #edf3ef 100%);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

.app-shell {
  width: min(100%, 860px);
  min-height: 100vh;
  margin: 0 auto;
  background: #fbfdfb;
  box-shadow: 0 0 80px rgba(25, 67, 35, .08);
  padding-bottom: calc(82px + var(--safe-bottom));
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 18px 12px;
  background: rgba(251, 253, 251, .9);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(222, 231, 225, .85);
}
.brand-button, .date-button, .icon-button {
  border: 0;
  background: transparent;
  color: var(--ink);
}
.brand-button { display: inline-flex; align-items: center; gap: 9px; padding: 0; font-weight: 900; font-size: 1.35rem; }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.date-button { display: flex; align-items: center; gap: 7px; background: #f1f5f2; border-radius: 12px; padding: 9px 11px; font-weight: 700; color: #29322c; }
.icon-button { width: 42px; height: 42px; border-radius: 50%; background: #f1f5f2; font-size: 1.1rem; }

main { padding: max(12px, calc(env(safe-area-inset-top) + 8px)) 14px 6px; }
.view { display: none; animation: fade .18s ease-out; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.status-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 17px;
  border-radius: 21px;
  border: 1px solid rgba(18, 55, 27, .08);
  box-shadow: var(--shadow);
  transition: background .25s ease, border-color .25s ease;
}
.status-green { background: linear-gradient(135deg, #e6f9e3, #d8f4ce); border-color: #bbe7b3; }
.status-yellow { background: linear-gradient(135deg, #fff8cc, #f3efb7); border-color: #eadf8e; }
.status-red { background: linear-gradient(135deg, #ffe1de, #ffd0cb); border-color: #f1aaa2; }
.status-neutral { background: linear-gradient(135deg, #f3f6f4, #eaf0ec); }
.eyebrow { font-size: .84rem; font-weight: 800; letter-spacing: .01em; color: #28332b; }
.status-number { display: flex; align-items: baseline; flex-wrap: nowrap; gap: 4px; line-height: .95; margin: 7px 0 8px; white-space: nowrap; }
.status-eaten-number { font-size: clamp(2.55rem, 9.6vw, 4.15rem); font-weight: 900; letter-spacing: -.065em; }
.status-unit { font-size: .9rem; font-weight: 850; margin-right: 2px; }
.status-divider { font-size: clamp(1.45rem, 5.2vw, 2rem); font-weight: 650; opacity: .56; margin: 0 1px; }
.status-goal-number { font-size: clamp(1.55rem, 6.2vw, 2.45rem); font-weight: 900; letter-spacing: -.045em; }
.status-goal-unit { font-size: .76rem; font-weight: 800; opacity: .76; }
.status-subtext { font-size: .84rem; color: #34463a; max-width: 34rem; }
.status-ring-stack { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-width: 92px; }
.goal-ring {
  --pct: 0deg;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--green-dark) var(--pct), rgba(255,255,255,.6) 0);
}
.goal-ring-inner { width: 60px; height: 60px; border-radius: 50%; background: rgba(255,255,255,.88); display: grid; place-items: center; font-weight: 900; color: #2b4832; }
.status-trend { max-width: 105px; text-align: center; font-size: .69rem; line-height: 1.18; font-weight: 850; color: #31503a; }
.remaining-card { margin-top: 8px; min-height: 48px; border-radius: 16px; background: #ebf9ed; border: 1px solid #d2edd7; display: flex; align-items: baseline; justify-content: center; gap: 8px; padding: 10px 14px; box-shadow: 0 6px 20px rgba(27,54,34,.04); }
.remaining-card strong { color: var(--green-dark); font-size: 1.35rem; letter-spacing: -.025em; }
.remaining-card span { color: #4b6552; font-size: .82rem; font-weight: 800; }

.mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 9px 0; }
.mini-card, .card, .stat-card, .insight-card, .privacy-card {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 8px 28px rgba(27, 54, 34, .05);
}
.mini-card { border-radius: 16px; padding: 13px; }
.mini-label { font-size: .78rem; color: var(--muted); font-weight: 700; }
.mini-value { font-size: 1.5rem; font-weight: 900; letter-spacing: -.04em; margin-top: 5px; }
.mini-value small { font-size: .52em; color: var(--muted); letter-spacing: 0; }
.mini-sub { margin-top: 6px; font-size: .77rem; color: var(--muted); }

.card { border-radius: var(--radius); padding: 15px; margin-top: 9px; }
.card h2, .page-title-row h1, .onboarding h1 { margin: 0; letter-spacing: -.035em; }
.card h2 { font-size: 1.08rem; }
.card-heading-row, .page-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-kicker { color: var(--green-dark); font-weight: 800; text-transform: uppercase; font-size: .68rem; letter-spacing: .09em; margin-bottom: 3px; }
.centered { text-align: center; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 8px; background: #f1f4f2; font-size: .72rem; color: var(--muted); font-weight: 800; white-space: nowrap; }
.badge.accent { background: var(--green-soft); color: var(--green-dark); }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field span { font-size: .78rem; font-weight: 750; color: #39423c; }
.field input, .select-control {
  width: 100%;
  min-height: 44px;
  border: 1px solid #dbe3dd;
  border-radius: 13px;
  background: #f9fbfa;
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.field input:focus, .select-control:focus { border-color: #7ac98b; box-shadow: 0 0 0 4px rgba(29, 170, 62, .11); background: #fff; }
.inline-form { display: flex; align-items: end; gap: 9px; margin-top: 10px; }
.grow { flex: 1; }
.form-grid, .profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.food-form { display: grid; gap: 10px; margin-top: 10px; }
.food-input-grid { grid-template-columns: 1fr; }
.food-log-kicker { margin: 0; text-align: right; }
.label-free-field input::placeholder { color: #111; opacity: .9; font-weight: 650; }
.quick-add-wrap { margin-top: 10px; }
.quick-add-field { max-width: 100%; }
.quick-add-select { width: 100%; min-height: 44px; font-weight: 800; font-size: .82rem; white-space: nowrap; text-overflow: ellipsis; background: #f4faf5; border-color: #d6e8da; }
.quick-add-select:focus { border-color: #7ac98b; box-shadow: 0 0 0 4px rgba(29, 170, 62, .11); background: #fff; }
.expression-wrap { position: relative; }
.expression-wrap input { padding-right: 76px; }
.expression-result { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: var(--green-soft); color: var(--green-dark); padding: 6px 9px; border-radius: 9px; font-weight: 900; font-size: .8rem; }
.primary-button, .secondary-button {
  border: 0;
  border-radius: 14px;
  min-height: 44px;
  padding: 9px 14px;
  font-weight: 850;
}
.primary-button { color: white; background: linear-gradient(180deg, #25b946, #159435); box-shadow: 0 8px 16px rgba(21, 148, 53, .18); }
.primary-button:active { transform: translateY(1px); }
.primary-button.compact { min-height: 44px; white-space: nowrap; }
.secondary-button { background: #edf5ef; color: var(--green-dark); }


.status-date-button {
  border: 0;
  background: rgba(255,255,255,.62);
  color: inherit;
  border-radius: 999px;
  padding: 3px 7px;
  margin-left: 3px;
  font-size: .78rem;
  font-weight: 850;
}
.status-date-button:active { transform: translateY(1px); }

.entries-list { display: grid; margin-top: 10px; }
.entry-row { display: grid; cursor: pointer; border-radius: 10px; padding-left: 4px; padding-right: 4px; transition: background .15s ease; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 9px 0; border-top: 1px solid #edf1ee; }
.entry-row:hover, .entry-row:focus-visible { background: #f7faf8; outline: none; }
.entry-main { min-width: 0; }
.entry-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-main small, .entry-time { color: var(--muted); font-size: .75rem; }
.entry-calories { font-weight: 900; white-space: nowrap; }
.empty-state { padding: 26px 10px; text-align: center; color: var(--muted); }

.page-title-row { margin-bottom: 8px; }
.page-title-row h1 { font-size: 2rem; }
.select-control { width: auto; min-height: 42px; font-weight: 750; }
.chart-card { overflow: hidden; }
.chart-area { min-height: 210px; margin-top: 6px; }
.chart-area svg { width: 100%; height: 210px; overflow: visible; }
.chart-axis { stroke: #dfe6e1; stroke-width: 1; }
.chart-label { fill: #79837d; font-size: 10px; }
.chart-line { fill: none; stroke: var(--green-dark); stroke-width: 3.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-fill { fill: url(#weightGradient); }
.chart-point { fill: #fff; stroke: var(--green-dark); stroke-width: 3; }
.chart-bar { fill: #65cf7d; rx: 5; }
.chart-goal { stroke: var(--green-dark); stroke-width: 1.5; stroke-dasharray: 5 5; opacity: .8; }
.no-chart { min-height: 220px; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 24px; }
.muted { color: var(--muted); font-size: .77rem; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 9px; }
.stat-card { border-radius: 16px; padding: 13px; }
.stat-card span, .stat-card small { display: block; color: var(--muted); font-size: .74rem; }
.stat-card strong { display: block; margin: 6px 0 3px; font-size: 1.25rem; color: var(--green-dark); }
.insight-card { border-radius: 17px; padding: 14px; display: flex; gap: 10px; margin-top: 9px; background: #edf7ff; border-color: #d5e8f8; }
.insight-icon { font-size: 1.3rem; }
.insight-card p, .privacy-card p { margin: 5px 0 0; color: #51625a; line-height: 1.45; font-size: .86rem; }

.profile-form { display: grid; gap: 10px; }
.profile-grid .full { grid-column: 1 / -1; }
.info-note { border-radius: 12px; padding: 10px 11px; background: #edf8ef; color: #35553d; font-size: .82rem; line-height: 1.45; }
.info-note.subtle { background: #f5f7f6; color: var(--muted); }
.settings-list { display: grid; gap: 7px; margin-top: 9px; }
.settings-row { width: 100%; border: 0; background: #f8faf9; border-radius: 13px; padding: 10px; display: grid; grid-template-columns: 42px 1fr auto; gap: 10px; align-items: center; text-align: left; color: var(--ink); }
.settings-icon { width: 38px; height: 38px; border-radius: 11px; background: #e9f7ec; color: var(--green-dark); display: grid; place-items: center; font-size: 1.2rem; font-weight: 900; }
.settings-row strong, .settings-row small { display: block; }
.settings-row small { color: var(--muted); margin-top: 2px; }
.danger-row .settings-icon { background: #ffeded; color: #a52b2b; }
.danger-row strong { color: #9e2a2a; }
.privacy-card { border-radius: 19px; padding: 17px; margin-top: 12px; background: #f7faf8; }

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  z-index: 60;
  width: min(100%, 860px);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(20px);
  border-top: 1px solid #dfe7e1;
  padding: 6px 10px calc(6px + var(--safe-bottom));
}
.nav-button { border: 0; background: transparent; color: #667169; display: flex; flex-direction: column; align-items: center; gap: 2px; border-radius: 14px; padding: 6px 4px; }
.nav-button span { font-size: 1.2rem; line-height: 1; }
.nav-button small { font-size: .68rem; font-weight: 800; }
.nav-button.active { color: var(--green-dark); background: #edf8ef; }

.onboarding { min-height: 100vh; display: grid; place-items: center; padding: 26px 16px; }
.onboarding-card { width: min(100%, 620px); background: rgba(255,255,255,.96); border: 1px solid var(--line); border-radius: 32px; padding: 28px; box-shadow: 0 28px 80px rgba(21, 56, 29, .12); }
.onboarding-logo { display: block; width: 104px; height: 104px; margin: 0 auto 12px; border-radius: 24px; }
.onboarding h1 { text-align: center; font-size: clamp(2rem, 8vw, 3.4rem); }
.onboarding-intro { color: var(--muted); text-align: center; line-height: 1.55; max-width: 500px; margin: 10px auto 22px; }
.onboarding-submit { width: 100%; margin-top: 15px; }

.modal { position: fixed; inset: 0; z-index: 100; background: rgba(10, 20, 13, .45); display: grid; place-items: center; padding: 20px; backdrop-filter: blur(8px); }
.modal-card { width: min(100%, 420px); background: #fff; border-radius: 24px; padding: 24px; text-align: center; position: relative; box-shadow: 0 24px 80px rgba(0,0,0,.2); }
.modal-close { position: absolute; right: 12px; top: 10px; width: 38px; height: 38px; border: 0; border-radius: 50%; background: #f1f4f2; font-size: 1.5rem; }
.modal-logo { width: 82px; height: 82px; border-radius: 20px; }
.modal-card p { color: var(--muted); line-height: 1.5; }
.modal-card .primary-button { width: 100%; }

.edit-entry-modal-card { text-align: left; }
.edit-entry-modal-card h2 { margin: 2px 0 14px; }
.edit-entry-form { display: grid; gap: 12px; }
.modal-actions { display: grid; grid-template-columns: auto 1fr; gap: 10px; margin-top: 2px; }
.danger-button { color: #9e2a2a; background: #ffeded; }

.toast { position: fixed; left: 50%; bottom: calc(88px + var(--safe-bottom)); transform: translateX(-50%); z-index: 120; background: #152018; color: #fff; padding: 11px 15px; border-radius: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.18); max-width: min(90vw, 430px); text-align: center; font-size: .86rem; }

@media (max-width: 560px) {
  main { padding-left: 10px; padding-right: 10px; }
  .status-card { padding: 14px; }
  .goal-ring { width: 72px; height: 72px; }
  .goal-ring-inner { width: 52px; height: 52px; font-size: .82rem; }
  .mini-grid, .stats-grid { gap: 9px; }
  .mini-card, .card { border-radius: 18px; }
  .form-grid, .profile-grid { grid-template-columns: 1fr; }
  .profile-grid .full { grid-column: auto; }
  .inline-form { align-items: stretch; flex-direction: column; }
  .inline-form .primary-button { width: 100%; }
  .entry-row { grid-template-columns: minmax(0,1fr) auto; }
  .onboarding-card { padding: 23px 18px; border-radius: 24px; }
}
@media (display-mode: standalone) {
  .app-shell { width: 100%; box-shadow: none; }
}

/* v4: server sync + resilient startup */
.boot-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top, #ffffff 0, #f4f8f5 42%, #edf3ef 100%);
}
.boot-card {
  width: min(100%, 390px);
  text-align: center;
  padding: 28px 24px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 22px 70px rgba(20,45,27,.10);
}
.boot-logo { width: 84px; height: 84px; border-radius: 20px; margin-bottom: 12px; }
.boot-card strong { display: block; font-size: 1.35rem; }
.boot-card p { color: var(--muted); line-height: 1.5; margin: 8px 0 16px; }
.boot-card button { width: 100%; }

.onboarding-sync {
  max-width: 360px;
  margin: 14px auto 0;
  padding: 12px;
  border: 1px solid #d9e7dc;
  border-radius: 16px;
  background: #f5fbf6;
}
.sync-code-field input {
  text-transform: uppercase;
  text-align: center;
  letter-spacing: .22em;
  font-size: 1.2rem;
  font-weight: 900;
}
.sync-status { margin-top: 7px; color: var(--muted); font-size: .75rem; line-height: 1.4; text-align: center; }
.sync-status.error { color: #a72f2f; }
.sync-status.success { color: var(--green-dark); font-weight: 800; }
.sync-status.loading { color: #385c42; }

.sync-code-modal-card { max-width: 390px; }
.sync-code-value {
  margin: 14px 0 8px;
  padding: 14px 10px;
  border-radius: 16px;
  background: #edf8ef;
  color: var(--green-dark);
  font-size: clamp(2rem, 10vw, 3.2rem);
  font-weight: 950;
  letter-spacing: .18em;
  line-height: 1;
  text-align: center;
  user-select: all;
}
.sync-code-countdown { margin: 8px 0 14px; color: var(--muted); font-size: .82rem; font-weight: 800; }
.sync-code-modal-card .secondary-button { width: 100%; }

/* Avoid accidental backdrop closes while a user is scrolling a mobile keyboard/form. */
.modal { touch-action: pan-y; }
.modal-card { touch-action: auto; }


/* v4.2: safer log rows, Quick Add management, wider iOS picker and dark mode */
.field-help { display: block; margin-top: 1px; color: var(--muted); font-size: .72rem; line-height: 1.35; }
.modal-helper { margin: -6px 34px 10px 0 !important; font-size: .82rem; }
.quick-add-manager-card { max-height: min(78vh, 650px); overflow: auto; }
.quick-add-manager-list { display: grid; gap: 7px; margin-top: 10px; }
.quick-add-manager-row {
  width: 100%;
  border: 0;
  border-radius: 13px;
  background: #f8faf9;
  color: var(--ink);
  padding: 11px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  text-align: left;
}
.quick-add-manager-row strong, .quick-add-manager-row small { display: block; }
.quick-add-manager-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-add-manager-row small { margin-top: 2px; color: var(--muted); font-size: .74rem; }
.quick-add-manager-row > span:last-child { color: var(--muted); font-size: 1.35rem; }

/* iOS uses the control width as a strong hint for the native picker/popover. */
@supports (-webkit-touch-callout: none) {
  .quick-add-field { width: calc(100% + 18px); max-width: none; margin-left: -9px; }
  .quick-add-select { width: 100%; font-size: .76rem; padding-left: 9px; padding-right: 24px; }
  .quick-add-select option { font-size: .76rem; }
}

:root[data-theme="dark"] {
  --green: #49c969;
  --green-dark: #68d982;
  --green-soft: #173822;
  --ink: #f1f6f2;
  --muted: #a8b4ac;
  --line: #3a3a3a;
  --surface: #1b1b1b;
  --surface-2: #252525;
  --shadow: 0 14px 40px rgba(0, 0, 0, .24);
}
:root[data-theme="dark"] { background: #000; color-scheme: dark; }
:root[data-theme="dark"] body { background: #000; }
:root[data-theme="dark"] .app-shell { background: #000; box-shadow: 0 0 80px rgba(0,0,0,.36); }
:root[data-theme="dark"] .mini-card,
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .stat-card,
:root[data-theme="dark"] .privacy-card { background: var(--surface); border-color: var(--line); box-shadow: 0 8px 28px rgba(0,0,0,.18); }
:root[data-theme="dark"] .field span { color: #cbd5ce; }
:root[data-theme="dark"] .field input,
:root[data-theme="dark"] .select-control { background: #252525; border-color: #474747; color: var(--ink); }
:root[data-theme="dark"] .field input:focus,
:root[data-theme="dark"] .select-control:focus { background: #2d2d2d; border-color: #65ba78; }
:root[data-theme="dark"] .quick-add-select { background: #242424; border-color: #454545; }
:root[data-theme="dark"] .badge { background: #292929; }
:root[data-theme="dark"] .badge.accent { background: #173822; color: var(--green-dark); }
:root[data-theme="dark"] .secondary-button { background: #292929; color: var(--green-dark); }
:root[data-theme="dark"] .status-date-button { background: rgba(42,42,42,.72); }
:root[data-theme="dark"] .status-neutral { background: linear-gradient(135deg, #262626, #1d1d1d); border-color: #3c3c3c; }
:root[data-theme="dark"] .status-green { background: linear-gradient(135deg, #17331f, #1c4027); border-color: #2d6540; }
:root[data-theme="dark"] .status-yellow { background: linear-gradient(135deg, #403914, #322f16); border-color: #655c25; }
:root[data-theme="dark"] .status-red { background: linear-gradient(135deg, #43201f, #371b1a); border-color: #6f3431; }
:root[data-theme="dark"] .eyebrow,
:root[data-theme="dark"] .status-subtext { color: #d4ded7; }
:root[data-theme="dark"] .goal-ring-inner { background: #232323; color: #e8eee9; }
:root[data-theme="dark"] .entry-row { border-top-color: #343434; }
:root[data-theme="dark"] .entry-row:hover,
:root[data-theme="dark"] .entry-row:focus-visible { background: #252525; }
:root[data-theme="dark"] .remaining-card { background: #202020; border-color: #383838; }
:root[data-theme="dark"] .remaining-card span { color: #b4b4b4; }
:root[data-theme="dark"] .info-note { background: #242424; color: #c7d0c9; }
:root[data-theme="dark"] .info-note.subtle { background: #262626; color: var(--muted); }
:root[data-theme="dark"] .settings-row,
:root[data-theme="dark"] .quick-add-manager-row { background: #252525; color: var(--ink); }
:root[data-theme="dark"] .settings-icon { background: #18351f; color: var(--green-dark); }
:root[data-theme="dark"] .danger-row .settings-icon,
:root[data-theme="dark"] .danger-button { background: #422322; color: #ffaaa5; }
:root[data-theme="dark"] .danger-row strong { color: #ffaaa5; }
:root[data-theme="dark"] .insight-card { background: #172632; border-color: #294153; }
:root[data-theme="dark"] .insight-card p,
:root[data-theme="dark"] .privacy-card p { color: #aebbb3; }
:root[data-theme="dark"] .bottom-nav { background: rgba(10,10,10,.96); border-top-color: #363636; }
:root[data-theme="dark"] .nav-button { color: #a7b1aa; }
:root[data-theme="dark"] .nav-button.active { color: var(--green-dark); background: #18331f; }
:root[data-theme="dark"] .modal { background: rgba(0,0,0,.62); }
:root[data-theme="dark"] .modal-card,
:root[data-theme="dark"] .onboarding-card,
:root[data-theme="dark"] .boot-card { background: #1c1c1c; border-color: var(--line); color: var(--ink); }
:root[data-theme="dark"] .modal-close { background: #292929; color: var(--ink); }
:root[data-theme="dark"] .onboarding-sync { background: #202020; border-color: #3a3a3a; }
:root[data-theme="dark"] .boot-screen { background: #000; }
:root[data-theme="dark"] .sync-code-value { background: #173822; color: var(--green-dark); }
:root[data-theme="dark"] .chart-axis { stroke: #3c3c3c; }
:root[data-theme="dark"] .chart-label { fill: #9aa79e; }
:root[data-theme="dark"] .chart-point { fill: #1b1b1b; }
:root[data-theme="dark"] .label-free-field input::placeholder { color: #f1f6f2; opacity: .86; }
:root[data-theme="dark"] .status-trend { color: #c4d1c7; }


/* v4.3 weight check-in behavior */
.tappable-card {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.tappable-card:active { transform: scale(.985); }
.tappable-card:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--green) 35%, transparent);
  outline-offset: 2px;
}
.weight-modal-day { margin-top: -7px !important; margin-bottom: 12px !important; }
@media (hover: hover) {
  .tappable-card:hover { border-color: #b8d9bf; box-shadow: 0 9px 28px rgba(27, 84, 40, .09); }
}
:root[data-theme="dark"] .tappable-card:hover { border-color: #436c4d; }

/* v4.5: reliable day picker + day-boundary period handling */
.date-picker-modal-card { max-width: 390px; }
.date-picker-modal-card input[type="date"] { width: 100%; min-height: 46px; font-size: 1rem; }
.date-picker-actions { margin-top: 14px; }
.date-picker-actions > * { flex: 1; }

/* v4.8: BMI, dense weight labels, and read-only sharing */
.chart-point-label {
  fill: var(--ink);
  font-size: 10px;
  font-weight: 850;
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 3px;
  stroke-linejoin: round;
}
.bmi-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.bmi-summary-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  padding: 12px 13px;
}
.bmi-summary-card span {
  display: block;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 750;
}
.bmi-summary-card strong {
  display: block;
  margin-top: 4px;
  color: var(--green-dark);
  font-size: 1.45rem;
  letter-spacing: -.035em;
}
.share-modal-card { max-width: 470px; max-height: min(86vh, 760px); overflow: auto; }
.share-choice-list { display: grid; gap: 7px; margin: 12px 0 14px; }
.share-choice {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
  padding: 11px 12px;
  cursor: pointer;
}
.share-choice input { margin-top: 3px; accent-color: var(--green-dark); }
.share-choice strong, .share-choice small { display: block; }
.share-choice small { color: var(--muted); margin-top: 2px; font-size: .74rem; line-height: 1.35; }
.share-result { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 14px; }
.share-result textarea {
  width: 100%;
  min-height: 112px;
  resize: vertical;
  border: 1px solid #dce4df;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}
.share-actions { grid-template-columns: 1fr 1fr; margin-top: 9px; }
:root[data-theme="dark"] .bmi-summary-card,
:root[data-theme="dark"] .share-choice { background: #252525; border-color: #404040; }
:root[data-theme="dark"] .chart-point-label { stroke: var(--surface); fill: var(--ink); }
:root[data-theme="dark"] .share-result textarea { background: #252525; border-color: #474747; color: var(--ink); }
@media (max-width: 520px) {
  .bmi-summary-grid { grid-template-columns: 1fr 1fr; }
  .chart-point-label { font-size: 9px; }
}


/* v4.9: larger graph values, metric tooltips, account UI */
.chart-point-label { font-size: 14px; font-weight: 900; }
.chart-calorie-label { font-size: 12px; }
.chart-bmi-fill { fill: url(#bmiGradient); }
.chart-target-note { fill: var(--muted); font-size: 10px; font-weight: 800; }
.chart-bar-good { fill: #58c978; }
.chart-bar-warn { fill: #e1bb3d; }
.chart-bar-bad { fill: #e36b60; }
.chart-bar-neutral { fill: #8b9890; }
.chart-bar-goal { stroke: var(--ink); stroke-width: 1.4; opacity: .45; }
.chart-hover-target { cursor: default; }
.chart-tooltip { position: fixed; z-index: 300; pointer-events: none; opacity: 0; transform: translateY(3px); transition: opacity .08s ease, transform .08s ease; padding: 6px 8px; border-radius: 9px; background: rgba(18,23,19,.94); color: white; font-size: 11px; font-weight: 750; box-shadow: 0 6px 24px rgba(0,0,0,.2); white-space: nowrap; }
.chart-tooltip.visible { opacity: 1; transform: none; }
.settings-copy { color: var(--muted); font-size: .84rem; line-height: 1.45; margin: 7px 0 10px; }
.account-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 10px; }
.text-button { border: 0; background: transparent; color: var(--green-dark); font-weight: 800; padding: 9px 4px; text-align: left; }
.onboarding-account { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
:root[data-theme="dark"] .chart-bar-goal { stroke: #f0f3f1; }
:root[data-theme="dark"] .chart-tooltip { background: rgba(245,247,246,.96); color: #111; }
@media (max-width: 520px) {
  /* SVG text scales with the 720-unit viewBox on phones. These larger source
     sizes produce roughly the same visible label size as the desktop chart. */
  .chart-point-label { font-size: 24px; stroke-width: 5px; }
  .chart-calorie-label { font-size: 22px; }
}


/* v5.0: unified 30-day goal estimate + iPhone chart legibility */

/* v5.1: iPhone date labels + projected goal month */
.goal-date-stat { font-weight: 850; color: var(--ink) !important; margin-bottom: 2px; }
@media (max-width: 520px) {
  .chart-label { font-size: 16px; font-weight: 750; }
}
