/* MacroLog — local-first macro tracker */

:root {
  color-scheme: dark;
  --bg: #080b10;
  --bg-soft: #0b1017;
  --surface: #111823;
  --surface-2: #172130;
  --surface-3: #1e2a3a;
  --border: #223044;
  --border-strong: #33465e;
  --fg: #edf3f9;
  --muted: #93a4b8;
  --muted-2: #67788d;
  --accent: #4ade80;
  --accent-soft: rgba(74, 222, 128, 0.14);
  --accent-ink: #04170b;
  --protein: #60a5fa;
  --protein-soft: rgba(96, 165, 250, 0.14);
  --carbs: #fbbf24;
  --carbs-soft: rgba(251, 191, 36, 0.14);
  --fat: #fb7185;
  --fat-soft: rgba(251, 113, 133, 0.14);
  --warning: #fb923c;
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.22);
  --radius: 20px;
  --radius-sm: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f3f5f8;
    --bg-soft: #eef2f6;
    --surface: #ffffff;
    --surface-2: #f7f9fc;
    --surface-3: #eef2f7;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --fg: #0f172a;
    --muted: #52627a;
    --muted-2: #7c8aa0;
    --accent: #15803d;
    --accent-soft: #dcfce7;
    --accent-ink: #ffffff;
    --protein: #2563eb;
    --protein-soft: #dbeafe;
    --carbs: #d97706;
    --carbs-soft: #fef3c7;
    --fat: #e11d48;
    --fat-soft: #ffe4e6;
    --warning: #ea580c;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --shadow: 0 18px 50px rgba(15, 23, 42, 0.1);
    --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.06);
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5f8;
  --bg-soft: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f7;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --fg: #0f172a;
  --muted: #52627a;
  --muted-2: #7c8aa0;
  --accent: #15803d;
  --accent-soft: #dcfce7;
  --accent-ink: #ffffff;
  --protein: #2563eb;
  --protein-soft: #dbeafe;
  --carbs: #d97706;
  --carbs-soft: #fef3c7;
  --fat: #e11d48;
  --fat-soft: #ffe4e6;
  --warning: #ea580c;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.1);
  --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 600px at 85% -15%, var(--accent-soft), transparent 60%),
    var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.sheet-open,
body.onboarding-open {
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.08) 100%);
  z-index: -1;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.55rem, 4vw, 2rem);
  letter-spacing: -0.035em;
  line-height: 1.1;
}

h2 {
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

h3 {
  font-size: 1rem;
  letter-spacing: -0.01em;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
}

a {
  color: var(--accent);
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
}

/* ---- Layout --------------------------------------------------------------- */

.app-shell {
  max-width: 940px;
  margin: 0 auto;
  padding: 0 16px calc(96px + env(safe-area-inset-bottom));
}

.main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 18px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  margin: 0 -16px;
  padding: 0 16px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-bottom: 1px solid transparent;
}

.topbar-inner {
  max-width: 908px;
  margin: 0 auto;
  height: 62px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--fg);
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.025em;
}

.brand-mark {
  display: inline-flex;
  width: 30px;
  height: 30px;
  color: var(--fg);
}

.brand-mark svg {
  width: 100%;
  height: 100%;
}

.brand-mark.is-large {
  width: 52px;
  height: 52px;
}

.topnav {
  display: none;
  margin-left: auto;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.topnav button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 600;
  transition: background 160ms ease, color 160ms ease;
}

.topnav button .icon {
  width: 16px;
  height: 16px;
}

.topnav button:hover {
  color: var(--fg);
}

.topnav button.is-active {
  background: var(--surface-3);
  color: var(--fg);
}

