:root {
  --bg: #0a0a0b;
  --surface: #141416;
  --surface-2: #1c1c1f;
  --surface-3: #26262a;
  --line: rgba(255, 255, 255, 0.07);
  --text: #f5f5f7;
  --muted: #8e8e96;
  --faint: #5c5c64;
  --accent: #c8f560;
  --accent-ink: #0d1400;
  --accent-soft: rgba(200, 245, 96, 0.12);
  --over: #ff8a4c;
  --over-soft: rgba(255, 138, 76, 0.14);
  --danger: #ff5f57;
  --protein: #7cc4ff;
  --carbs: #ffd166;
  --fat: #ff8fab;
  --radius: 22px;
  --radius-sm: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100dvh; overscroll-behavior-y: none; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
svg.icon { width: 1em; height: 1em; flex: none; }

.num { font-variant-numeric: tabular-nums; }

/* ---------- Views ---------- */

.view {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(var(--safe-top) + 16px) 20px calc(var(--safe-bottom) + 40px);
  animation: view-in 0.28s ease-out;
}
#view-home { padding-bottom: calc(var(--safe-bottom) + 150px); }
.view-flush { padding: 0; }

@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 20px;
}
.topbar h1 {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}
.topbar-actions { display: flex; gap: 8px; }
.topbar.with-back { align-items: center; justify-content: flex-start; }
.topbar.with-back h1 { font-size: 26px; }

.eyebrow {
  margin: 0 0 2px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  font-size: 20px;
  transition: transform 0.15s, background 0.15s;
}
.icon-btn:active { transform: scale(0.92); background: var(--surface-3); }
.icon-btn.small { width: 36px; height: 36px; font-size: 17px; }
.icon-btn.danger { color: var(--danger); }

/* ---------- Summary card (today / day) ---------- */

.summary-card {
  background: radial-gradient(120% 140% at 100% 0%, rgba(200, 245, 96, 0.10), transparent 55%), var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 22px 20px;
}
.summary-card.is-over {
  background: radial-gradient(120% 140% at 100% 0%, rgba(255, 138, 76, 0.12), transparent 55%), var(--surface);
}
.summary-label {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.summary-value {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin: 2px 0 16px;
}
.summary-value .big {
  font-family: var(--font-display);
  font-size: 68px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.summary-value .of { font-size: 17px; color: var(--muted); font-weight: 500; }

.bar {
  height: 10px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: calc(var(--p, 0) * 100%);
  border-radius: inherit;
  background: linear-gradient(90deg, #9fe03a, var(--accent));
  box-shadow: 0 0 18px rgba(200, 245, 96, 0.45);
  transition: width 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.is-over .bar-fill {
  background: linear-gradient(90deg, #ffb35c, var(--over));
  box-shadow: 0 0 18px rgba(255, 138, 76, 0.45);
}
.summary-foot { margin: 12px 0 0; font-size: 15px; color: var(--muted); }
.summary-foot strong { color: var(--text); font-weight: 600; }
.is-over .summary-foot strong { color: var(--over); }

/* ---------- Meal list ---------- */

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 30px 0 12px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.section-title .count {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 99px;
  padding: 2px 9px;
}

.meal-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.meal-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px 10px 10px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: left;
  transition: transform 0.15s, background 0.15s;
}
.meal-row:active { transform: scale(0.985); background: var(--surface-2); }
.thumb {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  overflow: hidden;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 24px;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.meal-info { flex: 1; min-width: 0; display: grid; gap: 3px; }
.meal-title {
  font-weight: 600;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meal-meta { font-size: 13px; color: var(--muted); }
.meal-kcal {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  line-height: 1.1;
}
.meal-kcal small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }

.empty {
  text-align: center;
  padding: 36px 24px;
  border: 1.5px dashed var(--surface-3);
  border-radius: var(--radius);
  color: var(--muted);
}
.empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 26px;
}
.empty h3 { margin: 0 0 6px; color: var(--text); font-size: 17px; }
.empty p { margin: 0; font-size: 15px; }

/* ---------- Dock (camera button) ---------- */

.dock {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 18px);
  transform: translateX(-50%);
  z-index: 20;
  display: none;
  align-items: center;
  gap: 22px;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(20, 20, 22, 0.82);
  border: 1px solid var(--line);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}
body[data-view="home"] .dock { display: flex; }
.dock-side {
  display: grid;
  justify-items: center;
  gap: 2px;
  width: 64px;
  color: var(--muted);
  font-size: 22px;
}
.dock-side small { font-size: 11px; font-weight: 600; }
.dock-side:active { color: var(--text); }
.dock-camera {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 34px;
  box-shadow: 0 0 0 6px rgba(200, 245, 96, 0.14), 0 10px 30px rgba(200, 245, 96, 0.35);
  transition: transform 0.15s;
}
.dock-camera:active { transform: scale(0.92); }
.dock-camera svg { stroke-width: 2.2; }

/* ---------- Analyzing ---------- */

.scan {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(var(--safe-top) + 16px) 20px calc(var(--safe-bottom) + 24px);
}
.scan-photo {
  position: relative;
  flex: 1;
  min-height: 52vh;
  max-height: 68vh;
  border-radius: 28px;
  overflow: hidden;
  background: var(--surface);
}
.scan-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.05);
  animation: breathe 3.2s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: scale(1.02); }
  50% { transform: scale(1.06); }
}
.scan-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 10, 11, 0.2), transparent 30%, transparent 60%, rgba(10, 10, 11, 0.55));
}
.scan-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 34%;
  top: -34%;
  z-index: 2;
  background: linear-gradient(180deg, transparent, rgba(200, 245, 96, 0.22) 85%, rgba(200, 245, 96, 0.95) 99%, transparent);
  animation: scan 2.4s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}
