:root {
  --bg: #f7fbf1;
  --surface: rgba(255, 255, 255, 0.84);
  --surface-strong: #ffffff;
  --text: #142019;
  --muted: #617064;
  --line: rgba(20, 32, 25, 0.1);
  --green: #91d64d;
  --green-2: #d7ff77;
  --deep: #17331f;
  --yellow: #f6d76b;
  --orange: #fb9f45;
  --danger: #ff6b6b;
  --shadow: 0 24px 70px rgba(23, 51, 31, 0.14);
  --radius-xl: 32px;
  --radius-lg: 24px;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #08120c;
  --surface: rgba(17, 31, 22, 0.86);
  --surface-strong: #111f16;
  --text: #eef8e9;
  --muted: #9fac9d;
  --line: rgba(238, 248, 233, 0.11);
  --deep: #dfffd1;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Switzer", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, rgba(145, 214, 77, 0.26), transparent 34rem), radial-gradient(circle at 90% 10%, rgba(246, 215, 107, 0.22), transparent 28rem), var(--bg);
  color: var(--text);
}
button, input, select { font: inherit; }
button { cursor: pointer; border: 0; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
svg { width: 18px; height: 18px; stroke-width: 2.4; }
.app-shell { width: min(1160px, 100%); margin: 0 auto; padding: 0 16px 104px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-inline: calc(50% - 50vw);
  padding: 14px max(16px, calc((100vw - 1160px) / 2 + 16px));
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.brand-pill, .hero-actions, .scan-controls, .card-title-row, .drawer-header, .auth-actions { display: flex; align-items: center; }
.brand-pill { gap: 10px; background: var(--surface); color: var(--text); padding: 8px 12px 8px 8px; border-radius: 999px; border: 1px solid var(--line); box-shadow: 0 10px 24px rgba(23, 51, 31, .08); font-weight: 900; }
.brand-mark { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, var(--green), var(--green-2)); color: #102014; font-weight: 900; }
.icon-btn, .secondary-btn, .text-btn, .primary-btn, .brand-pill, .nav-item, .history-item, .metric-card, .scan-card, .food-chip-grid span { transition: transform .2s ease, opacity .2s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease; }
.icon-btn:hover, .secondary-btn:hover, .text-btn:hover, .primary-btn:hover, .brand-pill:hover, .nav-item:hover { transform: translateY(-1px); }
.history-item:hover, .metric-card:hover, .scan-card:hover { transform: translateY(-2px); box-shadow: 0 26px 80px rgba(23, 51, 31, .16); }
.food-chip-grid span:hover { transform: translateY(-1px); border-color: rgba(145,214,77,.5); }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.primary-btn, .secondary-btn { min-height: 50px; border-radius: 999px; padding: 0 20px; font-weight: 900; display: inline-flex; align-items: center; justify-content: center; gap: 9px; }
.primary-btn { background: linear-gradient(135deg, var(--green), var(--green-2)); color: #102014; box-shadow: 0 16px 36px rgba(145, 214, 77, .28); }
.primary-btn:hover { box-shadow: 0 20px 44px rgba(145, 214, 77, .36); }
.secondary-btn { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.primary-btn:disabled, .secondary-btn:disabled { opacity: .42; cursor: not-allowed; transform: none; }
.text-btn { background: transparent; color: var(--deep); font-weight: 900; padding: 8px; display: inline-flex; align-items: center; gap: 7px; }
.full { width: 100%; }
.screen { display: none; animation: rise .35s ease both; }
.screen.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, .78fr); gap: 36px; align-items: center; padding: 40px 0 28px; }
.eyebrow, .kicker { color: var(--deep); font-weight: 900; letter-spacing: -.01em; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.pulse-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 8px rgba(145, 214, 77, .18); }
h1 { font-size: clamp(3rem, 7.2vw, 6rem); line-height: .9; letter-spacing: -.055em; margin: 20px 0; max-width: 760px; }
h2 { font-size: clamp(2rem, 4.6vw, 3.75rem); letter-spacing: -.045em; line-height: .98; margin: 0; }
h3 { margin: 0; letter-spacing: -.02em; }
p { color: var(--muted); line-height: 1.65; }
.hero-subtext { max-width: 620px; font-size: 1.08rem; }
.hero-actions { gap: 10px; flex-wrap: wrap; margin-top: 28px; }
.phone-preview { position: relative; min-height: 600px; border-radius: 32px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; padding: 22px; backdrop-filter: blur(18px); }
.phone-top { width: 116px; height: 26px; border-radius: 999px; background: color-mix(in srgb, var(--text) 10%, transparent); margin: 0 auto; }
.scan-card { display: flex; align-items: center; gap: 12px; background: var(--surface-strong); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px; box-shadow: var(--shadow); margin-top: 32px; }
.scan-card small { display: block; color: var(--muted); margin-top: 3px; }
.food-emoji { font-size: 2rem; }
.score-pill { margin-left: auto; border-radius: 999px; padding: 8px 10px; font-weight: 900; background: rgba(145,214,77,.22); color: var(--deep); white-space: nowrap; }
.plate-orbit { position: relative; min-height: 320px; display: grid; place-items: center; }
.plate-core { width: 168px; height: 168px; border-radius: 50%; display: grid; place-items: center; font-size: 4.6rem; background: linear-gradient(135deg, var(--surface-strong), color-mix(in srgb, var(--green-2) 35%, var(--surface-strong))); box-shadow: inset 0 0 0 14px color-mix(in srgb, var(--green) 20%, transparent); }
.orbit-item { position: absolute; width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; font-size: 1.75rem; background: var(--surface-strong); border: 1px solid var(--line); box-shadow: 0 15px 30px rgba(0,0,0,.08); }
.orbit-item.one { top: 44px; right: 24%; } .orbit-item.two { left: 18%; bottom: 72px; } .orbit-item.three { right: 14%; bottom: 92px; }
.macro-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.macro-row span { background: var(--surface-strong); border: 1px solid var(--line); border-radius: 18px; padding: 12px; color: var(--muted); font-size: .82rem; }
.macro-row b { display: block; color: var(--text); font-size: 1.1rem; }
.section-heading { margin: 30px 0 16px; }
.section-heading p { margin-bottom: 6px; color: var(--deep); font-weight: 900; }
.food-chip-grid { display: flex; flex-wrap: wrap; gap: 10px; padding-bottom: 30px; }
.food-chip-grid span, .detected-tags span { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 9px 12px; color: var(--muted); font-weight: 800; font-size: .88rem; }
.screen-header { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin: 34px 0 20px; }
.kicker { margin: 0 0 8px; font-size: .82rem; text-transform: uppercase; }
.scanner-panel, .tip-card, .score-card, .nutrition-card, .insight-card, .metric-card, .history-item, .empty-card, .settings-section, .account-card { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: var(--radius-xl); }
.scanner-panel { padding: 14px; }
.camera-box { position: relative; min-height: 420px; border-radius: 26px; border: 1px dashed rgba(145,214,77,.7); background: rgba(145,214,77,.08); display: grid; place-items: center; overflow: hidden; }
.camera-box input[type="file"] { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.upload-state { text-align: center; padding: 24px; max-width: 430px; }
.upload-actions { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.upload-icon { width: 96px; height: 96px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 32px; background: var(--surface-strong); color: var(--deep); }
.upload-icon svg { width: 38px; height: 38px; }
#imagePreview { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.scan-controls { justify-content: space-between; gap: 10px; padding-top: 12px; }
.scan-controls button { flex: 1; }
.tip-card, .insight-card { padding: 22px; margin-top: 16px; }
.result-grid, .dashboard-grid { display: grid; grid-template-columns: .85fr 1.15fr; gap: 16px; }
.score-card, .nutrition-card, .metric-card { padding: 22px; }
.score-ring { --angle: calc(var(--score) * 3.6deg); width: 160px; height: 160px; border-radius: 50%; margin: 6px auto 18px; display: grid; place-items: center; background: conic-gradient(var(--green) var(--angle), rgba(145,214,77,.13) 0); position: relative; }
.score-ring:after { content:""; width: 118px; height: 118px; border-radius: 50%; background: var(--surface-strong); position:absolute; }
.score-ring span { position: relative; z-index: 1; font-size: 2.4rem; font-weight: 900; letter-spacing: -.06em; }
.card-title-row { justify-content: space-between; gap: 18px; }
.nutrition-card .card-title-row { align-items: center; margin-bottom: 18px; }
.nutrition-scope-pill { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; padding: 8px 12px; border: 1px solid var(--line); background: rgba(145,214,77,.10); color: var(--deep) !important; font-size: .82rem; font-weight: 900; white-space: nowrap; }
.nutrition-list { display: grid; gap: 10px; margin-top: 0; }
.nutrition-list div { display: flex; justify-content: space-between; align-items: center; background: rgba(145,214,77,.08); border-radius: 16px; padding: 14px; }
.nutrition-list span, .card-title-row span { color: var(--muted); }
.detected-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.dashboard-grid { grid-template-columns: repeat(3, 1fr); }
.metric-card span, .metric-card small { color: var(--muted); }
.metric-card strong { display: block; font-size: 2rem; letter-spacing: -.05em; margin: 8px 0 3px; }
.history-list { display: grid; gap: 12px; margin-top: 16px; }
.history-item { display: flex; gap: 14px; padding: 14px; align-items: center; }
.history-thumb { width: 62px; height: 62px; border-radius: 20px; display: grid; place-items: center; background: rgba(145,214,77,.14); font-size: 1.8rem; flex: none; }
.history-item p { margin: 3px 0 0; font-size: .9rem; }
.empty-card { display: grid; place-items: center; text-align: center; gap: 8px; padding: 36px 20px; }
.empty-card svg { width: 38px; height: 38px; color: var(--deep); }
.bottom-nav { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(560px, calc(100% - 26px)); display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 8px; background: color-mix(in srgb, var(--surface-strong) 82%, transparent); border: 1px solid var(--line); border-radius: 26px; box-shadow: var(--shadow); backdrop-filter: blur(18px); z-index: 80; }
.nav-item { display: grid; place-items: center; gap: 3px; min-height: 58px; border-radius: 20px; background: transparent; color: var(--muted); font-weight: 900; font-size: .78rem; }
.nav-item svg { width: 19px; height: 19px; }
.nav-item.active { background: linear-gradient(135deg, var(--green), var(--green-2)); color: #102014; }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.48); backdrop-filter: blur(8px); opacity: 0; transition: .22s ease; z-index: 500; }
.drawer-backdrop.show { opacity: 1; }
.settings-drawer { position: fixed; top: 0; right: 0; width: min(440px, 100%); height: 100dvh; overflow-y: auto; padding: 18px; background: var(--bg); border-left: 1px solid var(--line); box-shadow: -30px 0 90px rgba(0,0,0,.22); transform: translateX(104%); transition: transform .25s ease; z-index: 600; }
.settings-drawer.show { transform: translateX(0); }
.drawer-header { justify-content: space-between; margin-bottom: 16px; }
.account-card { display: flex; align-items: center; gap: 12px; padding: 14px; margin-bottom: 14px; }
.account-card p { margin: 3px 0 0; font-size: .92rem; }
.avatar { width: 54px; height: 54px; border-radius: 20px; display: grid; place-items: center; flex: none; overflow: hidden; background: linear-gradient(135deg, var(--green), var(--green-2)); color: #102014; font-weight: 900; font-size: 1.25rem; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.settings-section { padding: 18px; margin-top: 14px; }
.settings-section h3 { margin-bottom: 6px; }
.settings-section p { margin: 0 0 14px; }
.auth-form { display: grid; gap: 12px; }
.auth-actions { gap: 8px; margin-top: 2px; }
.auth-actions button { flex: 1; }
.divider { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: var(--muted); font-weight: 800; font-size: .86rem; }
.divider:before, .divider:after { content: ""; height: 1px; flex: 1; background: var(--line); }
label { color: var(--muted); font-weight: 900; font-size: .9rem; }
input, select { width: 100%; margin-top: 8px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface-strong); color: var(--text); min-height: 52px; padding: 0 14px; outline: none; }
input:focus, select:focus { border-color: rgba(145,214,77,.8); box-shadow: 0 0 0 4px rgba(145,214,77,.14); }
.toast { position: fixed; top: 18px; left: 50%; transform: translate(-50%, -16px); width: min(520px, calc(100% - 28px)); background: var(--surface-strong); color: var(--text); border: 1px solid var(--line); box-shadow: 0 22px 70px rgba(0,0,0,.22); border-radius: 22px; padding: 14px 16px; opacity: 0; pointer-events: none; transition: .25s ease; z-index: 9999; font-weight: 900; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.spin { animation: spin .85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 820px) {
  .app-shell { padding-left: 14px; padding-right: 14px; }
  .hero-grid, .result-grid, .dashboard-grid { grid-template-columns: 1fr; }
  .phone-preview { min-height: 500px; }
  .camera-box { min-height: 360px; }
  h1 { font-size: clamp(3.25rem, 17vw, 5rem); letter-spacing: -.05em; }
}
@media (max-width: 520px) {
  .topbar { padding-top: 10px; padding-bottom: 10px; }
  .hero-grid { padding-top: 24px; }
  .phone-preview { display: none; }
  .screen-header { flex-direction: column; }
  .scan-controls, .hero-actions, .auth-actions, .upload-actions { flex-direction: column; align-items: stretch; }
  .camera-box { min-height: 330px; }
  .score-ring { width: 138px; height: 138px; }
  .score-ring:after { width: 102px; height: 102px; }
  .history-item { align-items: flex-start; }
  .bottom-nav { bottom: 10px; }
  .settings-drawer { padding: 16px; }
}

.history-content { flex: 1; min-width: 0; }
.history-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.history-title-row strong { display: block; line-height: 1.25; }
.history-meta { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px 0 6px; }
.history-meta span { display: inline-flex; align-items: center; min-height: 30px; padding: 6px 10px; border-radius: 999px; background: rgba(145, 214, 77, .1); border: 1px solid var(--line); color: var(--muted); font-size: .78rem; font-weight: 900; white-space: nowrap; }
.delete-meal-btn { width: 38px; height: 38px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; background: color-mix(in srgb, var(--danger) 10%, var(--surface-strong)); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 26%, var(--line)); transition: transform .2s ease, background .2s ease, box-shadow .2s ease; }
.delete-meal-btn:hover { transform: translateY(-1px); background: color-mix(in srgb, var(--danger) 16%, var(--surface-strong)); box-shadow: 0 12px 28px rgba(255, 107, 107, .16); }
.delete-meal-btn svg { width: 17px; height: 17px; }
.api-save-btn { margin-top: 18px; }
.settings-section label + label { margin-top: 14px; display: block; }

.better-box {
  margin-top: 18px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(166, 242, 79, 0.08);
}

.better-box strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
}

.better-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.ask-card{margin-top:18px;padding:20px;background:var(--surface);border:1px solid var(--line);box-shadow:var(--shadow);border-radius:var(--radius-xl);}
.ask-head{display:flex;align-items:flex-start;justify-content:space-between;gap:14px;margin-bottom:14px;}
.ask-head h3{margin:0 0 6px;font-size:1.05rem;letter-spacing:-.01em;}
.ask-head p{margin:0;color:var(--muted);line-height:1.55;font-size:.92rem;}
.quick-questions{display:flex;gap:8px;flex-wrap:wrap;margin:14px 0;}
.quick-questions button{border:1px solid var(--line);background:rgba(145,214,77,.09);color:var(--text);border-radius:999px;padding:9px 11px;font:inherit;font-size:.82rem;font-weight:800;cursor:pointer;transition:transform .18s ease,background .18s ease,border-color .18s ease;}
.quick-questions button:hover{transform:translateY(-1px);background:rgba(145,214,77,.16);border-color:rgba(145,214,77,.45);}
.meal-chat{display:flex;flex-direction:column;gap:10px;max-height:320px;overflow:auto;padding:12px;border:1px solid var(--line);background:rgba(255,255,255,.04);border-radius:20px;}
.chat-bubble{width:fit-content;max-width:88%;border-radius:18px;padding:11px 13px;line-height:1.55;font-size:.92rem;}
.chat-bubble.assistant{background:rgba(145,214,77,.12);color:var(--text);border-top-left-radius:6px;}
.chat-bubble.user{
  align-self:flex-end;
  background:var(--green);
  color:#10230f;
  border-top-right-radius:6px;
  font-weight:800;
}
.ask-form{display:grid;grid-template-columns:1fr auto;gap:10px;margin-top:12px;}
.ask-form input{min-width:0;border:1px solid var(--line);border-radius:999px;padding:13px 14px;background:var(--surface-strong);color:var(--text);font:inherit;outline:none;}
.ask-form input:focus{border-color:rgba(145,214,77,.65);box-shadow:0 0 0 4px rgba(145,214,77,.12);}
.small-btn{min-height:44px;padding-inline:16px;}
@media(max-width:560px){.ask-card{padding:16px}.chat-bubble{max-width:95%}.ask-form{grid-template-columns:1fr}.small-btn{width:100%}}

.chat-bubble.typing::after{
  content:"";
  display:inline-block;
  width:6px;
  height:1em;
  margin-left:3px;
  border-radius:999px;
  background:currentColor;
  vertical-align:-2px;
  animation:biteoffBlink .8s infinite;
}
@keyframes biteoffBlink{
  0%,45%{opacity:1}
  46%,100%{opacity:0}
}


/* Navbar logo lockup update */
.brand-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: auto;
  overflow: hidden;
}

.brand-logo {
  display: block;
  height: 38px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.brand-logo-light {
  display: none;
}

.brand-logo-dark {
  display: block;
}

[data-theme="light"] .brand-logo-dark,
body.light .brand-logo-dark,
.light-mode .brand-logo-dark {
  display: none;
}

[data-theme="light"] .brand-logo-light,
body.light .brand-logo-light,
.light-mode .brand-logo-light {
  display: block;
}

@media (max-width: 560px) {
  .brand-logo {
    height: 32px;
    max-width: 150px;
  }
}


.api-help-note {
  margin: 8px 0 16px;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.5;
}

.api-help-note a {
  color: var(--green);
  font-weight: 800;
  text-decoration: none;
}

.api-help-note a:hover {
  text-decoration: underline;
}
