:root {
  color-scheme: light dark;
  --blue: #1677ff;
  --blue-strong: #0668e8;
  --blue-soft: #e8f2ff;
  --green: #248a3d;
  --green-soft: #e8f6eb;
  --orange: #c86400;
  --orange-soft: #fff1dc;
  --red: #d70015;
  --red-soft: #ffebed;
  --purple: #7542c8;
  --background: #f2f2f7;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-secondary: #f2f2f7;
  --surface-tertiary: #e9e9ee;
  --label: #111114;
  --secondary-label: #5f5f67;
  --tertiary-label: #86868f;
  --separator: rgba(60, 60, 67, 0.18);
  --separator-strong: rgba(60, 60, 67, 0.3);
  --material: rgba(249, 249, 251, 0.78);
  --scrim: rgba(0, 0, 0, 0.28);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
  --focus: #0a84ff;
  --sidebar-width: 252px;
  --sidebar-compact: 80px;
  --topbar-height: 58px;
  --tabbar-height: 58px;
  --content-max: 1480px;
  --radius-card: 18px;
  --radius-control: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, "Helvetica Neue", sans-serif;
  font-family: var(--font);
  font-size: 16px;
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html[data-theme="dark"] {
  --blue: #409cff;
  --blue-strong: #64adff;
  --blue-soft: #102d4f;
  --green: #42c45b;
  --green-soft: #15361d;
  --orange: #ff9f0a;
  --orange-soft: #3f2c0c;
  --red: #ff453a;
  --red-soft: #431a1c;
  --purple: #bf8cff;
  --background: #000000;
  --surface: #1c1c1e;
  --surface-raised: #2c2c2e;
  --surface-secondary: #2c2c2e;
  --surface-tertiary: #3a3a3c;
  --label: #f5f5f7;
  --secondary-label: #c7c7cc;
  --tertiary-label: #98989f;
  --separator: rgba(84, 84, 88, 0.65);
  --separator-strong: rgba(125, 125, 130, 0.68);
  --material: rgba(28, 28, 30, 0.78);
  --scrim: rgba(0, 0, 0, 0.62);
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.45);
  --focus: #64d2ff;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    --blue: #409cff;
    --blue-strong: #64adff;
    --blue-soft: #102d4f;
    --green: #42c45b;
    --green-soft: #15361d;
    --orange: #ff9f0a;
    --orange-soft: #3f2c0c;
    --red: #ff453a;
    --red-soft: #431a1c;
    --purple: #bf8cff;
    --background: #000000;
    --surface: #1c1c1e;
    --surface-raised: #2c2c2e;
    --surface-secondary: #2c2c2e;
    --surface-tertiary: #3a3a3c;
    --label: #f5f5f7;
    --secondary-label: #c7c7cc;
    --tertiary-label: #98989f;
    --separator: rgba(84, 84, 88, 0.65);
    --separator-strong: rgba(125, 125, 130, 0.68);
    --material: rgba(28, 28, 30, 0.78);
    --scrim: rgba(0, 0, 0, 0.62);
    --shadow: 0 22px 60px rgba(0, 0, 0, 0.45);
    --focus: #64d2ff;
  }
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--background); }
body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background: var(--background);
  color: var(--label);
  font: 400 16px/1.42 var(--font);
  letter-spacing: -0.008em;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button:not(:disabled), a[href] { cursor: pointer; }
button:disabled, input:disabled, textarea:disabled, select:disabled { cursor: not-allowed; opacity: 0.48; }
img, svg { display: block; max-width: 100%; }
a { color: var(--blue); }
h1, h2, h3, p { margin-block-start: 0; }
h1, h2, h3, strong, b { font-weight: 650; }
h1 { margin-bottom: 0; font-size: clamp(32px, 3vw, 42px); line-height: 1.05; letter-spacing: -0.035em; }
h2 { margin-bottom: 0; font-size: 21px; line-height: 1.18; letter-spacing: -0.018em; }
h3 { margin-bottom: 0; font-size: 17px; line-height: 1.25; }
:focus-visible { outline: none; }
body.keyboard-navigation :focus-visible { outline: 3px solid color-mix(in srgb, var(--focus) 70%, transparent); outline-offset: 2px; }
.main:focus-visible { outline: none; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.skip-link { position: fixed; z-index: 200; top: 8px; left: 8px; min-height: 44px; transform: translateY(-160%); padding: 10px 14px; border-radius: 10px; background: var(--label); color: var(--surface); text-decoration: none; }
.skip-link:focus { transform: translateY(0); }

.auth-active { overflow: auto; }
.auth-gate {
  display: grid;
  min-height: 100dvh;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  place-items: center;
}
.auth-card {
  width: min(100%, 760px);
  overflow: hidden;
  border: 1px solid var(--separator);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 14px; padding: 22px 24px 18px; border-bottom: 1px solid var(--separator); }
.auth-brand img { flex: 0 0 auto; border-radius: 13px; }
.auth-brand span, .auth-step__counter { display: block; margin: 0 0 3px; color: var(--secondary-label); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.auth-brand h1 { font-size: clamp(25px, 5vw, 34px); }
.auth-content { padding: 24px; }
.auth-step { display: grid; gap: 18px; }
.auth-step > h2 + p, .auth-step > p { margin: 0; color: var(--secondary-label); }
.auth-form { display: grid; gap: 16px; }
.auth-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 14px; }
.auth-metrics-grid { display: grid; grid-column: 1 / -1; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.auth-targets { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--separator); border-radius: var(--radius-control); background: var(--surface-secondary); }
.auth-targets > div:first-child { display: grid; gap: 2px; }
.auth-targets__eyebrow { color: var(--secondary-label); font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.auth-targets__grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.auth-targets__grid > span { display: grid; gap: 2px; min-width: 0; }
.auth-targets__grid > span:only-child { grid-column: 1 / -1; color: var(--secondary-label); }
.auth-targets__grid small { color: var(--secondary-label); font-size: 11px; }
.auth-targets__grid strong { font-size: 14px; }
.auth-targets > p { margin: 0; color: var(--tertiary-label); font-size: 12px; }
.auth-form .field small, .auth-grid .field small { display: block; margin-top: 5px; color: var(--tertiary-label); font-size: 12px; }
.auth-submit { justify-self: end; min-width: 240px; }
.auth-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.auth-actions--stack { grid-template-columns: minmax(0, 1fr); }
.auth-code { font-size: 26px !important; font-weight: 700; letter-spacing: .22em; text-align: center; font-variant-numeric: tabular-nums; }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--tertiary-label); font-size: 13px; }
.auth-divider::before, .auth-divider::after { height: 1px; flex: 1; background: var(--separator); content: ""; }
.profile-access-banner { position: fixed; z-index: 145; top: max(8px, env(safe-area-inset-top)); left: 50%; max-width: calc(100vw - 24px); min-height: 44px; padding: 10px 14px; transform: translateX(-50%); border: 1px solid var(--orange); border-radius: 13px; background: var(--orange-soft); color: var(--label); box-shadow: var(--shadow); }

@media (max-width: 600px) {
  .auth-gate { place-items: start center; padding-inline: max(10px, env(safe-area-inset-left)) max(10px, env(safe-area-inset-right)); }
  .auth-card { border-radius: 16px; }
  .auth-brand { padding: 17px; }
  .auth-content { padding: 17px; }
  .auth-grid, .auth-actions, .auth-metrics-grid { grid-template-columns: minmax(0, 1fr); }
  .auth-targets__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-submit, .auth-actions .button { width: 100%; min-width: 0; }
}

