:root {
  color-scheme: dark;
  --bg: #070707;
  --panel: #111111;
  --panel-2: #171717;
  --line: #2a2a2a;
  --text: #f4f4f4;
  --muted: #989898;
  --accent: #d6ff3f;
  --accent-ink: #111500;
  --danger: #ff6262;
  --safe: #72f7a0;
  --warn: #ffc857;
  --radius: 22px;
  --shadow: 0 18px 50px rgba(0,0,0,.28);
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #161616 0, #080808 28rem, #070707 100%);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button,input,select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.app-shell { width: min(100%, 560px); margin: 0 auto; min-height: 100vh; padding: env(safe-area-inset-top) 16px calc(100px + env(safe-area-inset-bottom)); }
.topbar { display:flex; align-items:center; justify-content:space-between; padding: 18px 4px 16px; position:sticky; top:0; z-index:10; background:linear-gradient(to bottom, rgba(7,7,7,.98) 60%, rgba(7,7,7,0)); backdrop-filter: blur(14px); }
.brand { font-size: 1.45rem; font-weight: 950; letter-spacing:.08em; }
.subbrand { color: var(--muted); font-size:.69rem; letter-spacing:.18em; font-weight:800; margin-top:2px; }
.beta-pill { color: var(--accent); border:1px solid #5d6d22; border-radius:999px; padding:2px 6px; letter-spacing:.08em; }
.date-button { border:1px solid var(--line); background:#111; color:#ddd; padding:10px 13px; border-radius:14px; font-size:.82rem; font-weight:800; }
.view { display:none; animation: fade .18s ease; }
.view.active { display:block; }
@keyframes fade { from{opacity:.55; transform:translateY(4px)} to{opacity:1; transform:none} }
.hero-card, .panel { background:linear-gradient(180deg,#141414,#0f0f0f); border:1px solid #242424; border-radius:var(--radius); box-shadow:var(--shadow); }
.hero-card { padding:24px 22px 20px; }
.hero-label,.eyebrow,.macro-name { color:var(--muted); font-size:.69rem; font-weight:900; letter-spacing:.18em; }
.calorie-line { display:flex; align-items:baseline; gap:8px; margin-top:8px; }
.calorie-line strong { font-size:3.3rem; line-height:1; letter-spacing:-.06em; }
.calorie-line span { color:#9f9f9f; font-size:1.08rem; }
.remaining-line { color:#bbb; margin-top:10px; font-size:.92rem; }
.progress-track,.mini-track { background:#292929; overflow:hidden; border-radius:999px; }
.progress-track { height:9px; margin-top:18px; }
.progress-fill,.mini-fill { height:100%; width:0%; border-radius:inherit; background:var(--accent); transition:width .3s ease; }
.macro-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; margin-top:10px; }
.macro-card { background:var(--panel); border:1px solid #242424; border-radius:18px; padding:16px 13px 14px; }
.macro-card strong { font-size:1.15rem; }
.macro-card span { color:var(--muted); font-size:.7rem; }
.macro-name { margin-bottom:9px; letter-spacing:.1em; font-size:.61rem; }
.mini-track { height:5px; margin-top:12px; }
.action-row { display:grid; grid-template-columns:1.6fr 1fr; gap:10px; margin:14px 0; }
.primary-button,.secondary-button,.danger-button,.small-button { border:0; border-radius:16px; font-weight:900; letter-spacing:.04em; cursor:pointer; min-height:48px; }
.primary-button { background:var(--accent); color:var(--accent-ink); }
.secondary-button { background:#1b1b1b; color:#f0f0f0; border:1px solid #303030; }
.danger-button { width:100%; background:#271414; color:#ff8d8d; border:1px solid #5b2727; }
.small-button { min-height:38px; padding:0 14px; background:#1b1b1b; color:#eee; border:1px solid #303030; }
.full { width:100%; }
.panel { padding:20px; margin-top:14px; }
.panel-heading { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-bottom:14px; }
.panel-heading.compact { margin-bottom:8px; }
h2 { font-size:1.18rem; margin:4px 0 0; letter-spacing:-.02em; }
.muted { color:var(--muted); font-size:.83rem; }
.food-list { display:flex; flex-direction:column; gap:10px; }
.meal-group { background:#131313; border:1px solid #252525; border-radius:17px; padding:0 14px; overflow:hidden; }
.meal-group-empty { background:#111; }
.meal-heading { min-height:62px; display:flex; align-items:center; justify-content:space-between; gap:12px; }
.meal-heading h3 { margin:0 0 3px; font-size:.92rem; letter-spacing:.01em; }
.meal-heading span { color:#777; font-size:.72rem; }
.meal-add-button { width:38px; height:38px; flex:0 0 38px; border-radius:12px; border:1px solid #303030; background:#1b1b1b; color:var(--accent); font-size:1.35rem; line-height:1; font-weight:900; }
.meal-items:empty { display:none; }
.meal-items .food-entry:first-child { border-top:1px solid #242424; }
.food-entry { display:grid; grid-template-columns:1fr auto; gap:10px; align-items:center; padding:14px 0; border-top:1px solid #242424; }
.food-entry:first-child { border-top:0; }
.food-entry h3 { margin:0 0 4px; font-size:.95rem; }
.food-entry .meta { color:var(--muted); font-size:.78rem; }
.food-kcal { text-align:right; }
.food-kcal strong { font-size:.95rem; display:block; }
.delete-entry { border:0; background:transparent; color:#777; font-size:1.3rem; padding:5px 0 5px 10px; }
.empty-state { padding:28px 8px 18px; text-align:center; color:#777; font-size:.9rem; }
.recommendation-panel { border-color:#30361b; }
.recommendation-badge { display:inline-block; margin-top:8px; background:#252a16; color:var(--accent); border:1px solid #434d20; border-radius:999px; padding:8px 11px; font-size:.72rem; font-weight:950; letter-spacing:.08em; }
.recommendation-copy,.small-copy { color:#a7a7a7; line-height:1.55; font-size:.9rem; margin-bottom:0; }
.progress-stats { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-top:12px; }
.stat-box { background:#171717; border:1px solid #252525; border-radius:16px; padding:13px 10px; }
.stat-box span { display:block; color:#888; font-size:.67rem; margin-bottom:6px; }
.stat-box strong { font-size:.9rem; }
.chart-wrap { margin:20px 0 8px; min-height:150px; border-radius:16px; overflow:hidden; background:linear-gradient(180deg,#161616,#101010); border:1px solid #222; }
.chart-wrap svg { display:block; width:100%; height:160px; }
.history-row { display:flex; justify-content:space-between; gap:12px; border-top:1px solid #242424; padding:13px 0; font-size:.86rem; }
.history-row span { color:#888; }
.rule-row { display:flex; justify-content:space-between; gap:10px; border-top:1px solid #252525; padding:13px 0; margin-top:12px; font-size:.78rem; }
.rule-row span { color:#888; font-weight:900; letter-spacing:.08em; }
.form-stack { display:flex; flex-direction:column; gap:14px; margin-top:16px; }
.two-col { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
label { color:#a6a6a6; font-size:.77rem; font-weight:750; display:flex; flex-direction:column; gap:7px; }
input,select { width:100%; background:#181818; color:#f5f5f5; border:1px solid #303030; border-radius:14px; padding:13px 12px; outline:none; min-height:46px; }
input:focus,select:focus { border-color:#687429; box-shadow:0 0 0 3px rgba(214,255,63,.08); }
.checkbox-label { flex-direction:row; align-items:center; gap:9px; }
.checkbox-label input { width:20px; min-height:auto; accent-color:var(--accent); }
.stack-buttons { display:flex; flex-direction:column; gap:10px; margin-top:16px; }
.bottom-nav { position:fixed; left:50%; transform:translateX(-50%); bottom:0; z-index:20; width:min(100%,560px); display:grid; grid-template-columns:repeat(4,1fr); padding:10px 10px calc(10px + env(safe-area-inset-bottom)); background:rgba(8,8,8,.94); border-top:1px solid #202020; backdrop-filter:blur(18px); }
.nav-button { background:transparent; color:#777; border:0; padding:7px 4px; font-size:.72rem; font-weight:850; display:flex; flex-direction:column; align-items:center; gap:4px; }
.nav-button span { font-size:1.05rem; }
.nav-button.active { color:var(--accent); }
dialog { padding:0; border:0; background:transparent; color:var(--text); }
dialog::backdrop { background:rgba(0,0,0,.74); backdrop-filter:blur(4px); }
.sheet-dialog { width:min(100% - 20px,540px); max-height:90vh; margin:auto auto 10px; }
.sheet { background:#0f0f0f; border:1px solid #292929; border-radius:26px 26px 22px 22px; padding:10px 18px 20px; max-height:88vh; overflow:auto; }
.sheet-handle { width:44px; height:5px; background:#3c3c3c; border-radius:99px; margin:0 auto 12px; }
.sheet-heading { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:14px; }
.close-button { border:0; background:#1d1d1d; color:#bbb; border-radius:50%; width:36px; height:36px; font-size:1.5rem; line-height:1; }
.mode-switch { display:grid; grid-template-columns:1fr 1fr; gap:6px; background:#171717; border-radius:14px; padding:5px; margin-bottom:16px; }
.mode-button { border:0; border-radius:10px; padding:10px; color:#888; background:transparent; font-weight:850; }
.mode-button.active { color:#111; background:var(--accent); }
.hidden { display:none !important; }
.saved-foods-section { margin-bottom:16px; }
.saved-foods { display:flex; gap:8px; overflow-x:auto; padding:3px 0 6px; }
.saved-chip { flex:0 0 auto; border:1px solid #303030; background:#171717; color:#ddd; border-radius:999px; padding:9px 12px; font-size:.78rem; }
.barcode-box { display:flex; flex-direction:column; gap:12px; }
.status-copy { color:#999; text-align:center; padding:12px 4px; font-size:.85rem; }
.product-card { display:flex; align-items:center; gap:12px; background:#161616; border:1px solid #282828; border-radius:16px; padding:12px; margin-bottom:14px; }
.product-image { width:58px; height:58px; object-fit:contain; border-radius:10px; background:#fff; }
.serving-macros { background:#171717; border:1px solid #282828; border-radius:14px; padding:12px; color:#bbb; font-size:.84rem; line-height:1.6; }
.scanner-dialog { width:100vw; height:100vh; max-width:none; max-height:none; }
.scanner-shell { width:100%; height:100%; background:#000; position:relative; overflow:hidden; }
#scannerVideo { width:100%; height:100%; object-fit:cover; }
.scan-frame { position:absolute; left:12%; right:12%; top:36%; height:170px; border:2px solid var(--accent); border-radius:18px; box-shadow:0 0 0 9999px rgba(0,0,0,.38); }
.scanner-overlay { position:absolute; inset:0; pointer-events:none; }
.scanner-close { pointer-events:auto; position:absolute; top:calc(18px + env(safe-area-inset-top)); right:18px; border:0; background:rgba(0,0,0,.65); color:white; width:44px; height:44px; border-radius:50%; font-size:1.7rem; }
.scanner-copy { position:absolute; top:calc(36% + 190px); left:20px; right:20px; text-align:center; font-weight:800; text-shadow:0 1px 10px #000; }
.small-dialog { max-width:420px; margin:auto; }
.small-dialog .sheet { display:flex; flex-direction:column; gap:12px; }
.toast { position:fixed; left:50%; bottom:calc(88px + env(safe-area-inset-bottom)); transform:translate(-50%,20px); background:#ededed; color:#111; padding:11px 15px; border-radius:999px; font-weight:850; font-size:.8rem; opacity:0; pointer-events:none; transition:.2s; z-index:99; white-space:nowrap; max-width:90%; overflow:hidden; text-overflow:ellipsis; }
.toast.show { opacity:1; transform:translate(-50%,0); }
@media (max-width:390px) {
  .app-shell { padding-left:12px; padding-right:12px; }
  .calorie-line strong { font-size:3rem; }
  .macro-card { padding-left:10px; padding-right:10px; }
  .macro-card strong { font-size:1.02rem; }
  .macro-card span { font-size:.62rem; }
  .progress-stats { grid-template-columns:1fr; }
}

/* v1.1 onboarding + sharing */
.share-beta-button { margin-top:16px; }
.share-url { color:#8f8f8f; font-size:.72rem; word-break:break-all; margin:12px 0 0; }
.onboarding-dialog { width:100vw; height:100vh; max-width:none; max-height:none; margin:0; background:#070707; }
.onboarding-dialog::backdrop { background:#070707; }
.onboarding-shell { min-height:100%; padding:calc(36px + env(safe-area-inset-top)) 24px calc(30px + env(safe-area-inset-bottom)); background:radial-gradient(circle at 50% 0%, rgba(214,255,63,.08), transparent 34%), #070707; overflow:auto; }
.onboarding-brand { font-size:2rem; font-weight:1000; letter-spacing:.08em; }
.onboarding-sub { margin-top:4px; color:#929292; font-weight:900; letter-spacing:.18em; font-size:.78rem; }
.onboarding-step { max-width:520px; margin:70px auto 0; }
.onboarding-step h1 { margin:8px 0 10px; font-size:2rem; line-height:1.05; letter-spacing:-.045em; }
.onboarding-copy { color:#979797; line-height:1.5; margin:0 0 24px; }
.goal-picker { display:flex; flex-direction:column; gap:10px; }
.goal-choice { text-align:left; background:#111; color:#eee; border:1px solid #292929; border-radius:20px; padding:18px; display:flex; flex-direction:column; gap:5px; }
.goal-choice strong { letter-spacing:.08em; font-size:.95rem; }
.goal-choice span { color:#888; font-size:.82rem; line-height:1.35; }
.goal-choice.selected { border-color:#6f7d25; box-shadow:0 0 0 2px rgba(214,255,63,.06); }
.goal-choice.selected strong { color:var(--accent); }
.onboarding-back { border:0; background:transparent; color:#999; font-weight:850; padding:0 0 18px; }
.onboarding-form { margin-top:22px; }
.device-note { text-align:center; color:#666; font-size:.72rem; margin-top:14px; }


/* v2.0 premium coaching */
.pro-pill { color:var(--accent); border:1px solid #596521; background:#171b0c; border-radius:999px; padding:6px 9px; font-size:.63rem; font-weight:950; letter-spacing:.09em; white-space:nowrap; }
.coach-hero { border-color:#3b441d; background:radial-gradient(circle at 80% 0%,rgba(214,255,63,.09),transparent 38%),linear-gradient(180deg,#15170f,#10110d); }
.coach-title-row { display:flex; align-items:flex-start; justify-content:space-between; gap:14px; }
.coach-decision { margin-top:20px; color:var(--accent); font-size:1.65rem; font-weight:1000; letter-spacing:-.035em; line-height:1; }
.coach-summary { color:#b3b3b3; font-size:.92rem; line-height:1.55; margin:12px 0 0; }
.coach-action-wrap { margin-top:18px; background:#171a10; border:1px solid #3e491c; border-radius:17px; padding:13px; display:grid; grid-template-columns:1fr auto; align-items:center; gap:12px; }
.coach-action-wrap span { display:block; color:#8f8f8f; font-size:.67rem; margin-bottom:3px; }
.coach-action-wrap strong { font-size:1.25rem; }
.coach-action-wrap .primary-button { min-height:42px; padding:0 13px; font-size:.72rem; }
.coach-kpi-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-top:14px; }
.coach-kpi { background:#111; border:1px solid #242424; border-radius:18px; padding:15px 14px; min-height:102px; }
.coach-kpi span { display:block; color:#8c8c8c; font-size:.67rem; margin-bottom:8px; }
.coach-kpi strong { display:block; font-size:1.05rem; line-height:1.1; }
.coach-kpi small { display:block; color:#666; font-size:.62rem; margin-top:6px; line-height:1.25; }
.coach-reasons { display:flex; flex-direction:column; margin-top:12px; }
.coach-reason { display:grid; grid-template-columns:28px 1fr; gap:10px; align-items:flex-start; padding:12px 0; border-top:1px solid #242424; }
.coach-reason:first-child { border-top:0; }
.coach-reason .reason-icon { width:26px; height:26px; display:grid; place-items:center; border-radius:9px; background:#1a1d10; color:var(--accent); font-weight:950; }
.coach-reason strong { display:block; font-size:.85rem; margin-bottom:3px; }
.coach-reason p { margin:0; color:#8e8e8e; font-size:.78rem; line-height:1.4; }
.coach-meter-row { display:flex; justify-content:space-between; gap:12px; align-items:center; margin-top:16px; font-size:.78rem; }
.coach-meter-row span { color:#999; }
.coach-meter { height:7px; border-radius:999px; background:#272727; overflow:hidden; margin-top:7px; }
.coach-meter > div { height:100%; width:0; background:var(--accent); border-radius:inherit; transition:width .3s ease; }
.projection-card { margin-top:14px; background:#151515; border:1px solid #282828; border-radius:17px; padding:16px; }
.projection-card > span { display:block; color:#888; font-size:.72rem; }
.projection-card > strong { display:block; font-size:1.65rem; margin-top:6px; letter-spacing:-.035em; }
.weekly-report { color:#c0c0c0; line-height:1.6; font-size:.9rem; margin:14px 0 0; }
.coach-disclaimer { color:#5f5f5f; font-size:.66rem; line-height:1.45; border-top:1px solid #232323; padding-top:12px; margin-top:16px; }
.pro-settings-panel { border-color:#33391d; }
@media (max-width:390px) {
  .bottom-nav { padding-left:6px; padding-right:6px; }
  .nav-button { font-size:.66rem; }
  .coach-kpi-grid { grid-template-columns:1fr 1fr; }
}


/* v2.1 profile + target calculator */
.calc-note { margin:-4px 2px 2px; color:#9b9b9b; font-size:.82rem; line-height:1.45; }
.calculator-result { margin-top:18px; padding:16px; border:1px solid #2d2d2d; border-radius:18px; background:#0c0c0c; display:grid; gap:12px; }
.calculator-result.hidden { display:none; }
.calculator-result > div { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.calculator-result span { color:#8f8f8f; font-size:.84rem; }
.calculator-result strong { font-size:1.05rem; }
.onboarding-estimate-card { margin:20px 0 8px; padding:18px; border:1px solid #334008; border-radius:20px; background:linear-gradient(135deg,rgba(214,255,63,.09),rgba(214,255,63,.02)); display:grid; gap:6px; }
.onboarding-estimate-card span { color:#999; font-size:.78rem; font-weight:850; letter-spacing:.08em; text-transform:uppercase; }
.onboarding-estimate-card strong { font-size:1.8rem; color:#d6ff3f; }
.onboarding-estimate-card small { color:#9a9a9a; line-height:1.4; }

/* v2.3 camera-first barcode UX */
.barcode-camera-first { padding:4px 0 14px; }
.barcode-help { margin:6px 0 14px; color:var(--muted); line-height:1.45; }
.scan-camera-button { min-height:56px; font-size:1rem; letter-spacing:.02em; }
.barcode-manual-fallback { margin-top:10px; border-top:1px solid var(--line); padding-top:12px; }
.barcode-manual-fallback summary { cursor:pointer; color:var(--muted); font-weight:700; padding:8px 0 12px; }
.barcode-manual-fallback[open] summary { color:var(--text); }

.training-return{position:fixed;z-index:80;right:12px;top:calc(9px + env(safe-area-inset-top));border:1px solid #2c4f65;background:rgba(10,20,27,.92);color:#9fd8ff;border-radius:999px;padding:8px 10px;text-decoration:none;font-size:.55rem;font-weight:950;letter-spacing:.04em;backdrop-filter:blur(12px)}