@keyframes scan {
  0% { top: -34%; }
  100% { top: 100%; }
}
.corner {
  position: absolute;
  z-index: 3;
  width: 34px;
  height: 34px;
  border: 3px solid var(--accent);
  opacity: 0.9;
}
.corner.tl { top: 18px; left: 18px; border-right: 0; border-bottom: 0; border-top-left-radius: 12px; }
.corner.tr { top: 18px; right: 18px; border-left: 0; border-bottom: 0; border-top-right-radius: 12px; }
.corner.bl { bottom: 18px; left: 18px; border-right: 0; border-top: 0; border-bottom-left-radius: 12px; }
.corner.br { bottom: 18px; right: 18px; border-left: 0; border-top: 0; border-bottom-right-radius: 12px; }

.scan-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: 28px;
  border-radius: 28px;
  background: radial-gradient(120% 100% at 0% 0%, rgba(200, 245, 96, 0.10), transparent 60%), var(--surface);
  border: 1px solid var(--line);
}
.scan-text .quote {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.shimmer {
  height: 14px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.shimmer.short { width: 60%; }
@keyframes shimmer { to { background-position: -200% 0; } }

.scan-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 28px 0 8px;
  min-height: 28px;
}
.scan-status p {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  animation: fade-msg 0.4s ease-out;
}
@keyframes fade-msg {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(200, 245, 96, 0.6);
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  70% { box-shadow: 0 0 0 12px rgba(200, 245, 96, 0); }
  100% { box-shadow: 0 0 0 0 rgba(200, 245, 96, 0); }
}
.scan-sub { margin: 0 0 18px; text-align: center; color: var(--muted); font-size: 14px; }

.error-card {
  margin: 22px 0 6px;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: center;
}
.error-card h2 { margin: 0 0 6px; font-size: 19px; }
.error-card p { margin: 0 0 18px; color: var(--muted); font-size: 15px; }
.error-card .btn-stack { display: grid; gap: 10px; }

/* ---------- Buttons ---------- */

.btn-primary, .btn-secondary, .btn-ghost, .btn-danger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 56px;
  padding: 0 20px;
  border-radius: 18px;
  font-size: 17px;
  font-weight: 650;
  transition: transform 0.15s, opacity 0.15s, background 0.15s;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--muted); min-height: 48px; }
.btn-danger { background: rgba(255, 95, 87, 0.12); color: var(--danger); }
.btn-danger.armed { background: var(--danger); color: #fff; }
.btn-primary:active, .btn-secondary:active, .btn-danger:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.35; }
.btn-row { display: flex; gap: 10px; }

/* ---------- Review ---------- */