.security-panel { display: block; }
.security-panel > .security-form,
.security-panel > .security-list,
.security-panel > .one-time-secret { margin-top: 16px; }
.security-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) 120px; gap: 12px; align-items: end; }
.security-form:not(.security-form--token) .button { width: 120px; }
.security-form--password { margin-top: 14px !important; }
.security-form--token { grid-template-columns: minmax(140px, 1fr) 90px minmax(150px, .8fr) minmax(150px, .8fr) auto; gap: 10px; }
.security-list { display: grid; overflow: hidden; border: 1px solid var(--separator); border-radius: var(--radius-control); }
.security-row { display: flex; min-height: 58px; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; background: var(--surface-raised); }
.security-row + .security-row { border-top: 1px solid var(--separator); }
.security-row > div:first-child { display: grid; min-width: 0; gap: 2px; }
.security-row span { overflow-wrap: anywhere; color: var(--secondary-label); font-size: 13px; }
.security-row__actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.security-row__actions > span { flex: 0 0 auto; overflow-wrap: normal; font-size: 15px; line-height: 1.1; white-space: nowrap; }
.one-time-secret { display: grid; gap: 9px; padding: 14px; border: 1px solid var(--orange); border-radius: var(--radius-control); background: var(--orange-soft); }
.one-time-secret code { max-width: 100%; overflow-wrap: anywhere; user-select: all; font: 600 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.one-time-secret .button { justify-self: start; }
.one-time-secret p { margin: 0; color: var(--secondary-label); font-size: 13px; }

@media (max-width: 800px) {
  .security-form, .security-form--token { grid-template-columns: minmax(0, 1fr); }
  .security-form .button { width: 100%; }
}

@media (max-width: 520px) {
  .security-row { align-items: stretch; flex-direction: column; }
  .security-row .button, .security-row__actions { width: 100%; }
  .security-row__actions .button { flex: 1; }
}

.sf-icon {
  --symbol: none;
  display: inline-block;
  flex: 0 0 auto;
  width: 1.25em;
  height: 1.25em;
  background: currentColor;
  -webkit-mask: var(--symbol) center / contain no-repeat;
  mask: var(--symbol) center / contain no-repeat;
}

.connection-banner, .update-banner {
  position: fixed;
  z-index: 150;
  top: max(8px, env(safe-area-inset-top));
  left: 50%;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(620px, calc(100vw - 24px));
  min-height: 44px;
  padding: 9px 14px;
  transform: translateX(-50%);
  border: 1px solid var(--separator);
  border-radius: 13px;
  background: var(--material);
  box-shadow: var(--shadow);
  color: var(--label);
  font-size: 14px;
  -webkit-backdrop-filter: saturate(160%) blur(24px);
  backdrop-filter: saturate(160%) blur(24px);
}
.connection-banner .sf-icon { color: var(--orange); }
.update-banner { justify-content: space-between; }

.app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky;
  z-index: 40;
  top: 0;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  height: 100dvh;
  padding: 18px 14px max(16px, env(safe-area-inset-bottom));
  overflow: hidden;
  border-right: 1px solid var(--separator);
  background: var(--background);
}
.sidebar__brand { position: relative; z-index: 3; display: flex; min-height: 58px; align-items: center; gap: 12px; padding: 5px 8px 15px; }
.sidebar__brand img { width: 44px; height: 44px; flex: 0 0 auto; border-radius: 11px; }
.sidebar__brand-copy { min-width: 0; }
.sidebar__brand-copy strong, .sidebar__brand-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__brand-title { display: flex; min-width: 0; align-items: baseline; gap: 6px; }
.sidebar__brand-copy strong { font-size: 17px; }
.sidebar__brand-copy span { margin-top: 1px; color: var(--secondary-label); font-size: 13px; }
.sidebar__brand-title .sidebar__version { display: inline; flex: 0 0 auto; margin-top: 0; }
.sidebar__nav { display: grid; gap: 3px; }
.nav-item {
  display: flex;
  width: 100%;
  min-height: 46px;
  align-items: center;
  gap: 13px;
  padding: 9px 12px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--secondary-label);
  text-align: left;
  white-space: nowrap;
}
.nav-item .sf-icon { width: 22px; height: 22px; }
.nav-item span:last-child { overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: color-mix(in srgb, var(--surface-secondary) 72%, transparent); color: var(--label); }
.nav-item[aria-current="page"] { background: var(--blue-soft); color: var(--blue); font-weight: 620; }
.sidebar__collapse {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 13px;
  margin-top: auto;
  padding: 8px 12px;
  border: 1px solid var(--separator);
  border-radius: 11px;
  background: color-mix(in srgb, var(--surface) 82%, var(--background));
  color: var(--secondary-label);
  text-align: left;
  white-space: nowrap;
}
.sidebar__collapse:hover { background: var(--surface); color: var(--label); }
body.sidebar-compact { --sidebar-width: var(--sidebar-compact); }
body.sidebar-compact .sidebar__brand { justify-content: center; padding-inline: 0; }
body.sidebar-compact .sidebar__brand-copy, body.sidebar-compact .nav-item span:last-child, body.sidebar-compact .sidebar__collapse-label { display: none; }
body.sidebar-compact .nav-item, body.sidebar-compact .sidebar__collapse { justify-content: center; padding-inline: 0; }
.sidebar-scrim { display: none; }

.main { min-width: 0; width: 100%; padding: 0 clamp(24px, 3vw, 48px) 64px; }
.topbar {
  position: sticky;
  z-index: 25;
  top: 0;
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  margin-inline: calc(clamp(24px, 3vw, 48px) * -1);
  padding: 7px clamp(24px, 3vw, 48px);
  border-bottom: 0;
  background: color-mix(in srgb, var(--background) 86%, transparent);
  box-shadow: none;
  -webkit-backdrop-filter: saturate(160%) blur(24px);
  backdrop-filter: saturate(160%) blur(24px);
}
.topbar__menu { display: none; }
.topbar__spacer { display: flex; min-width: 0; flex: 1 1 0; align-items: center; }
.view { width: min(100%, var(--content-max)); margin-inline: auto; }
.page-heading { min-width: 0; padding: 0; }
.page-heading h1 { font-size: clamp(28px, 2.3vw, 34px); }
.page-heading__eyebrow { margin-bottom: 4px; color: var(--tertiary-label); font-size: 12px; font-weight: 650; letter-spacing: 0.08em; }
.view { min-height: 300px; }
.view[aria-busy="true"] { cursor: progress; }