.net-status {
  margin-left: auto;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.bottom-nav {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 640px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.bottom-nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 2px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--muted-2);
  font-size: 0.65rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.bottom-nav button .icon {
  width: 22px;
  height: 22px;
}

.bottom-nav button.is-active {
  color: var(--accent);
}

/* ---- Common --------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 8px 2px 2px;
}

.page-head p {
  color: var(--muted);
  font-size: 0.86rem;
  margin-top: 3px;
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.muted-small {
  color: var(--muted-2);
  font-size: 0.78rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 650;
  white-space: nowrap;
}

.pill-accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.pill-muted {
  background: var(--surface-2);
  color: var(--muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 15px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--fg);
  font-size: 0.87rem;
  font-weight: 650;
  line-height: 1.1;
  transition: transform 120ms ease, filter 120ms ease, background 160ms ease;
}

.btn:hover {
  filter: brightness(1.08);
}

.btn:active {
  transform: translateY(1px);
}

.btn .icon {
  width: 18px;
  height: 18px;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

.btn-outline {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--fg);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger-ghost {
  border-color: color-mix(in srgb, var(--danger) 32%, transparent);
  background: transparent;
  color: var(--danger);
}

.btn-lg {
  width: 100%;
  padding: 13px 18px;
  font-size: 0.94rem;
  border-radius: 14px;
}

.btn-small {
  padding: 7px 11px;
  font-size: 0.78rem;
  border-radius: 10px;
}

.btn-small .icon {
  width: 16px;
  height: 16px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted);
  flex: none;
}

.icon-btn:hover {
  color: var(--fg);
}

.icon-btn-accent {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
}

.icon-btn-small {
  width: 32px;
  height: 32px;
  border-radius: 9px;
}

.icon-btn-small .icon {
  width: 16px;
  height: 16px;
}

.icon-btn.is-fav {
  color: var(--carbs);
  background: var(--carbs-soft);
  border-color: transparent;
}

.icon-btn.is-fav .icon {
  fill: currentColor;
}

.danger {
  color: var(--danger);
}

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 650;
}

.text-btn .icon {
  width: 15px;
  height: 15px;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
  white-space: nowrap;
}

.chip.is-active {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
}

.chip-strong {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

.chip .icon {
  width: 14px;
  height: 14px;
}

.segmented {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
}

.segmented button {
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
}

.segmented button.is-active {
  background: var(--surface-3);
  color: var(--fg);
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}

.dot-p {
  background: var(--protein);
}

.dot-c {
  background: var(--carbs);
}

.dot-f {
  background: var(--fat);
}

.macro-mini {
  display: inline-flex;
  gap: 9px;
  color: var(--muted-2);
  font-size: 0.72rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.macro-mini span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.macro-mini .dot {
  width: 5px;
  height: 5px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
}

.field input,
.field select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--fg);
  font-size: 0.9rem;
  font-weight: 500;
  transition: border-color 140ms ease, background 140ms ease;
}

.field input:hover,
.field select:hover {
  border-color: var(--border-strong);
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.field input::placeholder {
  color: var(--muted-2);
}

.field-grid {
  display: grid;
  gap: 12px;
}

.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field-grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.optional {
  color: var(--muted-2);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.form-note {
  color: var(--muted-2);
  font-size: 0.75rem;
  line-height: 1.4;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--fg);
  font-size: 0.84rem;
  font-weight: 550;
}

.check-row input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.search-field {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--muted);
}

.search-field:focus-within {
  border-color: var(--accent);
  background: var(--surface);
}

.search-field .icon {
  width: 18px;
  height: 18px;
}

.search-field input {
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--fg);
  font-size: 0.88rem;
}

.search-field input::placeholder {
  color: var(--muted-2);
}

.filter-chips {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.filter-chips.compact {
  gap: 6px;
}

/* ---- Today ---------------------------------------------------------------- */

.date-bar {
  position: relative;
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  gap: 8px;
  padding: 2px;
}

.date-label {
  border: 0;
  background: none;
  color: var(--fg);
  text-align: center;
  min-width: 0;
}

.date-label .eyebrow {
  margin-bottom: 1px;
}

.date-label strong {
  display: block;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.today-chip {
  position: absolute;
  right: 0;
  top: calc(100% + 5px);
  transform: none;
  padding: 3px 8px;
  font-size: 0.68rem;
}

.summary-card {
  padding: 20px;
  background:
    radial-gradient(500px 220px at 0% 0%, var(--accent-soft), transparent 70%),
    var(--surface);
}

.summary-top {
  display: flex;
  align-items: center;
  gap: 22px;
}

.ring-wrap {
  position: relative;
  width: 158px;
  height: 158px;
  flex: none;
}

.ring {
  width: 100%;
  height: 100%;
  display: block;
}

.ring-track {
  stroke: var(--surface-3);
}

.ring-value {
  stroke: var(--accent);
  transition: stroke-dashoffset 500ms cubic-bezier(0.16, 1, 0.3, 1);
}

.ring-value.is-over {
  stroke: var(--warning);
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}

.ring-center strong {
  font-size: 2rem;
  line-height: 1;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
}

.ring-center span {
  color: var(--muted);
  font-size: 0.68rem;
}

.summary-right {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.remaining-block {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.remaining-block > span:first-child {
  width: 100%;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
}

.remaining-block strong {
  font-size: 1.9rem;
  line-height: 1;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
}

.remaining-block > span:last-child {
  color: var(--muted);
  font-size: 0.76rem;
}

.remaining-block.is-over strong {
  color: var(--warning);
}

.summary-meta {
  display: flex;
  gap: 12px;
  color: var(--muted-2);
  font-size: 0.73rem;
}

.basis-pill {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  max-width: 100%;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.69rem;
  text-align: left;
  line-height: 1.3;
}

.basis-pill .icon {
  width: 14px;
  height: 14px;
  margin-top: 1px;
  color: var(--accent);
}

.basis-pill span {
  flex: 1;
  min-width: 0;
}

.basis-pill .icon:last-child {
  width: 12px;
  height: 12px;
  margin-left: auto;
  margin-top: 2px;
}

.macro-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
  padding-top: 17px;
  border-top: 1px solid var(--border);
}

.macro-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.macro-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.79rem;
}

.macro-head > span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-weight: 600;
}

.macro-head strong {
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.macro-head em {
  color: var(--muted-2);
  font-style: normal;
  font-weight: 500;
}

.macro-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.macro-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 450ms cubic-bezier(0.16, 1, 0.3, 1);
}

.macro-fill.p {
  background: var(--protein);
}

.macro-fill.c {
  background: var(--carbs);
}

.macro-fill.f {
  background: var(--fat);
}

.macro-fill.is-over {
  background: var(--warning);
}

.quick-actions {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 10px;
}

.weight-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 17px;
}

