:root{
  --bg:#0A0A0A;
  --surface:#161616;
  --surface-2:#1F1F1F;
  --line:#2A2A2A;
  --text:#FFFFFF;
  --muted:#8A8A8A;
  --accent:#C7F94E;      /* verde-lima: progreso / logro */
  --accent-dim:#2b3417;
  --win:#C7F94E;         /* ahorraste calorías */
  --lose:#FF6B5A;        /* te pasaste */
  --p:#4ADE80;           /* proteína */
  --c:#FBBF24;           /* carbos */
  --f:#60A5FA;           /* grasas */
  --safe-bottom:env(safe-area-inset-bottom,0px);
  --safe-top:env(safe-area-inset-top,0px);
}

*{box-sizing:border-box;margin:0;padding:0;-webkit-tap-highlight-color:transparent}
html,body{height:100%}
body{
  background:var(--bg);color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,system-ui,sans-serif;
  overscroll-behavior:none;
}

/* ===== Layout general ===== */
.view{min-height:100%}
.screen{padding:calc(var(--safe-top) + 12px) 20px 120px}
.topbar{display:flex;align-items:center;justify-content:space-between;margin-bottom:18px}
.logo{font-size:20px;font-weight:800;letter-spacing:-.02em}
.streak{background:var(--surface);border:1px solid var(--line);padding:6px 12px;border-radius:999px;font-weight:700;font-size:14px}
.section-title{font-size:15px;color:var(--muted);margin:24px 0 12px;font-weight:600}

/* ===== Anillo de progreso ===== */
.ring-wrap{position:relative;width:230px;height:230px;margin:8px auto 0}
.ring{width:100%;height:100%;transform:rotate(-90deg)}
.ring-bg{fill:none;stroke:var(--surface-2);stroke-width:14}
.ring-fg{fill:none;stroke:var(--accent);stroke-width:14;stroke-linecap:round;
  stroke-dasharray:540;stroke-dashoffset:540;transition:stroke-dashoffset .8s cubic-bezier(.2,.8,.2,1)}
.ring-center{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center}
.kcal-left{font-size:52px;font-weight:800;line-height:1;letter-spacing:-.03em}
.kcal-label{font-size:13px;color:var(--muted);margin-top:4px}

/* ===== Chip de balance (logro) ===== */
.balance-chip{margin:18px auto 0;text-align:center;font-weight:700;font-size:15px;
  padding:12px 16px;border-radius:16px;max-width:340px}