.button, .icon-button, .date-control, .segmented button, .tabbar button {
  appearance: none;
  border: 0;
  border-radius: var(--radius-control);
  background: none;
}
.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  font-size: 15px;
  font-weight: 610;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  transition: background-color 150ms ease, box-shadow 150ms ease, color 150ms ease;
}
.button--primary { background: var(--blue); color: #fff; }
.button--primary:hover { background: var(--blue-strong); }
.button--secondary { box-shadow: inset 0 0 0 1px var(--separator); background: var(--surface-raised); color: var(--blue); }
.button--secondary:hover { background: color-mix(in srgb, var(--surface-raised) 90%, #000); }
.button--plain { padding-inline: 8px; color: var(--blue); }
.button--destructive-text { color: var(--red); }
.button--plain:hover { background: color-mix(in srgb, var(--surface-raised) 90%, #000); }
.button--accent { font-weight: 680; }
.button--danger { background: var(--red); color: #fff; }
.button--danger:hover { background: color-mix(in srgb, var(--red) 84%, #000); }
.button--logout { box-shadow: inset 0 0 0 1px var(--red); background: var(--surface-raised); color: var(--red); }
.button--logout:hover { background: color-mix(in srgb, var(--surface-raised) 90%, #000); }
.button--primary:active { background: color-mix(in srgb, var(--blue-strong) 82%, #000); }
.button--secondary:active, .button--plain:active, .button--logout:active { background: color-mix(in srgb, var(--surface-raised) 82%, #000); }
.button--danger:active { background: color-mix(in srgb, var(--red) 74%, #000); }
.button--compact { min-height: 44px; padding: 7px 12px; font-size: 14px; }
.icon-button { display: inline-grid; width: 44px; height: 44px; place-items: center; padding: 0; color: var(--blue); }
.icon-button.topbar__menu { display: none; }
.icon-button:hover { background: var(--surface-secondary); }
.icon-button .sf-icon { width: 20px; height: 20px; }
.date-control {
  display: inline-flex;
  min-width: 0;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--separator);
  font-size: 15px;
  font-weight: 590;
  white-space: nowrap;
}
.date-control .sf-icon { width: 18px; height: 18px; color: var(--blue); }
.date-control__chevron { width: 13px !important; transform: rotate(90deg); color: var(--tertiary-label) !important; }
.date-text--mobile { display: none; }

.stack { display: grid; gap: 16px; }
.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panel, .metric-card, .calorie-card {
  min-width: 0;
  border: 1px solid var(--separator);
  border-radius: var(--radius-card);
  background: var(--surface);
}
.panel { padding: 22px; }
.panel__header, .section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}
.panel__header p, .section-header p, .supporting { margin: 4px 0 0; color: var(--secondary-label); font-size: 14px; }
.eyebrow { display: block; margin-bottom: 4px; color: var(--tertiary-label); font-size: 12px; font-weight: 680; letter-spacing: 0.07em; }
.overview-hero {
  display: grid;
  grid-template-areas: "eaten spent score balance status";
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}
.overview-kpi--eaten { grid-area: eaten; }
.overview-kpi--spent { grid-area: spent; }
.overview-kpi--score { grid-area: score; }
.overview-kpi--balance { grid-area: balance; }
.overview-kpi--status { grid-area: status; }
.calorie-card { display: flex; min-height: 150px; align-items: center; justify-content: space-between; gap: 10px; padding: 17px; }
.calorie-card__value { display: block; margin-top: 4px; font-size: clamp(30px, 2.4vw, 38px); line-height: 0.98; letter-spacing: -0.045em; }
.calorie-card__unit { display: block; margin-top: 7px; color: var(--secondary-label); font-size: 14px; }
.progress-ring { --progress: 0; position: relative; display: grid; width: 70px; height: 70px; flex: 0 0 auto; place-items: center; border-radius: 50%; background: conic-gradient(var(--blue) calc(var(--progress) * 1%), var(--surface-tertiary) 0); }
.progress-ring::before { position: absolute; inset: 7px; border-radius: inherit; background: var(--surface); content: ""; }
.progress-ring strong { position: relative; font-size: 14px; }
.metric-card { display: flex; min-height: 150px; flex-direction: column; justify-content: center; padding: 17px; }
.metric-card span { color: var(--tertiary-label); font-size: 12px; font-weight: 650; letter-spacing: 0.06em; white-space: nowrap; }
.metric-card strong { display: block; margin: 8px 0 1px; font-size: clamp(23px, 2vw, 29px); line-height: 1; letter-spacing: -0.03em; white-space: nowrap; }
.metric-card small { color: var(--secondary-label); font-size: 13px; line-height: 1.25; }
.metric-card--green strong { color: var(--green); }
.metric-card--purple strong { color: var(--purple); }
.metric-card--positive strong { color: var(--green); }
.metric-card--negative strong { color: var(--red); }
.status-card { justify-content: space-between; }
.status-card--closed { background: var(--green-soft); }
.status-card__actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.status-card__actions .button { min-height: 38px; flex: 1 1 auto; padding-inline: 8px; }
.day-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 17px 20px;
  border: 1px solid var(--separator);
  border-radius: var(--radius-card);
  background: var(--surface);
}
.day-status--closed { background: var(--green-soft); }
.day-status__copy { min-width: 0; }
.day-status__copy strong { display: block; font-size: 17px; }
.day-status__copy span { display: block; margin-top: 2px; color: var(--secondary-label); font-size: 14px; }
.day-status__actions { display: flex; flex: 0 0 auto; gap: 8px; }
.pill { display: inline-flex; min-height: 28px; align-items: center; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 620; white-space: nowrap; }
.pill--open { background: var(--orange-soft); color: var(--orange); }
.pill--closed { background: var(--green-soft); color: var(--green); }
.macro-list { display: grid; gap: 15px; }
.macro-row { display: grid; grid-template-columns: 84px 128px minmax(100px, 1fr); align-items: center; gap: 12px; }
.macro-row span, .macro-row strong { font-size: 14px; white-space: nowrap; }
.macro-row strong { text-align: right; }
.macro-row__value { font-variant-numeric: tabular-nums; }
.progress-track { height: 8px; overflow: hidden; border-radius: 99px; background: var(--surface-tertiary); }
.progress-fill { width: var(--progress, 0%); height: 100%; border-radius: inherit; background: var(--blue); }
.macro-row.is-over-limit .macro-row__value { color: var(--red); }
.macro-row.is-over-limit .progress-fill { background: var(--red); }
.activity-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.activity-tile { display: flex; min-width: 0; min-height: 116px; flex-direction: column; align-items: flex-start; padding: 15px; border: 0; border-radius: 15px; background: var(--surface-secondary); text-align: left; }
.activity-tile .sf-icon { width: 23px; height: 23px; color: var(--blue); }
.activity-tile strong { max-width: 100%; margin-top: auto; overflow-wrap: break-word; font-size: 19px; }
.activity-tile__detail { max-width: 100%; margin-top: 2px; color: var(--secondary-label); font-size: 14px; overflow-wrap: break-word; }
html.platform-iphone .walking-details__separator { display: none; }
html.platform-iphone .walking-details__calories { display: block; }
.meal-list, .editor-list { display: grid; gap: 10px; }
.meal-section { overflow: hidden; border: 1px solid var(--separator); border-radius: 15px; }
.meal-section__header { display: flex; min-height: 44px; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; background: var(--surface-secondary); }
.meal-section__header strong, .meal-section__header span { font-size: 14px; white-space: nowrap; }
.meal-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; padding: 11px 14px; border-top: 1px solid var(--separator); }
.meal-row__name { display: block; font-size: 16px; font-weight: 560; overflow-wrap: break-word; }
.meal-row small { display: block; margin-top: 2px; color: var(--secondary-label); font-size: 13px; }
.meal-row > strong { align-self: center; color: var(--blue); font-size: 14px; white-space: nowrap; }
.empty-state { display: grid; min-height: 180px; place-items: center; padding: 30px; color: var(--secondary-label); text-align: center; }
.empty-state .sf-icon { width: 34px; height: 34px; margin: 0 auto 10px; color: var(--tertiary-label); }
.empty-state p { max-width: 420px; margin: 0; }

.segmented { --segmented-inset: 2px; --segmented-radius: 10px; display: inline-grid; grid-auto-flow: column; grid-auto-columns: minmax(92px, 1fr); padding: var(--segmented-inset); border-radius: var(--segmented-radius); background: var(--surface-tertiary); }
.segmented button { min-height: 44px; padding: 5px 12px; border-radius: calc(var(--segmented-radius) - var(--segmented-inset)); color: var(--secondary-label); font-size: 13px; font-weight: 580; white-space: nowrap; }
.segmented button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.14); color: var(--label); }
.searchbar-anchor { position: relative; z-index: 10; min-height: 44px; margin-bottom: 14px; }
.searchbar { position: relative; display: flex; width: 100%; min-width: 0; min-height: 44px; align-items: center; gap: 8px; padding: 7px 11px; border-radius: 12px; background: var(--surface-secondary); }
.topbar__spacer > .searchbar { width: 100%; margin: 0; background: var(--surface); }
.topbar__spacer > .searchbar input { font-size: 15px; }
.topbar__spacer > .searchbar.is-moving { flex: none; }
.searchbar.is-moving { will-change: transform, width; }
.searchbar.is-moving:not(:focus-within) { pointer-events: none; }
.searchbar .sf-icon { color: var(--tertiary-label); }
.searchbar input { width: 100%; min-width: 0; min-height: 30px; padding: 0; border: 0; outline: 0; background: transparent; color: var(--label); font-size: 16px; }
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 13px 12px; border-bottom: 1px solid var(--separator); vertical-align: middle; text-align: left; }
.data-table th { color: var(--tertiary-label); font-size: 12px; font-weight: 650; letter-spacing: 0.035em; white-space: nowrap; }
.data-table td { font-size: 15px; }
.data-table td[data-nowrap] { white-space: nowrap; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr[data-action] { cursor: pointer; }
.data-table tbody tr[data-action]:hover { background: var(--surface-secondary); }
.mobile-list { display: none; }
.inset-list { overflow: hidden; border: 1px solid var(--separator); border-radius: 15px; background: var(--surface); }
.list-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--separator); background: transparent; text-align: left; }
.list-row:last-child { border-bottom: 0; }
.list-row__leading { display: flex; min-width: 0; align-items: center; gap: 12px; }
.list-row__icon { display: grid; width: 32px; height: 32px; flex: 0 0 auto; place-items: center; border-radius: 8px; background: var(--blue); color: #fff; }
.list-row__icon .sf-icon { width: 18px; height: 18px; }
.list-row__copy { min-width: 0; }
.list-row__copy strong, .list-row__copy span { display: block; }
.list-row__copy strong { display: block; font-size: 16px; overflow-wrap: break-word; }
.list-row__copy span { display: block; margin-top: 2px; color: var(--secondary-label); font-size: 14px; overflow-wrap: break-word; }
.list-row__value { color: var(--secondary-label); font-size: 14px; white-space: nowrap; }
.catalog-row__calories { display: inline-block !important; margin-left: 8px !important; white-space: nowrap; }
.catalog-row__code { display: block; max-width: 170px; overflow-wrap: anywhere; white-space: normal; }
.catalog-mobile-list { gap: 0; }
.catalog-mobile-row {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 82px;
  align-items: center;
  grid-template-columns: minmax(0, 1fr) 17px;
  gap: 12px;
  padding: 14px 0;
  border: 0;
  background: transparent;
  color: var(--label);
  text-align: left;
  transition: background-color 140ms ease;
}
.catalog-mobile-row:not([hidden]):has(~ .catalog-mobile-row:not([hidden]))::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1px;
  background: var(--separator);
  content: "";
}
.catalog-mobile-row:active { background: var(--surface-secondary); }
.catalog-mobile-row__copy { display: grid; min-width: 0; gap: 3px; }
.catalog-mobile-row__name { overflow-wrap: break-word; font-size: 17px; font-weight: 600; line-height: 22px; }
.catalog-mobile-row__meta { color: var(--secondary-label); font-size: 15px; font-weight: 400; line-height: 20px; overflow-wrap: break-word; }
.catalog-mobile-row__code { color: var(--tertiary-label); font-size: 13px; font-weight: 400; line-height: 18px; overflow-wrap: anywhere; }
.catalog-mobile-row__chevron { width: 17px; height: 17px; color: var(--secondary-label); }

.chart-shell { position: relative; min-width: 0; }
.chart-svg { width: 100%; height: 260px; overflow: visible; }
.chart-gridline { stroke: var(--separator); stroke-width: 1; }
.chart-line { fill: none; stroke: var(--blue); stroke-linecap: round; stroke-linejoin: round; stroke-width: 3; }
.chart-area { fill: color-mix(in srgb, var(--blue) 14%, transparent); }
.chart-point { fill: var(--surface); stroke: var(--blue); stroke-width: 3; }
.chart-hit { fill: transparent; stroke: none; }
.chart-mark:focus .chart-point, .chart-mark:hover .chart-point, .chart-mark.is-active .chart-point { fill: var(--blue); outline: none; }
.chart-label { fill: var(--secondary-label); font: 13px var(--font); }
.chart-score-label { fill: var(--secondary-label); font: 600 13px var(--font); }
.chart-target { stroke: var(--orange); stroke-width: 2; stroke-dasharray: 7 6; }
.chart-target-label { fill: var(--orange); font: 600 13px var(--font); }
.chart-tooltip {
  position: absolute;
  z-index: 2;
  display: grid;
  width: max-content;
  max-width: min(240px, calc(100% - 16px));
  gap: 4px;
  padding: 10px 12px;
  transform: translateX(-50%);
  border: 1px solid var(--separator);
  border-radius: 12px;
  background: var(--surface-raised);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
  color: var(--secondary-label);
  font-size: 13px;
  line-height: 1.25;
  pointer-events: none;
}
.chart-tooltip > strong { color: var(--label); font-size: 14px; }
.chart-tooltip b { color: var(--label); }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stats-grid--analytics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { min-width: 0; padding: 15px; border-radius: 14px; background: var(--surface-secondary); }
.stat span { display: block; color: var(--secondary-label); font-size: 13px; white-space: nowrap; }
.stat strong { display: block; margin-top: 5px; overflow: hidden; font-size: 22px; text-overflow: ellipsis; white-space: nowrap; }
.stat--positive strong { color: var(--green); }
.stat--negative strong { color: var(--red); }
.stat--neutral strong { color: var(--secondary-label); }
.a11y-table { margin-top: 16px; }
.a11y-table summary { min-height: 44px; padding: 10px 0; color: var(--blue); cursor: pointer; }

.export-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.export-card { display: grid; min-height: 112px; align-content: start; gap: 12px; padding: 15px; border: 1px solid var(--separator); border-radius: 15px; background: var(--surface); color: var(--label); text-align: left; text-decoration: none; }
.export-card__title { display: flex; align-items: center; gap: 9px; color: var(--label) !important; }
.export-card .sf-icon { width: 24px; height: 24px; color: var(--blue); }
.export-card strong { font-size: 17px; }
.export-card__description { color: var(--secondary-label); font-size: 14px; line-height: 1.35; overflow-wrap: break-word; }
.export-card.is-disabled { color: var(--tertiary-label); opacity: .58; }
.export-card.is-disabled .sf-icon { color: var(--tertiary-label); }
.report-scopes { width: 100%; grid-auto-columns: minmax(max-content, 1fr); }
.report-period { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.date-picker-control {
  display: grid;
  width: 100%;
  min-height: 44px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  border: 1px solid var(--separator-strong);
  border-radius: 11px;
  background: var(--surface);
  color: var(--label);
  font-size: 16px;
  text-align: left;
}
.date-picker-control .sf-icon:first-child { color: var(--blue); }
.date-picker-control .sf-icon:last-child { width: 13px; height: 13px; color: var(--tertiary-label); }
.report-preview { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-top: 14px; padding: 14px 15px; border-radius: 14px; background: var(--surface-secondary); }
.report-preview strong { font-size: 16px; }
.report-preview span { color: var(--secondary-label); font-size: 14px; text-align: right; }
.import-options { display: grid; gap: 9px; }
.choice-row { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 11px; padding: 12px; border: 1px solid var(--separator); border-radius: 13px; color: var(--label); }
.choice-row input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--blue); }
.choice-row strong, .choice-row span { display: block; }
.choice-row span { margin-top: 2px; color: var(--secondary-label); font-size: 13px; }
.import-source { display: grid; gap: 6px; margin-top: 14px; }
.import-source__label { color: var(--secondary-label); font-size: 13px; }
.import-source__controls { display: grid; min-width: 0; grid-template-columns: auto auto minmax(140px, 1fr) auto; align-items: stretch; gap: 10px; }
.import-source__button { min-width: 0; }
.import-source__status {
  display: flex;
  min-width: 0;
  min-height: 44px;
  align-items: center;
  padding: 9px 12px;
  border: 1px solid var(--separator);
  border-radius: var(--radius-control);
  background: var(--surface-secondary);
  color: var(--secondary-label);
  font-size: 14px;
}
.import-source__status > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-source__status strong { color: var(--label); font-weight: 560; }
.import-source__preview { min-width: 148px; }
.import-preview { display: grid; gap: 14px; margin-top: 14px; }
.import-preview:empty { display: none; }
.import-preview .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.import-preview__submit { display: grid; justify-items: start; gap: 6px; }
.import-preview__submit > .supporting { margin: 0; }

.settings-page { display: grid; gap: 16px; }
.settings-dashboard {
  grid-template-areas:
    "profile password"
    "profile nutrition"
    "application passkeys"
    "application sessions"
    "token token";
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}
.settings-form-contents { display: contents; }
.settings-card--profile { grid-area: profile; }
.settings-card--password { grid-area: password; }
.settings-card--nutrition { grid-area: nutrition; }
.settings-card--application { grid-area: application; }
.settings-card--passkeys { grid-area: passkeys; }
.settings-card--sessions { grid-area: sessions; }
.settings-card--token { grid-area: token; }

body.view-ai { overflow: hidden; }
body.view-ai .main {
  display: grid;
  height: 100dvh;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  overflow: hidden;
}
body.view-ai .view { height: 100%; min-height: 0; }
body.view-ai .ai-page { height: 100%; min-height: 0; }

.ai-page {
  display: grid;
  height: calc(100dvh - 96px);
  min-height: 560px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--separator);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-subtle);
}
.ai-page__header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px 14px; border-bottom: 1px solid var(--separator); }
.ai-page__header h2 { margin: 3px 0 0; font-size: 20px; }
.ai-status { flex: 0 0 auto; }
.ai-status--busy { padding: 6px 10px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); font-size: 12px; font-weight: 600; }
.ai-conversation { min-height: 0; overflow: auto; padding: 24px max(22px, calc((100% - 820px) / 2)); scroll-behavior: smooth; }
.ai-welcome { display: grid; max-width: 560px; min-height: 100%; margin: auto; place-content: center; justify-items: center; text-align: center; }
.ai-welcome__mark { display: grid; width: 58px; height: 58px; margin-bottom: 14px; place-items: center; border-radius: 18px; background: var(--blue-soft); color: var(--blue); }
.ai-welcome__mark .sf-icon { width: 28px; height: 28px; }
.ai-welcome h2 { margin: 0; font-size: 26px; }
.ai-welcome p { max-width: 520px; margin: 10px 0 0; color: var(--secondary-label); line-height: 1.5; }
.ai-message { display: flex; margin: 0 0 18px; }
.ai-message--user { justify-content: flex-end; }
.ai-message--editable { align-items: flex-end; gap: 7px; }
.ai-message--edit-hidden { display: none; }
.ai-message__bubble { max-width: min(78%, 680px); padding: 11px 14px; border-radius: 18px; line-height: 1.48; overflow-wrap: anywhere; }
.ai-message__content { white-space: pre-wrap; }
.ai-message--assistant .ai-message__bubble { padding-left: 0; background: transparent; }
.ai-message--user .ai-message__bubble { border-bottom-right-radius: 5px; background: var(--blue); color: white; }
.ai-message__attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.ai-attachment-chip { display: inline-flex; max-width: 100%; align-items: center; gap: 6px; padding: 5px 8px; border: 1px solid var(--separator); border-radius: 999px; background: var(--surface-secondary); color: var(--secondary-label); font-size: 12px; }
.ai-message--user .ai-attachment-chip { border-color: rgb(255 255 255 / .4); background: rgb(255 255 255 / .14); color: white; }
.ai-message__edit { display: grid; width: 40px; height: 40px; flex: 0 0 40px; padding: 0; place-items: center; border: 0; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--blue); background: var(--surface); color: var(--blue); transition: background-color 140ms ease; }
.ai-message__edit:hover { background: var(--surface-secondary); }
.ai-message__edit:active { background: var(--surface-tertiary); }
.ai-message__edit .sf-icon { width: 20px; height: 20px; }
.ai-attachment-chip .sf-icon { width: 14px; height: 14px; flex: 0 0 auto; }
.ai-attachment-chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-composer { position: relative; width: min(820px, calc(100% - 44px)); margin: 0 auto 18px; padding: 8px 10px 7px; border: 1px solid var(--separator-strong); border-radius: 22px; background: var(--surface); box-shadow: 0 8px 30px rgb(0 0 0 / .08); }
.ai-composer__locked { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 2px 4px 9px; color: var(--secondary-label); font-size: 13px; line-height: 1.35; }
.ai-composer__locked .button { flex: 0 0 auto; min-height: 36px; }
.ai-composer--locked .ai-composer__row { opacity: .62; }
.ai-composer__edit-mode { display: flex; align-items: center; gap: 12px; padding: 2px 5px 8px; color: var(--secondary-label); font-size: 12px; font-weight: 600; }
.ai-composer__edit-mode[hidden] { display: none; }
.ai-composer.is-editing .ai-composer__edit-mode { min-height: 46px; padding-right: 48px; }
.ai-composer__attachments { display: flex; max-width: 100%; gap: 8px; overflow-x: auto; padding: 2px 4px 8px; overscroll-behavior-inline: contain; scrollbar-width: thin; }
.ai-composer-attachment { position: relative; display: grid; width: max-content; min-width: 164px; height: 58px; grid-template-columns: 44px max-content; align-items: center; gap: 9px; padding: 6px 32px 6px 6px; overflow: hidden; border: 1px solid var(--separator); border-radius: 13px; background: var(--surface-secondary); scroll-snap-align: start; }
.ai-composer-attachment--image { display: block; width: 62px; min-width: 62px; height: 62px; padding: 0; background: var(--surface-secondary); }
.ai-composer-attachment__preview { width: 100%; height: 100%; border-radius: 12px; object-fit: cover; }
.ai-composer-attachment__icon { position: relative; display: grid; width: 44px; height: 44px; grid-template-rows: 21px 8px; align-content: center; place-items: center; gap: 2px; border-radius: 9px; box-shadow: inset 0 0 0 1.5px var(--blue); background: var(--blue-soft); color: var(--blue); }
.ai-composer-attachment__icon .sf-icon { width: 21px; height: 21px; transform: translateY(-2px); }
.ai-composer-attachment__icon small { position: static; width: calc(100% - 6px); overflow: hidden; color: currentColor; font-size: 7px; font-weight: 750; letter-spacing: .025em; line-height: 8px; text-align: center; text-overflow: ellipsis; transform: translateY(-2px); white-space: nowrap; }
.ai-composer-attachment__icon--pdf { background: var(--red-soft); color: var(--red); }
.ai-composer-attachment__icon--document { background: var(--blue-soft); color: var(--blue); }
.ai-composer-attachment__icon--spreadsheet { background: var(--green-soft); color: var(--green); }
.ai-composer-attachment__icon--presentation { background: var(--orange-soft); color: var(--orange); }
.ai-composer-attachment__icon--archive { background: color-mix(in srgb, var(--purple) 13%, var(--surface)); color: var(--purple); }
.ai-composer-attachment__icon--data { background: color-mix(in srgb, var(--blue) 10%, var(--surface)); color: var(--blue); }
.ai-composer-attachment__icon--markdown, .ai-composer-attachment__icon--text { background: var(--surface-tertiary); color: var(--secondary-label); }
.ai-composer-attachment__name { overflow: hidden; color: var(--label); font-size: 12px; font-weight: 600; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.ai-composer-attachment__remove { position: absolute; top: 4px; right: 4px; display: grid; width: 24px; height: 24px; padding: 0; place-items: center; border: 0; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--blue); background: rgb(255 255 255 / .88); color: var(--blue); transition: background-color 140ms ease; }
.ai-composer-attachment__remove:hover { background: color-mix(in srgb, var(--blue) 10%, white); color: var(--blue); }
.ai-composer-attachment__remove:active { background: color-mix(in srgb, var(--blue) 18%, white); }
.ai-composer-attachment__remove::before, .ai-composer-attachment__remove::after { position: absolute; width: 10px; height: 1.5px; border-radius: 999px; background: currentColor; content: ""; }
.ai-composer-attachment__remove::before { transform: rotate(45deg); }
.ai-composer-attachment__remove::after { transform: rotate(-45deg); }
.ai-composer-attachment__remove .sf-icon { display: none; }
.ai-composer__row { display: grid; grid-template-columns: 38px minmax(0, 1fr) 38px; align-items: end; gap: 6px; }
.ai-composer textarea { width: 100%; min-height: 38px; max-height: 144px; resize: none; padding: 6px 5px; border: 0; outline: 0; background: transparent; color: var(--label); font: inherit; line-height: 26px; }
.ai-composer__submit-stack { display: flex; flex-direction: column; }
.ai-composer__attach, .ai-composer__cancel-edit, .ai-composer__send { width: 38px; height: 38px; min-height: 38px; border: 0; border-radius: 50%; }
.ai-composer__attach { display: grid; padding: 0; place-items: center; box-shadow: inset 0 0 0 1.5px var(--blue); background: var(--surface); color: var(--blue); line-height: 0; transition: background-color 140ms ease; }
.ai-composer__attach .sf-icon { display: block; width: 22px; height: 22px; stroke-width: 2.3; transform: translateY(-1px); }
.ai-composer__attach:hover { background: var(--surface-secondary); }
.ai-composer__attach:active { background: var(--surface-tertiary); }
.ai-composer__cancel-edit { position: absolute; top: 8px; right: 10px; z-index: 2; display: grid; padding: 0; place-items: center; box-shadow: inset 0 0 0 1.5px var(--red); background: var(--surface); color: var(--red); line-height: 0; transition: background-color 140ms ease; }
.ai-composer__cancel-edit[hidden] { display: none; }
.ai-composer__cancel-edit:hover { background: color-mix(in srgb, var(--red) 8%, var(--surface)); }
.ai-composer__cancel-edit:active { background: color-mix(in srgb, var(--red) 15%, var(--surface)); }
.ai-composer__cancel-edit .sf-icon { width: 18px; height: 18px; }
.ai-composer__send { background: var(--blue); color: white; }
.ai-composer__send:hover { background: color-mix(in srgb, var(--blue) 84%, black); }
.ai-composer__send:disabled { background: var(--fill); color: var(--tertiary-label); opacity: 1; }
.ai-composer :disabled { cursor: not-allowed; }
.ai-composer.is-processing { box-shadow: 0 8px 30px rgb(0 0 0 / .05); }
.ai-thinking { display: inline-flex; min-height: 28px; align-items: center; gap: 8px; color: var(--secondary-label); font-size: 14px; }
.ai-thinking > .sf-icon { width: 18px; height: 18px; color: var(--blue); animation: ai-thinking-pulse 1.8s ease-in-out infinite; }
.ai-thinking__text { transition: opacity 160ms ease; }
.ai-thinking__dots { display: inline-flex; align-items: center; gap: 3px; }
.ai-thinking__dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: ai-thinking-dot 1.2s ease-in-out infinite; opacity: .28; }
.ai-thinking__dots i:nth-child(2) { animation-delay: 140ms; }
.ai-thinking__dots i:nth-child(3) { animation-delay: 280ms; }
@keyframes ai-thinking-pulse { 0%, 100% { opacity: .55; transform: scale(.92); } 50% { opacity: 1; transform: scale(1); } }
@keyframes ai-thinking-dot { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: .9; transform: translateY(-2px); } }
.settings-dashboard > .panel { min-width: 0; }
.settings-card--profile, .settings-card--nutrition, .settings-card--application { display: flex; flex-direction: column; }
.nutrition-goals-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; margin-top: 16px; }
.profile-settings__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; margin-top: 16px; }
.profile-settings__metrics { display: grid; grid-column: 1 / -1; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; gap: 8px; }
.profile-settings__metric { min-width: 0; align-self: start; align-content: start; }
.profile-settings__metric output { display: flex; min-width: 0; height: 44px; min-height: 44px; align-items: center; padding: 10px 12px; border: 1px solid var(--separator-strong); border-radius: 11px; background: var(--surface-secondary); color: var(--label); font-size: 16px; }
.profile-settings__metric--action { align-self: start; padding-top: 22px; }
.profile-settings__metric--action .button { width: 100%; }
.profile-settings__walking-note { min-height: 18px; margin-top: 4px; color: var(--tertiary-label); font-size: 11px; }
.profile-settings__weight { grid-column: 1 / -1; }
.profile-weight-control { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 8px; }
.profile-weight-control output { display: flex; min-width: 0; min-height: 44px; align-items: center; padding: 10px 12px; border: 1px solid var(--separator-strong); border-radius: 11px; background: var(--surface-secondary); color: var(--label); font-size: 16px; }
.recent-weights { display: grid; gap: 5px; margin-top: 10px; }
.recent-weights > span { color: var(--secondary-label); font-size: 13px; }
.recent-weights table { width: 100%; border-collapse: collapse; font-size: 13px; }
.recent-weights td { padding: 5px 0; border-top: 1px solid var(--separator); }
.recent-weights td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.profile-settings__action { width: 200px; min-width: 200px; }
.settings-list { margin-top: 16px; border-top: 1px solid transparent; }
.setting-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(120px, 210px); min-height: 56px; align-items: center; gap: 16px; border-bottom: 1px solid transparent; }
.setting-row > label, .setting-row > span { color: var(--label); font-size: 15px; }
.setting-row input:not([type="checkbox"]), .setting-row select { width: 100%; }
.setting-row--theme { grid-template-columns: 1fr; align-items: start; gap: 8px; padding-block: 10px; }
.setting-row--theme .segmented { width: 100%; grid-auto-columns: minmax(0, 1fr); }
.switch { position: relative; display: grid; justify-self: end; width: 51px; height: 44px; place-items: center; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch span { display: block; width: 51px; height: 31px; border-radius: 99px; background: var(--surface-tertiary); transition: background 180ms ease; }
.switch span::after { display: block; width: 27px; height: 27px; margin: 2px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.25); content: ""; transition: transform 180ms ease; }
.switch input:checked + span { background: #34c759; }
.switch input:checked + span::after { transform: translateX(20px); }
body.keyboard-navigation .switch input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--focus) 70%, transparent); outline-offset: 2px; }
.settings-actions { display: flex; justify-content: flex-end; margin-top: auto; padding-top: 24px; }
.settings-actions.profile-settings__actions { justify-content: space-between; }