.weight-strip-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.weight-value {
  display: flex;
  align-items: center;
  gap: 8px;
}

.weight-value strong {
  font-size: 1.22rem;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px 0;
}

.section-head h2 {
  font-size: 1rem;
}

.meals {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.meal-card {
  padding: 15px 16px;
}

.meal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.meal-head h3 {
  font-size: 0.94rem;
}

.meal-head span {
  display: block;
  margin-top: 1px;
  color: var(--muted-2);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.meal-head .icon-btn {
  width: 34px;
  height: 34px;
}

.entry-list {
  display: flex;
  flex-direction: column;
  margin-top: 10px;
  border-top: 1px solid var(--border);
}

.entry-row {
  display: flex;
  align-items: stretch;
  gap: 4px;
  border-bottom: 1px solid var(--border);
}

.entry-row:last-child {
  border-bottom: 0;
}

.entry-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 11px 4px 11px 0;
  border: 0;
  background: none;
  text-align: left;
  color: var(--fg);
}

.entry-name {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.87rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fav-mark .icon {
  width: 12px;
  height: 12px;
  fill: var(--carbs);
  stroke: var(--carbs);
}

.entry-sub {
  color: var(--muted-2);
  font-size: 0.73rem;
}

.entry-side {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: none;
}

.entry-kcal {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 0.86rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.entry-kcal em {
  color: var(--muted-2);
  font-size: 0.62rem;
  font-style: normal;
  font-weight: 500;
}

.entry-side .icon-btn {
  width: 28px;
  height: 28px;
  border-color: transparent;
  background: transparent;
  opacity: 0.6;
}

.entry-side .icon-btn:hover {
  opacity: 1;
  background: var(--danger-soft);
}

.meal-empty {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: transparent;
  color: var(--muted-2);
  font-size: 0.77rem;
  font-weight: 600;
}

.meal-empty:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.meal-empty .icon {
  width: 13px;
  height: 13px;
  vertical-align: -2px;
}

/* ---- Insights ------------------------------------------------------------- */

.insight-hero {
  position: relative;
  overflow: hidden;
  padding: 20px;
  background:
    radial-gradient(420px 240px at 100% 0%, var(--accent-soft), transparent 70%),
    var(--surface);
}

.insight-hero.is-learning {
  background:
    radial-gradient(420px 240px at 100% 0%, var(--protein-soft), transparent 70%),
    var(--surface);
}

.insight-hero-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
}

.hero-number {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: clamp(2.1rem, 7vw, 3rem);
  font-weight: 750;
  line-height: 1;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
}

.hero-number span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0;
}

.insight-hero p {
  max-width: 60ch;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--muted-2);
  font-size: 0.72rem;
}