.review-hero {
  position: relative;
  height: 46vh;
  min-height: 300px;
  max-height: 460px;
  overflow: hidden;
  background: var(--surface);
}
.review-hero img { width: 100%; height: 100%; object-fit: cover; }
.review-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 10, 11, 0.45) 0%, transparent 28%, transparent 45%, rgba(10, 10, 11, 0.9) 88%, var(--bg) 100%);
}
.review-hero.text {
  height: auto;
  min-height: 0;
  padding: calc(var(--safe-top) + 76px) 24px 30px;
  background: radial-gradient(120% 100% at 0% 0%, rgba(200, 245, 96, 0.12), transparent 60%), var(--bg);
}
.review-hero.text::after { display: none; }
.hero-quote {
  margin: 0;
  font-size: 15px;
  color: var(--muted);
}
.hero-close {
  position: absolute;
  z-index: 3;
  top: calc(var(--safe-top) + 14px);
  left: 16px;
  background: rgba(10, 10, 11, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.hero-overlay {
  position: absolute;
  z-index: 2;
  left: 20px;
  right: 20px;
  bottom: 16px;
}
.review-hero.text .hero-overlay { position: static; margin-top: 10px; }
.hero-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  padding: 5px 10px;
  border-radius: 99px;
  background: rgba(200, 245, 96, 0.16);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.review-body {
  max-width: 520px;
  margin: 0 auto;
  padding: 6px 20px calc(var(--safe-bottom) + 120px);
}

.total-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}
.total-kcal {
  margin: 0;
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.total-kcal small { font-size: 16px; color: var(--muted); font-weight: 500; letter-spacing: 0; }

.macros { display: flex; gap: 6px; flex-wrap: wrap; }
.macro {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 99px;
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.macro::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  align-self: center;
  background: currentColor;
}
.macro b { font-weight: 600; color: var(--muted); }
.macro.p::before { background: var(--protein); }
.macro.c::before { background: var(--carbs); }
.macro.f::before { background: var(--fat); }

.ai-note {
  display: flex;
  gap: 8px;
  margin: 14px 4px 0;
  font-size: 14px;
  color: var(--muted);
}
.ai-note .icon { color: var(--accent); margin-top: 2px; }

.list-label {
  margin: 26px 4px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.item-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.item {
  padding: 16px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  animation: view-in 0.25s ease-out;
}
.item-head { display: flex; justify-content: space-between; gap: 12px; }
.item-name { margin: 0; font-weight: 650; font-size: 17px; }
.item-portion { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
.item-kcal {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.item-kcal small { font-size: 13px; color: var(--muted); font-weight: 500; }
.item-macros {
  display: flex;
  gap: 14px;
  margin: 8px 0 14px;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.item-macros span::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 5px;
  border-radius: 50%;
  vertical-align: 1px;
}
.item-macros .p::before { background: var(--protein); }
.item-macros .c::before { background: var(--carbs); }
.item-macros .f::before { background: var(--fat); }

.item-controls { display: flex; align-items: center; gap: 8px; }
.stepper {
  display: flex;
  align-items: center;
  height: 44px;
  border-radius: 14px;
  background: var(--surface-2);
}
.stepper button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-size: 18px;
  color: var(--text);
}
.stepper button:active { color: var(--accent); }
.stepper button:disabled { color: var(--faint); }
.stepper .mult {
  min-width: 46px;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.grams {
  display: flex;
  align-items: center;
  height: 44px;
  padding: 0 12px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1.5px solid transparent;
  transition: border-color 0.15s;
}
.grams:focus-within { border-color: var(--accent); }
.grams input {
  width: 52px;
  border: 0;
  background: transparent;
  outline: none;
  text-align: right;
  font-weight: 700;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.grams input::-webkit-outer-spin-button,
.grams input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.grams span { margin-left: 3px; color: var(--muted); font-size: 15px; }
.item-controls .icon-btn { margin-left: auto; width: 44px; height: 44px; background: rgba(255, 95, 87, 0.1); }

.disclaimer {
  display: flex;
  gap: 8px;
  margin: 22px 4px 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--faint);
}
.disclaimer .icon { margin-top: 2px; }

.action-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  padding: 16px 20px calc(var(--safe-bottom) + 16px);
  background: linear-gradient(180deg, transparent, var(--bg) 35%);
}
.action-bar > * { max-width: 480px; margin: 0 auto; }

/* ---------- History ---------- */

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}
.stat {
  padding: 16px 18px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.stat p { margin: 0; }
.stat .stat-value {
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat .stat-value small { font-size: 14px; color: var(--muted); font-weight: 500; letter-spacing: 0; }

.day-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.day-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 16px 18px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  transition: transform 0.15s;
}
.day-row:active { transform: scale(0.985); }
.day-row > div:nth-child(2) { display: grid; justify-items: end; gap: 4px; }
.day-name { margin: 0; font-weight: 650; font-size: 16px; }
.day-meta { margin: 0; font-size: 13px; color: var(--muted); }
.day-kcal {
  margin: 0;
  text-align: right;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}
.day-kcal small { font-size: 12px; color: var(--muted); font-weight: 500; }
.day-row .bar { grid-column: 1 / -1; height: 6px; margin-top: 10px; }
.day-row .bar-fill { box-shadow: none; }

.badge {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.badge.ok { background: var(--accent-soft); color: var(--accent); }
.badge.over { background: var(--over-soft); color: var(--over); }

/* ---------- Forms (goal / settings) ---------- */

.welcome { margin: 18px 0 26px; }
.logo {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  margin-bottom: 20px;
}
.welcome h1 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.welcome p { margin: 0; color: var(--muted); font-size: 16px; }

.form { display: grid; gap: 22px; }
.field-label {
  display: block;
  margin: 0 0 8px 2px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }

.fields-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.fields-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 10px; }
.input {
  display: flex;
  align-items: center;
  height: 58px;
  padding: 0 14px;
  border-radius: 16px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  transition: border-color 0.15s;
}
.input:focus-within { border-color: var(--accent); }
.input input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 20px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.input input::-webkit-outer-spin-button,
.input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input span { color: var(--muted); font-size: 15px; margin-left: 4px; }
.input-caption { display: block; margin: 6px 0 0 2px; font-size: 12px; color: var(--faint); }

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: grid;
  place-items: center;
  height: 46px;
  border-radius: 12px;
  padding: 0 4px;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.15;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.segmented input:checked + span { background: var(--surface-3); color: var(--text); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }

.choice-list { display: grid; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 15px 16px;
  border-radius: 16px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  transition: border-color 0.15s, background 0.15s;
}
.choice b { font-weight: 650; }
.choice small { color: var(--muted); font-size: 13px; text-align: right; }
.choice input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.goal-result {
  padding: 24px 22px;
  border-radius: var(--radius);
  background: radial-gradient(120% 140% at 100% 0%, rgba(200, 245, 96, 0.14), transparent 60%), var(--surface);
  border: 1px solid var(--line);
  text-align: center;
}
.goal-result .input { max-width: 220px; margin: 10px auto 4px; height: 72px; justify-content: center; }
.goal-result .input input { font-size: 40px; text-align: center; font-family: var(--font-display); }
.goal-result p { margin: 0; color: var(--muted); font-size: 14px; }

.card {
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  margin-bottom: 14px;
}
.card h2 { margin: 0 0 4px; font-size: 17px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }
.card .goal-big {
  margin: 6px 0 16px;
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.card .goal-big small { font-size: 16px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.card .btn-row > * { flex: 1; }
.card-inline { display: flex; gap: 10px; margin-top: 14px; }
.card-inline .input { flex: 1; height: 56px; }
.card-inline .btn-secondary { width: auto; }

/* ---------- Bottom sheet ---------- */

.sheet { position: fixed; inset: 0; z-index: 40; }
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  animation: fade 0.2s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 560px;
  max-height: 92dvh;
  margin: 0 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 20px calc(var(--safe-bottom) + 20px);
  border-radius: 28px 28px 0 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  animation: sheet-up 0.32s cubic-bezier(0.2, 0.9, 0.25, 1);
}
@keyframes sheet-up { from { transform: translateY(100%); } }
.sheet-grip {
  width: 40px;
  height: 5px;
  margin: 0 auto 14px;
  border-radius: 99px;
  background: var(--surface-3);
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.sheet-head h2 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.sheet-head .icon-btn { background: var(--surface-2); }

.textarea {
  width: 100%;
  min-height: 130px;
  padding: 16px;
  border-radius: 18px;
  border: 1.5px solid var(--line);
  background: var(--bg);
  font-size: 17px;
  line-height: 1.45;
  resize: none;
  outline: none;
  transition: border-color 0.15s;
}
.textarea:focus { border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 20px; }
.chip {
  padding: 8px 12px;
  border-radius: 99px;
  background: var(--surface-2);
  font-size: 14px;
  color: var(--muted);
}
.chip:active { color: var(--text); }

.detail-photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 22px;
  margin-bottom: 18px;
}
.detail-quote {
  margin: 0 0 18px;
  padding: 18px;
  border-radius: 18px;
  background: var(--bg);
  font-size: 17px;
}
.detail-title { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.detail-time { margin: 2px 0 16px; color: var(--muted); font-size: 14px; }
.detail-items { list-style: none; margin: 16px 0 0; padding: 0; }
.detail-items li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.detail-items p { margin: 0; }
.detail-items .sub { color: var(--muted); font-size: 13px; }
.detail-items .kcal { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sheet .btn-danger { margin-top: 18px; }

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

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 130px);
  z-index: 50;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 32px);
  padding: 12px 14px 12px 18px;
  border-radius: 16px;
  background: #f5f5f7;
  color: #0a0a0b;
  font-weight: 600;
  font-size: 15px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  width: max-content;
  animation: toast-in 0.25s ease-out;
}
.toast span { flex: 1; }
body:not([data-view="home"]) .toast { bottom: calc(var(--safe-bottom) + 100px); }
.toast button {
  flex: none;
  padding: 6px 10px;
  border-radius: 10px;
  background: #0a0a0b;
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .scan-line { top: 40%; }
}

.input input[type="text"] { font-size: 18px; }

/* ---------- Repetir refeição (+) ---------- */

.meal-item { display: flex; align-items: stretch; gap: 8px; }
.meal-item .meal-row { flex: 1; min-width: 0; }
.meal-plus {
  flex: none;
  width: 52px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: var(--accent-soft);
  border: 1px solid rgba(200, 245, 96, 0.16);
  color: var(--accent);
  font-size: 22px;
  transition: transform 0.15s, background 0.15s;
}
.meal-plus:active { transform: scale(0.92); background: rgba(200, 245, 96, 0.22); }
.meal-plus svg { stroke-width: 2.4; }
.servings {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 800;
  vertical-align: 1px;
}

.servings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 20px;
  background: var(--bg);
}
.servings-row p { margin: 0; }
.servings-label { font-weight: 650; }
.servings-hint { font-size: 13px; color: var(--muted); }
#sheet .list-label { margin-top: 20px; }
#sheet .detail-items { margin-top: 0; }

/* ---------- Adicionar algo que faltou ---------- */

.btn-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 56px;
  margin-top: 10px;
  border-radius: 20px;
  border: 1.5px dashed var(--surface-3);
  color: var(--accent);
  font-size: 16px;
  font-weight: 650;
  transition: background 0.15s;
}
.btn-add:active { background: var(--accent-soft); }
.sheet-hint { margin: 10px 2px 18px; font-size: 14px; color: var(--muted); }
.tag {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  vertical-align: 2px;
}

/* ---------- Corrigir itens ---------- */

.tag.warn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--over-soft);
  color: var(--over);
}
.tag.warn .icon { width: 11px; height: 11px; }
.item.is-uncertain { border-color: rgba(255, 138, 76, 0.35); }
.item.is-loading { opacity: 0.45; pointer-events: none; animation: loading-pulse 0.9s ease-in-out infinite alternate; }
@keyframes loading-pulse { to { opacity: 0.25; } }

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  padding: 4px 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
}
.link-btn .icon { width: 13px; height: 13px; }