@supports (-webkit-touch-callout: none) {
  #profileBirthDate,
  html.platform-iphone #weightDate {
    display: block;
    width: 100%;
    min-width: 0;
    height: 44px;
    min-height: 44px;
    max-height: 44px;
    padding: 0;
    -webkit-appearance: none;
    appearance: none;
    line-height: 22px;
  }
  #profileBirthDate::-webkit-date-and-time-value,
  html.platform-iphone #weightDate::-webkit-date-and-time-value {
    height: 22px;
    min-height: 22px;
    margin: 0;
    padding: 10px 12px;
    text-align: left;
  }
}

.field { display: grid; min-width: 0; gap: 6px; color: var(--secondary-label); font-size: 13px; font-weight: 520; }
.field input, .field textarea, .field select, .form-control {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--separator-strong);
  border-radius: 11px;
  outline: 0;
  background: var(--surface);
  color: var(--label);
  font-size: 16px;
}
.field input:not([type="checkbox"]), .field select, .form-control { height: 44px; min-height: 44px; }
.field textarea { min-height: 92px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus, .form-control:focus { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent); }
.field [aria-invalid="true"] { border-color: var(--red); }
.field-error { color: var(--red); font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.field--wide { grid-column: 1 / -1; }
.nutrition-groups { display: grid; gap: 11px; margin-block: 0; }
.nutrition-panel { display: grid; gap: 11px; margin-block: 0; padding: 14px; border: 1px solid var(--separator); border-radius: 15px; background: var(--surface-secondary); }
.nutrition-panel .nutrition-groups { gap: 11px; margin-block: 0; }
.nutrition-subgroup { display: grid; gap: 11px; min-width: 0; }
.nutrition-subgroup + .nutrition-subgroup { padding-top: 11px; border-top: 1px solid var(--separator); }
.nutrition-subgroup.is-derived { opacity: .82; }
.nutrition-subgroup__header { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 12px; }
.nutrition-subgroup__header h3 { min-width: 0; font-size: 16px; overflow-wrap: anywhere; }
.nutrition-group { display: grid; gap: 14px; padding: 16px; border: 1px solid var(--separator); border-radius: 15px; background: var(--surface-secondary); }
.nutrition-group.is-derived { background: color-mix(in srgb, var(--surface-secondary) 64%, transparent); }
.nutrition-group__header { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 12px; }
.nutrition-group__header h3 { min-width: 0; font-size: 16px; overflow-wrap: anywhere; }
.macro-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.calculation-badge, .confidence-badge { flex: 0 0 auto; padding: 4px 8px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); font-size: 12px; font-weight: 650; }
.confidence-badge { background: var(--green-soft); color: var(--green); }
.piece-net-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.piece-net-fields[hidden] { display: none; }
.field-output { display: flex; min-height: 44px; align-items: center; padding: 10px 12px; border: 1px solid var(--separator-strong); border-radius: 11px; background: var(--surface); color: var(--label); font-size: 16px; }
.hydration-group { margin-block: 0; padding: 14px; gap: 11px; }
.nutrition-details summary { min-height: 44px; padding-block: 10px; color: var(--blue); cursor: pointer; font-size: 14px; font-weight: 600; }
.nutrition-details[open] summary { margin-bottom: 10px; }
.form-stack { display: grid; gap: 14px; }
.form-section { padding: 20px 0; border-bottom: 1px solid var(--separator); }
.form-section:first-child { padding-top: 8px; }
.form-section:last-child { border-bottom: 0; }
.form-section > h3 { margin-bottom: 14px; }
.section-header__actions { display: flex; flex: 0 0 auto; align-items: center; gap: 10px; }
.editor-list--nested { margin-top: 15px; }
.form-grid--water { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; }
.water-summary__item { min-width: 0; }
.water-summary__item .field-output { background: var(--surface-secondary); font-weight: 650; font-variant-numeric: tabular-nums; }
.activity-form { align-items: end; }
.activity-form textarea { min-height: 76px; }
.field input.is-calculated { background: var(--surface-secondary); font-weight: 650; font-variant-numeric: tabular-nums; }
.editor-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%; min-height: 62px; padding: 10px 12px; border: 1px solid var(--separator); border-radius: 13px; background: var(--surface); text-align: left; }
.editor-row__copy { min-width: 0; }
.editor-row__copy strong { display: block; font-size: 16px; overflow-wrap: break-word; }
.editor-row__copy span { display: block; margin-top: 3px; color: var(--secondary-label); font-size: 14px; overflow-wrap: break-word; }
.editor-row__value { color: var(--secondary-label); font-size: 14px; white-space: nowrap; }
.notice { padding: 12px 14px; border-radius: 12px; font-size: 14px; }
.notice--success { background: var(--green-soft); color: var(--green); }
.notice--warning { background: var(--orange-soft); color: var(--orange); }
.notice--error { background: var(--red-soft); color: var(--red); }

