/* App-level layout and the components v6 did not include.
   Colour comes from tokens.css only — no raw hex in this file. */

* { box-sizing: border-box; }

/* The hidden attribute's default display:none loses to any explicit display
   rule. Without this, `el.hidden = true` silently does nothing on flex/grid
   components — a bug we hit twice. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- screens ---------- */

.scr {
  display: none;
  padding: 56px 18px 96px;
  max-width: 480px;
  margin: 0 auto;
}
.scr.on { display: block; }

/* ---------- language bar ---------- */

.lang-bar {
  position: fixed;
  top: 8px; right: 8px;
  z-index: 50;
  display: flex;
  gap: 4px;
  background: var(--surface);
  border-radius: 999px;
  padding: 4px;
  box-shadow: var(--shadow-sm);
}
.lang-btn {
  border: 0;
  background: transparent;
  color: var(--text2);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.lang-btn.on { background: var(--green); color: var(--surface); }

/* ---------- forms ---------- */

.form-error {
  display: none;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--amber2);
  color: var(--red);
  font-size: 13px;
}

.btn-primary, .btn-secondary {
  flex: 1;
  padding: 14px;
  border-radius: var(--radius);
  border: 0;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.btn-primary { background: var(--green); color: var(--surface); }
.btn-secondary { background: var(--surface2); color: var(--text2); }

/* ---------- home ---------- */

.home-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.ht-greet { font-size: 13px; color: var(--text2); }
.ht-name { font-size: 22px; font-weight: 800; }
.ht-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--green);
  color: var(--surface);
  display: grid; place-items: center;
  font-weight: 800;
}

.ring-row, .week-wrap, .today-meals {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.ri-title { font-size: 13px; font-weight: 700; color: var(--text2); margin-bottom: 8px; }
.ri-sub { font-size: 13px; color: var(--text2); }

.score-big { font-size: 44px; font-weight: 900; line-height: 1; }
.score-band { font-size: 14px; font-weight: 700; }
.score-row { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }

.daily-feedback {
  background: var(--green3);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- week chart ---------- */

.week-chart { display: flex; align-items: flex-end; gap: 6px; height: 120px; }
.wk-bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.wk-fill { border-radius: 6px 6px 0 0; min-height: 3px; transition: height .3s ease; }
.wk-day { font-size: 10px; color: var(--text3); text-align: center; margin-top: 4px; }

.empty { color: var(--text3); font-size: 13px; padding: 12px 0; text-align: center; }

/* ---------- meals ---------- */

.meal-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.meal-row:last-child { border-bottom: 0; }
.meal-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.meal-name { flex: 1; font-size: 14px; }
.meal-score { font-weight: 800; }

/* ---------- scan ---------- */

.scan-busy { text-align: center; padding: 24px; color: var(--text2); }
.spinner {
  width: 28px; height: 28px;
  margin: 0 auto 10px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.scan-confirm, .scan-result {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  margin-top: 14px;
  box-shadow: var(--shadow-sm);
}
.sc-q { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.sc-actions { display: flex; gap: 10px; margin-top: 14px; }

.portion-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.p-name { width: 96px; color: var(--text2); }
.p-bar { flex: 1; height: 8px; background: var(--surface2); border-radius: 999px; overflow: hidden; }
.p-fill { height: 100%; background: var(--green); border-radius: 999px; }
.p-val { width: 44px; text-align: right; font-weight: 700; color: var(--text2); }

.verdict { margin-top: 12px; font-size: 14px; line-height: 1.5; color: var(--text); }

/* ---------- bottom nav ---------- */

.bnav {
  position: fixed;
  bottom: 34px; left: 0; right: 0;
  z-index: 40;
  display: flex;
  max-width: 480px;
  margin: 0 auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.bn { flex: 1; text-align: center; padding: 10px 0; cursor: pointer; color: var(--text3); }
.bn.on { color: var(--green); }
.bn-i { font-size: 18px; }
.bn-l { font-size: 10px; font-weight: 700; }

/* ---------- onboarding (spec 5) ---------- */

.onb-optional-note {
  margin-top: 14px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--blue2);
  color: var(--text2);
  font-size: 12px;
  line-height: 1.5;
}
.input-field.invalid { border-color: var(--red); }

/* ---------- correction editor (spec 18) ---------- */

.edit-row { display: flex; gap: 6px; margin-bottom: 8px; align-items: center; }
.edit-name { flex: 1; min-width: 0; }
.edit-grams { width: 68px; }
.edit-row input, .edit-row select {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}
.edit-group { width: 104px; }
.edit-del {
  border: 0; background: var(--surface2); color: var(--text2);
  width: 28px; height: 28px; border-radius: 50%;
  font-size: 16px; cursor: pointer; flex: none;
}
.estimate-note { margin-top: 8px; font-size: 11px; color: var(--text3); }

/* ---------- manual tracking (spec 9) ---------- */

.track-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.track-label { flex: 1; font-size: 13px; color: var(--text2); }
.track-input {
  width: 84px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-align: right;
  font-size: 14px;
}
.track-saved {
  margin-top: 10px; padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--green3); color: var(--green-dark);
  font-size: 13px;
}

/* ---------- profile ---------- */

.prof-row {
  display: flex; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--text2);
}
.prof-row:last-child { border-bottom: 0; }
.prof-row b { color: var(--text); }

#logoutBtn { width: 100%; margin-top: 4px; }

/* ---------- week pills ---------- */

/* A day can be both today and done. components.css sets .wp.done to white-on-
   green and .wp.today to green text, which cancelled out to green-on-green.
   The mockup never hit this because its "today" was never also "done". */
.wp.done.today {
  color: var(--surface);
  border-color: var(--green-dark);
  border-width: 2px;
}

/* ---------- disclaimer (spec 16) ---------- */

.wellness-disclaimer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 60;
  padding: 6px 14px calc(6px + env(safe-area-inset-bottom, 0px));
  background: var(--ink);
  color: var(--surface);
  font-size: 10px;
  line-height: 1.35;
  text-align: center;
}