.balance-chip.win{background:var(--accent-dim);color:var(--win);border:1px solid #3d4a20}
.balance-chip.lose{background:#2c1917;color:var(--lose);border:1px solid #4a2420}

/* ===== Macros ===== */
.macros{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin-top:22px}
.macro{background:var(--surface);border:1px solid var(--line);border-radius:16px;padding:14px 12px;text-align:center}
.macro-bar{height:6px;background:var(--surface-2);border-radius:99px;overflow:hidden;margin-bottom:10px}
.macro-fill{height:100%;width:0;border-radius:99px;transition:width .6s ease}
.macro-fill.p{background:var(--p)}
.macro-fill.c{background:var(--c)}
.macro-fill.f{background:var(--f)}
.macro-txt{display:block;font-weight:800;font-size:16px}
.macro-name{display:block;font-size:12px;color:var(--muted);margin-top:2px}

/* ===== Lista de comidas ===== */
.meal-list{display:flex;flex-direction:column;gap:10px}
.empty,.soon{color:var(--muted);font-size:14px;text-align:center;padding:24px 8px;line-height:1.5}
.meal-item{display:flex;align-items:center;gap:12px;background:var(--surface);border:1px solid var(--line);border-radius:16px;padding:12px 14px;cursor:pointer}
.meal-item:active{background:var(--surface-2)}
.m-edit{font-size:14px;opacity:.5;margin-left:2px}
.meal-item .m-emoji{font-size:24px}
.meal-item .m-info{flex:1}
.meal-item .m-name{font-weight:700;font-size:15px}
.meal-item .m-sub{font-size:12px;color:var(--muted)}
.meal-item .m-kcal{font-weight:800}

/* ===== Cards (Progreso) ===== */
.card{background:var(--surface);border:1px solid var(--line);border-radius:20px;padding:20px;margin-bottom:14px;display:flex;flex-direction:column;gap:8px}
.card-label{font-size:13px;color:var(--muted);font-weight:600}
.big-number{font-size:40px;font-weight:800;letter-spacing:-.03em}
.big-number small{font-size:18px;color:var(--muted);font-weight:600}
.card-sub{font-size:13px;color:var(--muted);line-height:1.4}

/* ===== Botones ===== */
.ghost-btn{background:var(--surface-2);color:var(--text);border:1px solid var(--line);
  border-radius:12px;padding:12px 16px;font-weight:700;font-size:15px;cursor:pointer;margin-top:6px}
.ghost-btn:active{transform:scale(.98)}

/* ===== Tab bar ===== */
.tabbar{position:fixed;left:0;right:0;bottom:0;height:calc(68px + var(--safe-bottom));
  padding-bottom:var(--safe-bottom);
  background:rgba(14,14,14,.92);backdrop-filter:blur(18px);border-top:1px solid var(--line);
  display:flex;align-items:center;justify-content:space-around;z-index:20}
.tab{background:none;border:none;color:var(--muted);display:flex;flex-direction:column;align-items:center;gap:3px;font-size:11px;font-weight:600;cursor:pointer;flex:1}
.tab .ico{font-size:20px;filter:grayscale(1) opacity(.7)}
.tab.active{color:var(--accent)}
.tab.active .ico{filter:none}
.fab{width:60px;height:60px;border-radius:50%;border:none;background:var(--accent);color:#0A0A0A;
  font-size:26px;cursor:pointer;box-shadow:0 8px 24px rgba(199,249,78,.3);margin-top:-24px;flex:0 0 auto}
.fab:active{transform:scale(.94)}

/* ===== Hoja de captura ===== */
.sheet{position:fixed;inset:0;z-index:40;display:flex;align-items:flex-end;
  background:rgba(0,0,0,.6);animation:fade .2s ease}
.sheet-inner{width:100%;background:var(--surface);border-radius:24px 24px 0 0;padding:12px 20px calc(28px + var(--safe-bottom));animation:slideup .25s cubic-bezier(.2,.8,.2,1)}
.sheet-handle{width:40px;height:4px;background:var(--line);border-radius:99px;margin:4px auto 18px}
.sheet-inner h3{font-size:18px;margin-bottom:16px}
.capture-opts{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin-bottom:14px}
.cap-opt{background:var(--surface-2);border:1px solid var(--line);border-radius:16px;padding:18px 8px;color:var(--text);font-weight:700;font-size:14px;display:flex;flex-direction:column;gap:8px;align-items:center;cursor:pointer}
.cap-opt span{font-size:26px}
@keyframes fade{from{opacity:0}to{opacity:1}}
@keyframes slideup{from{transform:translateY(100%)}to{transform:translateY(0)}}

/* ===== Onboarding ===== */
.ob{min-height:100%;display:flex;flex-direction:column;padding:calc(var(--safe-top) + 40px) 24px calc(40px + var(--safe-bottom))}
.ob-progress{display:flex;gap:6px;margin-bottom:40px}
.ob-dot{flex:1;height:4px;border-radius:99px;background:var(--surface-2)}
.ob-dot.on{background:var(--accent)}
.ob-step{flex:1;display:flex;flex-direction:column;animation:fade .3s ease}
.ob-q{font-size:28px;font-weight:800;letter-spacing:-.03em;line-height:1.15;margin-bottom:8px}
.ob-hint{color:var(--muted);font-size:15px;margin-bottom:32px;line-height:1.4}
.ob-options{display:flex;flex-direction:column;gap:12px}
.ob-opt{background:var(--surface);border:1.5px solid var(--line);border-radius:16px;padding:18px 20px;color:var(--text);font-size:16px;font-weight:700;text-align:left;cursor:pointer;transition:.15s}
.ob-opt.sel{border-color:var(--accent);background:var(--accent-dim)}
.ob-opt .sub{display:block;font-weight:500;font-size:13px;color:var(--muted);margin-top:3px}
.ob-row{display:flex;gap:12px}
.ob-field{flex:1;display:flex;flex-direction:column;gap:8px}
.ob-field label{font-size:13px;color:var(--muted);font-weight:600}
.ob-field input{background:var(--surface);border:1.5px solid var(--line);border-radius:14px;padding:16px;color:var(--text);font-size:22px;font-weight:800;text-align:center;width:100%}
.ob-field input:focus{outline:none;border-color:var(--accent)}
.ob-cta{margin-top:auto;background:var(--accent);color:#0A0A0A;border:none;border-radius:16px;padding:18px;font-size:17px;font-weight:800;cursor:pointer}
.ob-cta:disabled{opacity:.35}
.ob-cta:active{transform:scale(.99)}
.ob-result{text-align:center;margin:auto 0}
.ob-result .goal-kcal{font-size:64px;font-weight:800;letter-spacing:-.04em;color:var(--accent);line-height:1}
.ob-result .goal-label{color:var(--muted);margin:8px 0 28px}
.ob-result .goal-macros{display:flex;justify-content:center;gap:24px}
.ob-result .gm{display:flex;flex-direction:column}
.ob-result .gm b{font-size:22px}
.ob-result .gm span{font-size:12px;color:var(--muted)}

/* ===== Ajustes ===== */
.settings-body{display:flex;flex-direction:column;gap:2px}
.set-row{display:flex;align-items:center;justify-content:space-between;background:var(--surface);border:1px solid var(--line);padding:16px;border-radius:14px;margin-bottom:8px}
.set-row .k{color:var(--muted);font-size:14px}
.set-row .v{font-weight:700}

/* ===== Resultado de análisis ===== */
.res-kcal{font-size:44px;font-weight:800;text-align:center;letter-spacing:-.03em;margin:6px 0}
.res-kcal small{font-size:18px;color:var(--muted);font-weight:600}
.res-macros{display:flex;justify-content:center;gap:22px;margin-bottom:12px;color:var(--muted);font-size:14px}
.res-macros b{color:#fff;font-size:17px}
.res-note{font-size:13px;color:var(--muted);text-align:center;margin-bottom:10px;line-height:1.4}
.res-items{display:flex;flex-direction:column;gap:6px;margin-bottom:16px;max-height:180px;overflow-y:auto}
.res-item{display:flex;justify-content:space-between;background:var(--surface-2);border-radius:10px;padding:9px 12px;font-size:14px}
.res-item em{color:var(--muted);font-style:normal}
.res-portion-label{display:block;font-size:14px;color:var(--muted);margin-bottom:8px}
.res-portion-label b{color:var(--accent)}
.res-slider{width:100%;accent-color:var(--accent);margin-bottom:16px}
.res-actions{display:flex;gap:10px}
.spinner{width:34px;height:34px;border:3px solid var(--surface-2);border-top-color:var(--accent);border-radius:50%;margin:24px auto;animation:spin .8s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

/* ===== Escáner de cámara ===== */
.sheet-inner.cam-full{border-radius:0;padding:0;background:#000;height:100vh;height:100dvh}
.cam-view{position:relative;width:100%;height:100%;overflow:hidden;background:#000}
.cam-view video{width:100%;height:100%;object-fit:cover}
.cam-frame{position:absolute;top:50%;left:50%;transform:translate(-50%,-54%);width:74vw;height:74vw;max-width:340px;max-height:340px}
.cam-frame i{position:absolute;width:34px;height:34px;border:3px solid var(--accent)}
.cam-frame i:nth-child(1){top:0;left:0;border-right:none;border-bottom:none;border-radius:10px 0 0 0}
.cam-frame i:nth-child(2){top:0;right:0;border-left:none;border-bottom:none;border-radius:0 10px 0 0}
.cam-frame i:nth-child(3){bottom:0;left:0;border-right:none;border-top:none;border-radius:0 0 0 10px}
.cam-frame i:nth-child(4){bottom:0;right:0;border-left:none;border-top:none;border-radius:0 0 10px 0}
.cam-hint{position:absolute;top:calc(var(--safe-top) + 70px);left:0;right:0;text-align:center;color:#fff;font-size:14px;font-weight:600;text-shadow:0 1px 4px rgba(0,0,0,.6)}
.cam-close{position:absolute;top:calc(var(--safe-top) + 14px);right:16px;width:40px;height:40px;border-radius:50%;border:none;background:rgba(0,0,0,.5);color:#fff;font-size:18px;cursor:pointer}
.cam-bar{position:absolute;left:0;right:0;bottom:calc(var(--safe-bottom) + 28px);display:flex;align-items:center;justify-content:space-around;padding:0 32px}
.cam-shoot{width:74px;height:74px;border-radius:50%;background:#fff;border:5px solid rgba(255,255,255,.4);cursor:pointer;background-clip:padding-box}
.cam-shoot:active{transform:scale(.92)}
.cam-gallery{width:52px;height:52px;border-radius:14px;border:none;background:rgba(255,255,255,.15);color:#fff;font-size:24px;cursor:pointer;backdrop-filter:blur(6px)}
.cam-spacer{width:52px}

[hidden]{display:none !important}