.learning-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.learning-row > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.72rem;
}

.learning-row strong {
  color: var(--fg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.learning-bar {
  height: 4px;
  margin-top: 4px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.learning-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--protein);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 15px;
}

.stat-card strong {
  font-size: 1.3rem;
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat-card strong em {
  margin-left: 3px;
  color: var(--muted-2);
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0;
}

.stat-card strong.warn {
  color: var(--warning);
}

.stat-sub {
  color: var(--muted-2);
  font-size: 0.72rem;
}

.chart-card {
  padding: 16px 15px 11px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-head p {
  margin-top: 2px;
  color: var(--muted-2);
  font-size: 0.73rem;
}

.chart {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart-axis {
  fill: var(--muted-2);
  font-size: 10px;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
}

.chart-unit {
  fill: var(--muted-2);
  font-size: 10px;
  font-family: var(--font);
  font-weight: 600;
}

.chart-trend {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.chart-dot {
  fill: var(--surface);
  stroke: var(--protein);
  stroke-width: 1.6;
  vector-effect: non-scaling-stroke;
}

.chart-bar {
  fill: var(--accent);
  opacity: 0.82;
}

.chart-bar.is-over {
  fill: var(--warning);
  opacity: 0.9;
}

.chart-miss {
  fill: var(--border-strong);
}

.chart-target {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 3 5;
  opacity: 0.7;
  vector-effect: non-scaling-stroke;
}

.chart-target-label {
  fill: var(--muted);
  font-size: 9px;
}

.chart-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 13px;
  margin-top: 7px;
  color: var(--muted-2);
  font-size: 0.69rem;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.legend-dot.trend {
  background: var(--accent);
}

.legend-dot.raw {
  background: var(--protein);
}

.legend-dot.bar {
  background: var(--accent);
}

.legend-dot.miss {
  background: var(--border-strong);
}

.legend-dot.target {
  height: 2px;
  width: 10px;
  border-radius: 0;
  background: var(--muted);
}

.legend-latest {
  margin-left: auto;
  color: var(--muted);
}

.empty-chart {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 4px 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.macro-avg-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 4px 0 14px;
}

.macro-avg-row > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.macro-avg-row span {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.72rem;
}

.macro-avg-row strong {
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.split {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-3);
}

.split span {
  display: block;
  height: 100%;
}

.split-p {
  background: var(--protein);
}

.split-c {
  background: var(--carbs);
}

.split-f {
  background: var(--fat);
}

.split-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 8px;
  color: var(--muted-2);
  font-size: 0.7rem;
}

.split-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.table-wrap {
  overflow-x: auto;
  margin: 0 -4px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.data-table th {
  padding: 6px 8px;
  color: var(--muted-2);
  font-size: 0.67rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-align: right;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table th:first-child,
.data-table td:first-child {
  text-align: left;
}

.data-table td {
  padding: 9px 8px;
  border-top: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}

.cell-sub {
  display: block;
  color: var(--muted-2);
  font-size: 0.66rem;
}

/* ---- Foods ---------------------------------------------------------------- */

.foods-toolbar {
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 13px;
}

.food-list {
  padding: 0;
  overflow: hidden;
}

.food-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
}

.food-row:last-child {
  border-bottom: 0;
}

.food-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 11px 0;
  border: 0;
  background: none;
  color: var(--fg);
  text-align: left;
}

.food-title {
  display: flex;
  align-items: baseline;
  gap: 6px;
  max-width: 100%;
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.food-title small {
  color: var(--muted-2);
  font-size: 0.7rem;
  font-weight: 500;
}

.food-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted-2);
  font-size: 0.68rem;
}

.category-chip {
  display: inline-flex;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 600;
}

.food-side {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: none;
}

.food-kcal {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 0.82rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.food-kcal em {
  color: var(--muted-2);
  font-size: 0.6rem;
  font-style: normal;
  font-weight: 500;
}

.food-actions {
  display: flex;
  gap: 2px;
}

.food-actions .icon-btn {
  width: 28px;
  height: 28px;
  border-color: transparent;
  background: transparent;
  color: var(--muted-2);
}

.food-actions .icon-btn:hover {
  background: var(--surface-3);
  color: var(--fg);
}

.food-actions .icon-btn.is-fav {
  color: var(--carbs);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 34px 20px;
  text-align: center;
}

.empty-state p {
  max-width: 38ch;
  color: var(--muted);
  font-size: 0.82rem;
}

.empty-state .btn {
  margin-top: 6px;
}

/* ---- Settings ------------------------------------------------------------- */

.settings-card {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.settings-card .card-head {
  margin-bottom: 0;
}

.unit-fields {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.units-metric .imperial-only,
.units-imperial .metric-only {
  display: none !important;
}

.radio-cards {
  display: grid;
  gap: 8px;
}

.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}

.radio-card input {
  margin: 3px 0 0;
  accent-color: var(--accent);
}

.radio-card span {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.radio-card strong {
  font-size: 0.85rem;
}

.radio-card small {
  color: var(--muted-2);
  font-size: 0.73rem;
  line-height: 1.35;
}

.radio-card.is-active {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: var(--accent-soft);
}

.manual-targets {
  padding: 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  background: var(--surface-2);
}

.target-preview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 12px 13px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.target-preview > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.target-preview span {
  color: var(--muted-2);
  font-size: 0.67rem;
}

.target-preview strong {
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.form-actions .btn {
  min-width: 150px;
}

.theme-segmented {
  align-self: flex-start;
}

.theme-segmented button {
  min-width: 74px;
}

.data-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.data-stats > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 11px;
  background: var(--surface-2);
}

.data-stats strong {
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

.data-stats span {
  color: var(--muted-2);
  font-size: 0.68rem;
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.data-actions .btn {
  flex: 1 1 auto;
}

.file-btn {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.about-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.about-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.about-brand > div {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.about-brand strong {
  font-size: 1rem;
}

.about-brand span {
  color: var(--muted-2);
  font-size: 0.7rem;
}

.about-card p {
  color: var(--muted);
  font-size: 0.78rem;
  max-width: 65ch;
}

/* ---- Onboarding ----------------------------------------------------------- */

.onboarding {
  position: fixed;
  inset: 0;
  z-index: 80;
  overflow-y: auto;
  padding: 22px 16px calc(32px + env(safe-area-inset-bottom));
  background:
    radial-gradient(900px 500px at 80% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(700px 400px at 0% 100%, var(--protein-soft), transparent 65%),
    var(--bg);
  -webkit-overflow-scrolling: touch;
}

.onboarding-card {
  max-width: 680px;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 26px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.onboarding-hero {
  padding: 28px 26px 22px;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(400px 180px at 0% 0%, var(--accent-soft), transparent 70%),
    var(--surface);
}

.onboarding-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  font-size: 1.15rem;
  font-weight: 750;
  letter-spacing: -0.03em;
}

.onboarding-hero h1 {
  margin-top: 14px;
  max-width: 18ch;
}

.onboarding-hero > p {
  max-width: 52ch;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.onboarding-form {
  display: flex;
  flex-direction: column;
}

.onboard-section {
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 22px 26px;
  border-bottom: 1px solid var(--border);
}

.onboard-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.onboard-head .step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 750;
}

.onboard-head h2 {
  font-size: 0.96rem;
}

.onboard-head p {
  margin-top: 1px;
  color: var(--muted-2);
  font-size: 0.75rem;
}

.goal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.goal-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}

.goal-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.goal-card strong {
  font-size: 0.85rem;
}

.goal-card small {
  color: var(--muted-2);
  font-size: 0.7rem;
  line-height: 1.3;
}

.goal-card.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.rate-field {
  max-width: 220px;
}

.units-toggle {
  display: inline-flex;
  align-self: flex-start;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-2);
}

.units-toggle label {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
  cursor: pointer;
}

.units-toggle label.is-active {
  background: var(--surface-3);
  color: var(--fg);
}

.units-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.preview-section {
  border-bottom: 0;
}

.preview-card {
  padding: 16px;
  border-radius: 15px;
  border: 1px solid var(--border);
  background:
    radial-gradient(320px 160px at 100% 0%, var(--accent-soft), transparent 70%),
    var(--surface-2);
}

.preview-calories {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.preview-calories strong {
  font-size: 2.1rem;
  line-height: 1;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
}

.preview-calories span {
  color: var(--muted);
  font-size: 0.74rem;
}

.preview-macros {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.preview-macros > div {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.preview-macros span {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted-2);
  font-size: 0.68rem;
}

.preview-macros strong {
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

.preview-card > p {
  margin-top: 10px;
  color: var(--muted-2);
  font-size: 0.69rem;
}

.onboarding-actions {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 20px 26px 26px;
}

/* ---- Sheets --------------------------------------------------------------- */

.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: rgba(2, 6, 12, 0.56);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fade-in 140ms ease;
}

.sheet {
  width: 100%;
  max-width: 600px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: sheet-up 220ms cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.sheet-handle {
  width: 36px;
  height: 4px;
  margin: 9px auto 0;
  border-radius: 999px;
  background: var(--border-strong);
  flex: none;
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.sheet-head > div:first-child {
  flex: 1;
  min-width: 0;
}

.sheet-head h2 {
  margin-top: 2px;
  font-size: 1.16rem;
  letter-spacing: -0.025em;
  overflow-wrap: anywhere;
}

.sheet-head p {
  margin-top: 3px;
  color: var(--muted-2);
  font-size: 0.74rem;
  line-height: 1.35;
}

.sheet-head .icon-btn {
  width: 34px;
  height: 34px;
}

.sheet-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  gap: 13px;
  padding: 15px 18px calc(18px + env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sheet-footer {
  display: flex;
  gap: 7px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex: none;
}

.sheet-footer .btn {
  flex: 1;
  padding: 9px 6px;
  font-size: 0.73rem;
  border-radius: 10px;
}

.sheet-footer .icon {
  width: 15px;
  height: 15px;
}

.meal-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 1px;
}

.meal-tabs .chip {
  flex: none;
}

.result-section {
  display: flex;
  flex-direction: column;
}

.result-label {
  padding: 6px 2px;
  color: var(--muted-2);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.food-pick {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 10px 2px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: none;
  color: var(--fg);
  text-align: left;
}

.food-pick:last-child {
  border-bottom: 0;
}

.food-pick:hover {
  background: var(--surface-2);
}

.food-pick-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.food-pick-name {
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.food-pick-sub {
  color: var(--muted-2);
  font-size: 0.68rem;
}

.food-pick-kcal {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex: none;
  font-size: 0.83rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.food-pick-kcal em {
  color: var(--muted-2);
  font-size: 0.6rem;
  font-style: normal;
  font-weight: 500;
}

.sheet-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 22px 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.quantity-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.amount-field input {
  height: 52px;
  font-size: 1.25rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.amount-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.quantity-preview {
  padding: 14px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.sheet-form-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 3px;
}

.scan-area {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 190px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface-2);
}

.scan-area video {
  display: none;
  width: 100%;
  height: 220px;
  object-fit: cover;
}

.scan-area.is-scanning video {
  display: block;
}

.scan-area.is-scanning .scan-placeholder {
  display: none;
}

.scan-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.scan-placeholder > .icon {
  width: 30px;
  height: 30px;
  color: var(--muted-2);
}

.scan-placeholder p {
  font-size: 0.8rem;
}

.scan-frame {
  display: none;
  position: absolute;
  width: 68%;
  height: 38%;
  border: 2px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.34);
}

.scan-area.is-scanning .scan-frame {
  display: block;
}

.barcode-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.barcode-form .field {
  flex: 1;
}

.barcode-form .btn {
  height: 42px;
}

.barcode-status {
  min-height: 1.3em;
  font-size: 0.78rem;
  color: var(--muted);
}

.barcode-status.is-error {
  color: var(--danger);
}

.barcode-status.is-loading {
  color: var(--protein);
}

.weight-context {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-2);
}

.weight-context > div {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.weight-context span {
  color: var(--muted-2);
  font-size: 0.68rem;
}

.weight-context strong {
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 8px;
}

/* ---- Toast ---------------------------------------------------------------- */

#toast-root {
  position: fixed;
  left: 50%;
  bottom: calc(82px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 120;
  width: min(440px, calc(100vw - 28px));
  pointer-events: none;
}

body.sheet-open #toast-root {
  top: calc(12px + env(safe-area-inset-top));
  bottom: auto;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--fg);
  font-size: 0.82rem;
  pointer-events: none;
  animation: toast-up 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

.toast span {
  flex: 1;
}

.toast button {
  pointer-events: auto;
  padding: 3px 7px;
  border: 0;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
}

/* ---- Boot ----------------------------------------------------------------- */

#boot {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg);
}

.boot-mark {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid var(--surface-3);
  border-top-color: var(--accent);
  animation: spin 800ms linear infinite;
}

#boot p {
  color: var(--muted);
  font-size: 0.8rem;
}

/* ---- Animation ------------------------------------------------------------ */

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes sheet-up {
  from {
    opacity: 0;
    transform: translateY(26px);
  }
}

@keyframes toast-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---- Responsive ----------------------------------------------------------- */

@media (min-width: 760px) {
  .topnav {
    display: flex;
  }

  .bottom-nav {
    display: none;
  }

  .app-shell {
    padding: 0 24px 60px;
  }

  .topbar {
    margin: 0 -24px;
    padding: 0 24px;
  }

  .main {
    gap: 18px;
    padding-top: 22px;
  }

  .stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .card {
    padding: 20px;
  }

  .summary-card {
    padding: 24px;
  }

  .ring-wrap {
    width: 174px;
    height: 174px;
  }

  .sheet-overlay {
    align-items: center;
    padding: 24px;
  }

  .sheet {
    border: 1px solid var(--border);
    border-radius: 24px;
    max-height: 88vh;
  }

  .sheet-handle {
    display: none;
  }

  #toast-root {
    bottom: 28px;
  }

  .onboarding-actions {
    flex-direction: row;
  }

  .onboarding-actions .btn-primary {
    flex: 1;
  }

  .onboarding-actions .btn-ghost {
    flex: 0 0 auto;
  }
}

@media (max-width: 620px) {
  .field-grid.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field-grid.three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field-grid.three .field:last-child {
    grid-column: 1 / -1;
  }

  .page-head {
    align-items: flex-start;
  }

  .page-actions {
    width: 100%;
  }

  .summary-top {
    gap: 14px;
  }

  .ring-wrap {
    width: 142px;
    height: 142px;
  }

  .ring-center strong {
    font-size: 1.75rem;
  }

  .remaining-block strong {
    font-size: 1.65rem;
  }

  .basis-pill span {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .food-row {
    padding: 0 10px;
  }

  .food-actions .icon-btn {
    width: 26px;
    height: 26px;
  }

  .food-kcal {
    font-size: 0.78rem;
  }

  .target-preview {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .target-preview > div {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
  }

  .onboarding {
    padding: 0;
  }

  .onboarding-card {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    min-height: 100vh;
  }

  .onboarding-hero,
  .onboard-section,
  .onboarding-actions {
    padding-left: 18px;
    padding-right: 18px;
  }

  .goal-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .goal-card {
    padding: 10px 12px;
  }

  .preview-macros {
    grid-template-columns: repeat(3, 1fr);
  }

  .data-actions .btn {
    flex: 1 1 45%;
  }
}

@media (max-width: 360px) {
  .summary-top {
    flex-direction: column;
    align-items: stretch;
  }

  .ring-wrap {
    align-self: center;
  }

  .summary-right {
    align-items: center;
    text-align: center;
  }

  .summary-meta {
    justify-content: center;
  }

  .basis-pill {
    text-align: left;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .macro-avg-row {
    gap: 5px;
  }

  .weight-strip {
    flex-direction: column;
    align-items: stretch;
  }
}

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