/* AlphaFuel Coach — styles. Colors come from CONFIG via CSS vars set in app.js. */
:root {
  --primary: #16a34a;
  --primary-dark: #15803d;
  --bg: #0b0f0c;
  --surface: #141a15;
  --text: #f2f5f2;
  --muted: #9fb3a3;
  --accent: #fbbf24;
  --danger: #ef4444;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--surface);
  position: sticky; top: 0; z-index: 10;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { border-radius: 9px; }
.app-header h1 { margin: 0; font-size: 19px; }
.tagline { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.demo-badge {
  background: var(--accent); color: #111; font-weight: 700; font-size: 11px;
  padding: 4px 10px; border-radius: 20px; letter-spacing: 1px;
}
main { padding: 12px 12px 0; max-width: 560px; margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; animation: fade .18s ease-in; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.card {
  background: var(--surface); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
  border: 1px solid rgba(255,255,255,.05);
}
.card h2 { margin: 0 0 8px; font-size: 17px; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.45; }
.file-btn {
  display: block; text-align: center; padding: 16px; margin: 10px 0;
  border: 2px dashed var(--primary); border-radius: var(--radius);
  font-size: 16px; font-weight: 600; cursor: pointer; color: var(--text);
}
.file-btn:active { background: rgba(22,163,74,.12); }
.preview-wrap img { width: 100%; border-radius: var(--radius); margin: 8px 0; }
.btn-primary, .btn-secondary, .btn-ghost {
  display: block; width: 100%; padding: 13px; margin: 8px 0 0;
  border: none; border-radius: var(--radius); font-size: 15px; font-weight: 700;
  cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-secondary { background: rgba(255,255,255,.09); color: var(--text); width: auto; display: inline-block; padding: 10px 18px; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid rgba(255,255,255,.12); }
.btn-ghost.danger { color: var(--danger); border-color: rgba(239,68,68,.4); }
.analyzing { text-align: center; padding: 20px; color: var(--muted); }
.spinner {
  width: 34px; height: 34px; margin: 0 auto 10px;
  border: 4px solid rgba(255,255,255,.12); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.result-card { margin-top: 12px; }
.big-kcal { font-size: 42px; font-weight: 800; color: var(--primary); }
.big-kcal small { font-size: 16px; color: var(--muted); font-weight: 400; }
.macros { display: flex; gap: 8px; margin: 10px 0; }
.macros > div {
  flex: 1; background: rgba(255,255,255,.04); border-radius: 10px;
  padding: 10px 4px; text-align: center;
}
.macros b { display: block; font-size: 16px; }
.macros span, .macros i { font-size: 11px; color: var(--muted); font-style: normal; }
.items { list-style: none; padding: 0; margin: 8px 0; font-size: 14px; }
.items li { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.confidence { font-size: 12px; color: var(--muted); }
.meal-type { margin: 10px 0; font-size: 14px; }
.meal-type select, input[type="text"], input[type="number"] {
  background: rgba(255,255,255,.07); color: var(--text);
  border: 1px solid rgba(255,255,255,.12); border-radius: 10px;
  padding: 10px; font-size: 15px;
}
.row { display: flex; gap: 8px; align-items: center; }
.row input[type="text"] { flex: 1; }
.row input[type="number"] { width: 90px; }
.budget-bar { height: 12px; background: rgba(255,255,255,.08); border-radius: 8px; overflow: hidden; margin: 8px 0; }
.budget-fill { height: 100%; width: 0%; background: var(--primary); border-radius: 8px; transition: width .3s; }
.budget-fill.over { background: var(--danger); }
.budget-text { font-size: 15px; }
.meals { list-style: none; padding: 0; margin: 0; }
.meals li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 0; border-bottom: 1px solid rgba(255,255,255,.05); font-size: 14px;
}
.meals .del { background: none; border: none; color: var(--muted); font-size: 17px; cursor: pointer; padding: 4px 8px; }
.targets-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.targets-grid label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.week-bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; margin: 10px 0; }
.week-bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.week-bar .bar { width: 100%; background: var(--primary); border-radius: 6px 6px 0 0; min-height: 4px; }
.week-bar .bar.over { background: var(--danger); }
.week-bar small { font-size: 10px; color: var(--muted); }
.coach-note {
  background: rgba(22,163,74,.08); border-left: 3px solid var(--primary);
  padding: 12px; border-radius: 0 10px 10px 0; font-size: 14px; line-height: 1.55;
  white-space: pre-wrap; margin-top: 10px;
}
.license-status { font-size: 13px; font-weight: 600; }
.license-status.ok { color: var(--primary); }
.license-status.bad { color: var(--danger); }
.device-code {
  background: rgba(255,255,255,.07); padding: 10px 14px; border-radius: 10px;
  font-size: 16px; letter-spacing: 2px; user-select: all;
}
.app-footer { text-align: center; padding: 18px 16px 8px; max-width: 560px; margin: 0 auto; }
.app-footer p { font-size: 11px; color: var(--muted); line-height: 1.5; margin: 4px 0; }
.foot-brand { font-weight: 700; }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: var(--surface);
  border-top: 1px solid rgba(255,255,255,.08);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; background: none; border: none; color: var(--muted);
  font-size: 12px; padding: 10px 0 8px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tabbar button.active { color: var(--primary); font-weight: 700; }

/* food picker (instant DB fallback) */
#foodSearch {
  width: 100%; box-sizing: border-box; margin: 8px 0;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12);
  color: var(--text); border-radius: 10px; padding: 12px 14px; font-size: 16px;
}
#foodResults { list-style: none; margin: 4px 0 0; padding: 0; max-height: 300px; overflow-y: auto; }
#foodResults li { margin: 6px 0; }
.food-pick {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1);
  color: var(--text); border-radius: 10px; padding: 12px 14px; font-size: 15px; cursor: pointer;
  text-align: left;
}
.food-pick:active { background: rgba(255,255,255,.12); }
.food-pick b { color: var(--accent); white-space: nowrap; }
#manualPickBtn { margin-top: 10px; }

/* v9 — local food picker: categories, tray, portions */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip {
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1);
  color: var(--text); border-radius: 20px; padding: 8px 12px; font-size: 13px; cursor: pointer;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
#foodResults mark { background: var(--accent); color: #111; border-radius: 3px; padding: 0 2px; }
#foodResults .muted { color: var(--muted); font-size: 12px; }
.tray-title { margin: 14px 0 6px; font-size: 15px; }
.tray { list-style: none; padding: 0; margin: 0; }
.tray .hint { padding: 6px 0; }
.tray-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.05); font-size: 14px;
}
.tray-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portion-steps { display: flex; gap: 4px; }
.pstep {
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12);
  color: var(--muted); border-radius: 8px; padding: 6px 8px; font-size: 12px; cursor: pointer;
}
.pstep.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.tray-kcal { color: var(--accent); white-space: nowrap; font-size: 14px; }
.tray-rm { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 2px 6px; }
.tray-total { margin-top: 10px; text-align: center; }
.meal-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; margin-right: 8px; flex-shrink: 0; }
.week-summary p { font-size: 14px; line-height: 1.5; margin: 6px 0; }
.week-summary {
  background: rgba(22,163,74,.08); border-left: 3px solid var(--primary);
  padding: 12px; border-radius: 0 10px 10px 0; margin-top: 10px;
}
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: #1d2620; color: var(--text); border: 1px solid rgba(255,255,255,.15);
  padding: 12px 18px; border-radius: 12px; font-size: 14px; max-width: 88vw; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