.suggest {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--over-soft);
}
.suggest > span { font-size: 13px; font-weight: 650; color: var(--over); margin-right: 2px; }
.chip.small { padding: 6px 11px; font-size: 13px; background: var(--surface-2); color: var(--text); }
.chip.small:active { background: var(--surface-3); }

/* ---------- Recentes ---------- */

.recents {
  display: flex;
  gap: 10px;
  margin: 0 -20px 4px;
  padding: 0 20px 6px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.recents::-webkit-scrollbar { display: none; }
.recent {
  flex: none;
  width: 104px;
  display: grid;
  gap: 4px;
  text-align: left;
  scroll-snap-align: start;
}
.recent .thumb { width: 104px; height: 104px; border-radius: 18px; }
.recent:active .thumb { transform: scale(0.96); }
.recent-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.recent-kcal { font-size: 12px; color: var(--muted); }

/* ---------- Idioma ---------- */

.access-top { display: flex; justify-content: flex-end; }
.lang-switch { width: 116px; flex: none; }
.lang-switch span { height: 36px; font-size: 13px; }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}
.settings-row .field-label { margin: 0; }

.grams span { white-space: nowrap; }

/* ---------- Entrar com código ---------- */

.field-error {
  display: block;
  min-height: 18px;
  margin: 6px 2px 0;
  font-size: 13px;
  color: var(--over);
}
.input.has-error { border-color: var(--over); }

.notice {
  display: flex;
  gap: 10px;
  margin: 0 0 18px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--over-soft);
  color: var(--text);
  font-size: 14px;
}
.notice .icon { color: var(--over); margin-top: 2px; flex: none; }

.otp {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.otp input {
  width: 100%;
  min-width: 0;
  height: 60px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  text-align: center;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  outline: none;
  caret-color: var(--accent);
  transition: border-color 0.15s;
}
.otp input:focus { border-color: var(--accent); }
.otp input:disabled { opacity: 0.5; }

.spam-hint {
  display: flex;
  gap: 8px;
  margin: 18px 2px 4px;
  font-size: 13px;
  color: var(--muted);
}
.spam-hint .icon { margin-top: 2px; flex: none; }
.link-btn.center { display: flex; justify-content: center; width: 100%; margin-top: 10px; font-size: 15px; }