.modal-layer {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--scrim);
  overscroll-behavior: contain;
}
.modal-layer--nested { z-index: 90; }
.modal-layer--alert { z-index: 100; }
body.modal-open { overflow: hidden; }
.sheet {
  display: flex;
  width: min(100%, 760px);
  max-height: min(92dvh, 900px);
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--separator);
  border-radius: 22px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
}
.sheet--day { width: min(100%, 980px); }
.sheet--calendar { width: min(100%, 440px); padding-bottom: 14px; }
.sheet--item, .sheet--form { width: min(100%, 620px); }
.sheet--nutrition { width: min(100%, 720px); }
.sheet--activity { width: min(100%, 720px); }
.sheet--compact { width: min(100%, 460px); }
.iphone-section-switcher { display: none; }
.sheet__header {
  display: grid;
  grid-template-columns: minmax(64px, 1fr) auto minmax(64px, 1fr);
  min-height: 56px;
  align-items: center;
  gap: 8px;
  padding: 6px 11px;
  border-bottom: 1px solid var(--separator);
  background: var(--material);
  -webkit-backdrop-filter: saturate(160%) blur(22px);
  backdrop-filter: saturate(160%) blur(22px);
}
.sheet__header > :first-child { justify-self: start; }
.sheet__header > :last-child { justify-self: end; }
.sheet__header h2 { font-size: 17px; text-align: center; white-space: nowrap; }
.sheet__header p { margin: 0; color: var(--tertiary-label); font-size: 10px; font-weight: 650; letter-spacing: .06em; text-align: center; }
.sheet__header--sticky { position: sticky; z-index: 2; top: 0; }
.sheet__scroll { min-height: 0; padding: 18px 22px 24px; overflow: auto; overscroll-behavior: contain; }
.sheet__footer { display: flex; min-height: 64px; align-items: center; justify-content: flex-end; gap: 10px; padding: 9px 16px calc(9px + env(safe-area-inset-bottom)); border-top: 1px solid var(--separator); background: var(--material); }
.calendar__monthbar { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; padding: 10px 14px 4px; text-align: center; }
.calendar__monthbar strong { font-size: 17px; text-transform: capitalize; }
.calendar__weekdays, .calendar__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; margin-inline: 16px; }
.calendar__weekdays { padding: 8px 0 5px; color: var(--tertiary-label); font-size: 11px; font-weight: 650; text-align: center; }
.calendar__weekdays span { white-space: nowrap; }
.calendar__day, .calendar__spacer { aspect-ratio: 1; }
.calendar__day { position: relative; display: grid; min-width: 0; min-height: 0; place-items: center; border: 0; border-radius: 50%; background: transparent; box-shadow: inset 0 0 0 1px var(--separator-strong); font-size: 14px; }
.calendar__day:hover { background: var(--surface-secondary); }
.calendar__day.is-selected { background: var(--blue); box-shadow: none; color: #fff; }
.calendar__day.is-today:not(.is-selected) { box-shadow: inset 0 0 0 1.5px var(--blue); color: var(--blue); }
.calendar__day.is-unavailable,
.calendar__day.is-unavailable:hover {
  background: transparent;
  box-shadow: none;
  color: var(--tertiary-label);
  opacity: .48;
}
.score-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; }
.calendar__day .score-dot { position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%); }
.score-dot--good { background: var(--green); }
.score-dot--medium { background: var(--orange); }
.score-dot--low { background: var(--red); }
.calendar__legend { display: flex; justify-content: center; gap: 12px; padding: 13px 16px 0; color: var(--secondary-label); font-size: 11px; }
.calendar__legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.alert-sheet { width: min(100%, 390px); padding: 24px; border: 1px solid var(--separator); border-radius: 22px; background: var(--surface-raised); box-shadow: var(--shadow); text-align: center; }
.alert-sheet__icon { display: grid; width: 42px; height: 42px; place-items: center; margin: 0 auto 12px; border-radius: 50%; background: var(--orange-soft); color: var(--orange); }
.alert-sheet__icon--accent { background: var(--blue-soft); color: var(--blue); }
.alert-sheet h2 { margin: 0 0 14px; }
.alert-sheet p { margin: 0; color: var(--secondary-label); font-size: 14px; }
.alert-sheet p + p { margin-top: 6px; }
.alert-sheet .form-stack { text-align: left; }
.alert-sheet .form-stack .alert-sheet__actions { margin-top: 18px; }
.alert-sheet__actions { display: grid; width: 100%; margin: 20px auto 0; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.alert-sheet__actions--binary { width: min(100%, 226px); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.toast { position: fixed; z-index: 180; right: 20px; bottom: max(20px, env(safe-area-inset-bottom)); max-width: min(420px, calc(100vw - 32px)); padding: 11px 15px; transform: translateY(18px); border-radius: 12px; background: color-mix(in srgb, var(--label) 92%, transparent); box-shadow: var(--shadow); color: var(--surface); font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 180ms ease, transform 180ms ease; }
.toast.is-visible { transform: translateY(0); opacity: 1; }
.tabbar { display: none; }

@media (max-width: 1180px) {
  .overview-hero {
    grid-template-areas:
      "eaten eaten score score status status"
      "spent spent spent balance balance balance";
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  .grid--2 { grid-template-columns: 1fr; }
  .settings-dashboard {
    grid-template-areas:
      "profile"
      "password"
      "nutrition"
      "application"
      "passkeys"
      "sessions"
      "token";
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (min-width: 700px) and (max-width: 1023px) and (min-height: 501px) {
  .app-shell { display: grid; grid-template-columns: var(--sidebar-compact) minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--sidebar-compact);
    transform: none;
    transition: width 200ms ease;
  }
  .sidebar__brand { justify-content: center; padding-inline: 0; }
  .sidebar__brand-copy, .nav-item span:last-child, .sidebar__collapse-label { display: none; }
  .nav-item, .sidebar__collapse { justify-content: center; padding-inline: 0; }
  .sidebar__collapse { display: flex; }
  body.sidebar-open .sidebar { width: 252px; box-shadow: var(--shadow); }
  body.sidebar-open .sidebar__brand { justify-content: flex-start; padding-inline: 8px; }
  body.sidebar-open .sidebar__brand-copy,
  body.sidebar-open .nav-item span:last-child,
  body.sidebar-open .sidebar__collapse-label { display: block; }
  body.sidebar-open .nav-item,
  body.sidebar-open .sidebar__collapse { justify-content: flex-start; padding-inline: 12px; }
  body.sidebar-open .sidebar-scrim { position: fixed; z-index: 35; inset: 0; display: block; width: 100%; height: 100%; border: 0; background: var(--scrim); }
  .main { grid-column: 2; padding-inline: 26px; }
  .topbar { gap: 8px; margin-inline: -26px; padding: 7px 10px 7px 8px; }
  .topbar .page-heading h1 { font-size: 26px; }
  .topbar .date-control { padding-inline: 8px; }
  .topbar .date-control__chevron { display: none; }
  .topbar .topbar__action { padding-inline: 11px; }
  .export-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-grid--analytics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .import-source__controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .import-source__status { grid-column: 1; }
  .import-source__preview { grid-column: 2; }
}

@media (max-width: 699px), (orientation: landscape) and (max-height: 500px) and (hover: none) and (pointer: coarse) {
  :root {
    --topbar-height: 54px;
    --mobile-content-left: max(14px, env(safe-area-inset-left));
    --mobile-content-right: max(14px, env(safe-area-inset-right));
  }
  body { font-size: 16px; }
  .ai-message__edit { width: 44px; height: 44px; flex-basis: 44px; }
  .app-shell { display: block; }
  .sidebar, .sidebar-scrim { display: none !important; }
  .main {
    padding: 0 var(--mobile-content-right) calc(var(--tabbar-height) + 24px + env(safe-area-inset-bottom)) var(--mobile-content-left);
  }
  body.view-ai .main {
    padding-bottom: calc(var(--tabbar-height) + 10px + env(safe-area-inset-bottom));
  }
  body.pwa-standalone .main { padding-bottom: calc(var(--tabbar-height) + 28px + env(safe-area-inset-bottom)); }
  body.view-ai.pwa-standalone .main {
    padding-bottom: calc(var(--tabbar-height) + 10px + env(safe-area-inset-bottom));
  }
  .topbar {
    top: 0;
    display: grid;
    grid-template-areas: "heading date action";
    grid-template-columns: minmax(0, 1fr) auto auto;
    min-height: calc(var(--topbar-height) + env(safe-area-inset-top));
    margin-top: 0;
    margin-right: calc(var(--mobile-content-right) * -1);
    margin-left: calc(var(--mobile-content-left) * -1);
    padding: calc(5px + env(safe-area-inset-top)) var(--mobile-content-right) 5px var(--mobile-content-left);
    background: var(--background);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .topbar .page-heading { min-width: 0; grid-area: heading; align-self: center; padding: 0 2px; }
  .topbar .topbar__spacer { display: none; }
  .topbar.has-catalog-search::after {
    position: absolute;
    z-index: 0;
    top: 100%;
    right: 0;
    left: 0;
    height: 52px;
    background: var(--background);
    content: "";
    pointer-events: none;
  }
  .topbar.has-catalog-search > * { position: relative; z-index: 1; }
  .topbar.has-catalog-search .topbar__spacer {
    position: absolute;
    z-index: 1;
    top: calc(100% + 4px);
    right: var(--mobile-content-right);
    left: var(--mobile-content-left);
    display: flex;
    width: auto;
    min-width: 0;
  }
  .topbar .date-control { grid-area: date; justify-self: end; }
  .topbar .topbar__action { grid-area: action; }
  .icon-button.topbar__menu { display: none; }
  .date-control { max-width: 100%; padding-inline: 9px; }
  .date-text--full { display: none; }
  .date-text--mobile { display: inline; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar__action { width: 44px; padding: 0; }
  .topbar__action span:last-child { display: none; }
  .page-heading h1 { overflow: hidden; font-size: 20px; letter-spacing: -.02em; text-overflow: ellipsis; white-space: nowrap; }
  .page-heading__eyebrow { display: none; }
  .panel { padding: 17px; }
  .ai-page {
    height: calc(100dvh - var(--topbar-height) - var(--tabbar-height) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 10px);
    min-height: 420px;
    margin-right: calc(var(--mobile-content-right) * -1);
    margin-left: calc(var(--mobile-content-left) * -1);
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .ai-page__header { padding: 10px var(--mobile-content-right) 9px var(--mobile-content-left); }
  .ai-page__header .eyebrow { display: none; }
  .ai-page__header h2 { margin: 0; font-size: 16px; }
  .ai-conversation { padding: 18px var(--mobile-content-right) 12px var(--mobile-content-left); }
  .ai-welcome h2 { font-size: 23px; }
  .ai-welcome p { font-size: 14px; }
  .ai-message__bubble { max-width: 88%; }
  .ai-composer { width: calc(100% - var(--mobile-content-left) - var(--mobile-content-right)); margin-bottom: 10px; }
  .ai-composer__locked { align-items: stretch; flex-direction: column; }
  .ai-composer__locked .button { width: 100%; min-height: 44px; }
  .ai-composer__row { grid-template-columns: 44px minmax(0, 1fr) 44px; }
  .ai-composer__attach, .ai-composer__cancel-edit, .ai-composer__send { width: 44px; height: 44px; min-height: 44px; }
  .ai-composer textarea { min-height: 44px; padding-block: 9px; }
  .ai-composer__attachments { margin-inline: -2px; padding-bottom: 8px; scroll-snap-type: inline proximity; }
  .ai-composer-attachment:not(.ai-composer-attachment--image) { width: max-content; min-width: 154px; }
  html.platform-iphone .ai-message__edit { width: 36px; height: 36px; flex-basis: 36px; }
  html.platform-iphone .ai-message__edit .sf-icon { width: 17px; height: 17px; }
  html.platform-iphone .ai-composer { padding-right: 8px; padding-left: 8px; }
  html.platform-iphone .ai-composer__row { grid-template-columns: 36px minmax(0, 1fr) 36px; gap: 4px; }
  html.platform-iphone .ai-composer__attach,
  html.platform-iphone .ai-composer__cancel-edit,
  html.platform-iphone .ai-composer__send { width: 36px; height: 36px; min-height: 36px; }
  html.platform-iphone .ai-composer__attach::after,
  html.platform-iphone .ai-composer__cancel-edit::after,
  html.platform-iphone .ai-composer__send::after,
  html.platform-iphone .ai-message__edit::after { position: absolute; inset: -4px; content: ""; }
  html.platform-iphone .ai-composer__attach,
  html.platform-iphone .ai-composer__cancel-edit,
  html.platform-iphone .ai-composer__send,
  html.platform-iphone .ai-message__edit { position: relative; }
  html.platform-iphone .ai-composer__cancel-edit { position: absolute; top: 7px; right: 8px; }
  html.platform-iphone .ai-composer.is-editing .ai-composer__edit-mode { min-height: 44px; padding-right: 44px; }
  html.platform-iphone .ai-composer__attach .sf-icon { width: 19px; height: 19px; }
  html.platform-iphone .ai-composer__cancel-edit .sf-icon,
  html.platform-iphone .ai-composer__send .sf-icon { width: 16px; height: 16px; }
  html.platform-iphone .ai-composer textarea { min-height: 36px; padding: 5px 4px; line-height: 26px; }
  .stack, .grid { gap: 16px; }
  .overview-hero {
    grid-template-areas:
      "eaten score"
      "spent balance"
      "status status";
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }
  .calorie-card { min-height: 112px; padding: 13px 12px; }
  .calorie-card__value { font-size: 27px; }
  .calorie-card__unit { font-size: 12px; }
  .progress-ring { width: 58px; height: 58px; }
  .progress-ring strong { font-size: 12px; }
  .metric-card { min-height: 112px; padding: 13px 12px; }
  .metric-card span { font-size: 11px; letter-spacing: .035em; }
  .metric-card strong { margin-top: 7px; font-size: 23px; }
  .metric-card small { font-size: 13px; }
  .overview-kpi--status {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-content: center;
    align-items: center;
  }
  .overview-kpi--status > span { grid-column: 1; grid-row: 1; }
  .overview-kpi--status > strong { grid-column: 1; grid-row: 2; }
  .overview-kpi--status .status-card__actions { grid-column: 2; grid-row: 1 / 3; margin-top: 0; }
  .overview-kpi--status .status-card__actions .button { min-height: 44px; }
  .status-card__actions .button { min-height: 40px; padding-inline: 8px; font-size: 13px; }
  .day-status { align-items: flex-start; flex-direction: column; padding: 15px; }
  .day-status__actions { width: 100%; }
  .day-status__actions .button { flex: 1; }
  .grid--2, .grid--3 { grid-template-columns: 1fr; }
  .panel__header { flex-wrap: wrap; }
  .catalog-header .segmented { width: 100%; height: 44px; flex: 1 0 100%; grid-auto-columns: minmax(0, 1fr); }
  .catalog-header .segmented button { min-height: 40px; }
  html.platform-iphone .iphone-section-switcher {
    display: grid;
    width: 100%;
    height: 44px;
    margin-bottom: 16px;
    grid-auto-columns: minmax(0, 1fr);
  }
  html.platform-iphone .iphone-section-switcher button { min-width: 0; min-height: 40px; padding-inline: 8px; overflow: hidden; text-overflow: ellipsis; }
  .macro-row { grid-template-columns: 70px 1fr; }
  .macro-row strong { text-align: right; }
  .macro-row .progress-track { grid-column: 1 / -1; }
  .activity-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .activity-tile { min-height: 104px; padding: 8px; }
  .activity-tile .sf-icon { width: 21px; height: 21px; }
  .activity-tile strong { font-size: 14px; }
  .activity-tile__detail { font-size: 11px; }
  .desktop-table { display: none; }
  .mobile-list { display: grid; gap: 10px; }
  .catalog-mobile-list { gap: 0; }
  .searchbar-anchor { position: relative; top: auto; margin-inline: 0; }
  .stats-grid { gap: 12px; }
  .import-preview .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 12px 10px; }
  .stat span { font-size: 13px; }
  .stat strong { font-size: 18px; }
  .chart-svg { height: 220px; }
  .export-grid { grid-template-columns: 1fr; gap: 12px; }
  .export-card { min-height: 104px; padding: 13px; }
  .report-scopes { display: grid; grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-period { grid-template-columns: 1fr; }
  .report-preview { align-items: flex-start; flex-direction: column; }
  .report-preview span { text-align: left; }
  .stats-grid--analytics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .import-source__controls { grid-template-columns: 1fr; }
  .import-source__button, .import-source__status, .import-source__preview { width: 100%; grid-column: 1; }
  .profile-settings__grid, .profile-settings__metrics { grid-template-columns: 1fr; }
  .profile-settings__metric--action { padding-top: 0; }
  .nutrition-goals-grid { grid-template-columns: 1fr; }
  .profile-weight-control { grid-template-columns: 1fr; }
  .profile-settings__action { width: 100%; min-width: 0; }
  .setting-row { grid-template-columns: minmax(0, 1fr) minmax(112px, 48%); }
  .setting-row--source { grid-template-columns: 1fr; align-items: start; gap: 8px; padding-block: 10px; }
  .setting-row--theme { grid-template-columns: 1fr; }
  .settings-actions .button { width: 100%; }
  .profile-settings__actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .profile-settings__actions .button { padding-inline: 6px; font-size: 12px; }
  html.platform-iphone .settings-card--password .security-form .button { width: 100%; }
  html.platform-iphone .settings-card--passkeys .security-row > .button,
  html.platform-iphone .settings-card--sessions .security-row > .button,
  html.platform-iphone .settings-card--token .security-row > .button {
    width: auto;
    min-width: 44px;
    align-self: flex-end;
  }
  html.platform-iphone .settings-card--token .security-row__actions {
    width: 100%;
    align-self: stretch;
    flex-wrap: nowrap;
    justify-content: flex-end;
  }
  html.platform-iphone .settings-card--token .security-row__actions .button { width: auto; flex: 0 0 auto; }
  .form-grid, .form-grid--summary { grid-template-columns: 1fr; }
  .macro-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .piece-net-fields { grid-template-columns: 1fr; }
  .field--wide { grid-column: auto; }
  .form-section { padding-block: 17px; }
  .section-header { align-items: center; }
  .section-header p { display: none; }
  .section-header__actions { max-width: 55%; }
  .form-grid--water { grid-template-columns: 1fr; }
  .modal-layer { align-items: end; padding: 0; }
  .sheet {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - env(safe-area-inset-top));
    border-width: 1px 0 0;
    border-radius: 20px 20px 0 0;
  }
  .sheet--day, .sheet--item, .sheet--form {
    height: calc(100dvh - env(safe-area-inset-top));
    max-height: none;
    border-top: 0;
    border-radius: 0;
  }
  .sheet__header { padding-top: 6px; }
  .sheet--day .sheet__header, .sheet--item .sheet__header, .sheet--form .sheet__header { padding-top: calc(6px + env(safe-area-inset-top)); }
  .sheet__scroll { padding: 15px 16px 22px; }
  .sheet__footer { padding-bottom: calc(9px + env(safe-area-inset-bottom)); }
  .sheet__footer .button { flex: 1; }
  .sheet--calendar { width: 100%; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .alert-sheet { margin: 12px; }
  .tabbar {
    position: fixed;
    z-index: 50;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(var(--tab-count, 5), minmax(0, 1fr));
    min-height: var(--tabbar-height);
    padding: 4px 5px 5px;
    border-top: 0;
    background: var(--background);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .tabbar {
    padding-right: max(5px, env(safe-area-inset-right));
    padding-bottom: max(5px, env(safe-area-inset-bottom));
    padding-left: max(5px, env(safe-area-inset-left));
  }
  body.keyboard-open .tabbar { display: none; }
  .tabbar button { display: grid; min-width: 0; min-height: 49px; place-items: center; align-content: center; gap: 2px; padding: 2px 1px; color: var(--secondary-label); font-size: 10px; font-weight: 540; white-space: nowrap; }
  .tabbar button .sf-icon { width: 23px; height: 23px; }
  .tabbar button[aria-current="page"] { color: var(--blue); }
  .toast { right: 12px; bottom: calc(var(--tabbar-height) + 14px + env(safe-area-inset-bottom)); left: 12px; max-width: none; text-align: center; }
  body.pwa-standalone .toast { bottom: calc(var(--tabbar-height) + 14px + env(safe-area-inset-bottom)); }
  .connection-banner, .update-banner { top: calc(env(safe-area-inset-top) + 6px); font-size: 13px; }
}

@media (max-width: 374px) {
  :root {
    --mobile-content-left: max(10px, env(safe-area-inset-left));
    --mobile-content-right: max(10px, env(safe-area-inset-right));
  }
  .main { padding-right: var(--mobile-content-right); padding-left: var(--mobile-content-left); }
  .topbar {
    margin-right: calc(var(--mobile-content-right) * -1);
    margin-left: calc(var(--mobile-content-left) * -1);
    padding-right: var(--mobile-content-right);
    padding-left: var(--mobile-content-left);
  }
  .date-control { max-width: calc(100vw - 106px); font-size: 14px; }
  .topbar__action { padding-inline: 9px; font-size: 14px; }
  .overview-kpi { min-height: 121px; }
  .calorie-card { padding: 15px; }
  .progress-ring { width: 54px; height: 54px; }
  .metric-card { padding-inline: 7px; }
  .metric-card strong { font-size: 21px; }
  .activity-tile { padding-inline: 8px; }
  .activity-grid { grid-template-columns: 1fr; }
  .activity-tile { display: grid; min-height: 78px; align-items: center; grid-template-columns: 28px minmax(0, 1fr) auto; text-align: left; }
  .activity-tile .sf-icon { grid-row: 1 / 3; }
  .activity-tile strong { margin-top: 0; }
  .activity-tile__detail { grid-column: 2 / -1; }
  .calendar__weekdays, .calendar__grid { gap: 0; margin-inline: 6px; }
  .tabbar { padding-inline: 1px; }
  .tabbar button { font-size: 10px; }
  .alert-sheet__actions:not(.alert-sheet__actions--binary) { width: 100%; grid-template-columns: 1fr; }
  .macro-grid { grid-template-columns: 1fr; }
}

@media (orientation: landscape) and (max-height: 500px) and (hover: none) and (pointer: coarse) {
  :root { --topbar-height: 48px; --tabbar-height: 54px; }
  .topbar {
    min-height: calc(var(--topbar-height) + env(safe-area-inset-top));
    grid-template-columns: minmax(68px, 1fr) minmax(0, auto) 44px;
    gap: 6px;
  }
  .date-control { max-width: min(44vw, 220px); }
  .page-heading { padding-block: 0; }
  .page-heading h1 { font-size: 20px; }
  .overview-hero {
    grid-template-areas: "eaten spent score balance status";
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
  }
  .overview-kpi--status {
    display: flex;
    align-items: stretch;
    flex-direction: column;
  }
  .overview-kpi--status > span,
  .overview-kpi--status > strong,
  .overview-kpi--status .status-card__actions { grid-column: auto; grid-row: auto; }
  .overview-kpi--status > strong { font-size: 20px; white-space: normal; }
  .overview-kpi--status .status-card__actions { width: 100%; margin-top: auto; }
  .overview-kpi--status.status-card--closed .status-card__actions { display: grid; grid-template-columns: 1fr; }
  .overview-kpi--status .status-card__actions .button { width: 100%; min-width: 0; padding-inline: 6px; }
  .overview-kpi--status .status-card__actions .button { min-height: 38px; }
  .tabbar button { grid-auto-flow: column; gap: 5px; min-height: 44px; }
  .tabbar button .sf-icon { width: 20px; height: 20px; }
  .sheet--day, .sheet--item, .sheet--form { height: 100dvh; }
  .sheet__header {
    padding-right: max(11px, env(safe-area-inset-right));
    padding-left: max(11px, env(safe-area-inset-left));
  }
  .sheet__scroll {
    padding-right: max(16px, env(safe-area-inset-right));
    padding-left: max(16px, env(safe-area-inset-left));
  }
  .sheet__footer {
    padding-right: max(16px, env(safe-area-inset-right));
    padding-left: max(16px, env(safe-area-inset-left));
  }
}

@media (max-width: 760px) and (orientation: landscape) and (max-height: 500px) and (hover: none) and (pointer: coarse) {
  .overview-hero {
    grid-template-areas:
      "eaten eaten score score status status"
      "spent spent spent balance balance balance";
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
}

@media (prefers-reduced-transparency: reduce) {
  .sidebar, .topbar, .sheet__header, .sheet__footer, .connection-banner, .update-banner { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

@media (max-width: 699px), (orientation: landscape) and (max-height: 500px) and (hover: none) and (pointer: coarse) {
  .topbar, .tabbar { background: var(--background); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

@media (forced-colors: active) {
  .sf-icon { background: currentColor; }
  .panel, .metric-card, .calorie-card, .list-row, .editor-row { border: 1px solid CanvasText; }
}
