/* =========================================================================
   Calorie Tracker — redesigned UI (dark, warm neutrals + green + amber)
   Single stylesheet, no build step, no framework.
   ========================================================================= */

/* ---- Design tokens --------------------------------------------------- */
:root {
  --bg:         #0E0F0D;
  --surface:    #171814;
  --surface-2:  #1F2119;
  --surface-3:  #272A20;
  --border:     #2A2D23;
  --border-hi:  #4A4F3E;

  --text:       #F3F1E8;
  --text-sub:   #A8A89A;
  --text-dim:   #6D6E62;

  --g-50:  #E8F5E9;
  --g-100: #C8E6C9;
  --g-300: #81C784;
  --g-500: #66BB6A;
  --g-600: #4CAF50;
  --g-700: #388E3C;
  --g-800: #2E7D32;

  --warn:    #E5A84A;
  --warn-bg: #2A2115;
  --bad:     #E06B5E;
  --bad-bg:  #2A1815;
  --ok:      #66BB6A;

  --r-1: 10px;
  --r-2: 16px;
  --r-3: 24px;
  --r-pill: 999px;

  --sh-1: 0 1px 2px rgba(0,0,0,0.3);
  --sh-2: 0 4px 16px rgba(0,0,0,0.25);
  --sh-3: 0 10px 40px rgba(0,0,0,0.35);
  --glow: 0 0 24px rgba(102,187,106,0.25);

  /* Native OS font stack — no web font downloaded. Renders San Francisco on
     Apple, Segoe UI on Windows, Roboto on Android, etc. Instant first paint,
     no swap, no font bytes over the wire. */
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --t-1: 13px;
  --t-2: 15px;
  --t-3: 17px;
  --t-4: 20px;
  --t-5: 28px;
  --t-6: 40px;
  --t-7: 64px;
}

/* ---- Reset ----------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: var(--t-3);
  line-height: 1.4;
  font-weight: 500;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
input, select, textarea, button { font-family: inherit; }
input, textarea, select { color: var(--text); }

/* ---- App shell ------------------------------------------------------- */
.app-shell {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  position: relative;
}
.app-shell--no-nav { padding-bottom: env(safe-area-inset-bottom, 0px); }

.skip-link {
  position: absolute; top: -40px; left: 0;
  background: var(--g-600); color: var(--bg);
  padding: 8px 14px; border-radius: 0 0 var(--r-1) 0;
  font-weight: 700; z-index: 1000;
  transition: top 0.2s;
}
.skip-link:focus { top: 0; }

/* ---- Screen header --------------------------------------------------- */
.screen-header {
  padding: 18px 20px 8px;
  display: flex; align-items: flex-start; gap: 12px;
}
.screen-header__back {
  width: 40px; height: 40px; border-radius: var(--r-1);
  background: var(--surface-2); border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text); cursor: pointer; flex-shrink: 0; margin-top: 4px;
  transition: background 0.15s, border-color 0.15s;
}
.screen-header__back:hover { background: var(--surface-3); border-color: var(--border-hi); }
.screen-header__main { flex: 1; min-width: 0; }
.screen-header__eyebrow {
  font-size: var(--t-1); font-weight: 600; color: var(--text-sub);
  letter-spacing: 1px; text-transform: uppercase; margin-bottom: 4px;
}
.screen-header__title {
  font-size: var(--t-5); font-weight: 700; line-height: 1.1;
  letter-spacing: -0.5px; color: var(--text); margin: 0;
}
.screen-header__title--lg { font-size: var(--t-6); letter-spacing: -0.8px; line-height: 1.05; }
.screen-header__subtitle {
  font-size: var(--t-2); color: var(--text-sub); margin-top: 6px;
}

/* ---- Section eyebrow ------------------------------------------------- */
.eyebrow {
  font-size: var(--t-1); font-weight: 700; color: var(--text-sub);
  letter-spacing: 1px; text-transform: uppercase;
  padding: 0 4px; margin: 24px 20px 10px;
}

/* ---- Card ------------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-2);
  padding: 20px;
}
.card--tight { padding: 16px; }
.card--interactive { cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.card--interactive:hover { background: var(--surface-2); border-color: var(--border-hi); }

/* ---- Section / content gutters -------------------------------------- */
.section { padding: 0 20px; }
.section + .section { margin-top: 16px; }
.stack-12 > * + * { margin-top: 12px; }
.stack-10 > * + * { margin-top: 10px; }

.row { display: flex; align-items: center; }
.row--between { justify-content: space-between; }
.row--gap-10 { gap: 10px; }
.row--gap-12 { gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---- Button --------------------------------------------------------- */
.btn {
  appearance: none;
  border: none;
  border-radius: var(--r-2);
  font-family: var(--font);
  font-weight: 600;
  letter-spacing: -0.1px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: transform 80ms, background 150ms, border-color 150ms, box-shadow 150ms, color 150ms;
  line-height: 1;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--g-500); outline-offset: 2px; }

.btn--sm { height: 40px; padding: 0 16px; font-size: var(--t-2); }
.btn--md { height: 52px; padding: 0 22px; font-size: var(--t-3); }
.btn--lg { height: 60px; padding: 0 28px; font-size: var(--t-4); }

.btn--primary {
  background: var(--g-600); color: #0E0F0D; box-shadow: var(--sh-2);
}
.btn--primary:hover:not(:disabled) { background: var(--g-500); }
.btn--primary:active:not(:disabled) { box-shadow: var(--sh-1); }

.btn--secondary {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-hi); box-shadow: var(--sh-1);
}
.btn--secondary:hover:not(:disabled) { background: var(--surface-3); }

.btn--ghost {
  background: transparent; color: var(--text-sub); border: 1px solid var(--border);
}
.btn--ghost:hover:not(:disabled) { background: var(--surface); color: var(--text); border-color: var(--border-hi); }

.btn--danger {
  background: transparent; color: var(--bad); border: 1px solid var(--border);
}
.btn--danger:hover:not(:disabled) { background: var(--bad-bg); border-color: var(--bad); }

.btn--full { width: 100%; }

/* ---- Chip (pill) ---------------------------------------------------- */
.chip {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text-sub);
  border: 1px solid var(--border);
  font-size: var(--t-2);
  font-weight: 600;
  letter-spacing: -0.1px;
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-decoration: none;
}
.chip:hover { color: var(--text); }
.chip--active {
  background: rgba(102,187,106,0.12);
  border-color: var(--g-500);
  color: var(--g-500);
}
.chip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 20px; }
.chip-grid .chip { justify-content: center; height: 44px; }

/* ---- Inputs --------------------------------------------------------- */
.input, select.input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  background: var(--bg);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-1);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--t-3);
  font-weight: 500;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.input:focus, select.input:focus { border-color: var(--g-500); }
.input::placeholder { color: var(--text-dim); }
.input--lg { height: 52px; font-weight: 700; }
.input--xl { height: 64px; font-weight: 700; font-size: 32px; text-align: center; }
.input--num { font-variant-numeric: tabular-nums; }

.field { display: block; margin: 0; }
.field + .field { margin-top: 16px; }
.field__label {
  display: block;
  font-size: var(--t-1); font-weight: 700; color: var(--text-sub);
  letter-spacing: 1px; text-transform: uppercase; margin-bottom: 8px;
  padding-left: 2px;
}
.field__error { color: var(--bad); font-size: var(--t-1); margin-top: 6px; }
.field__hint { color: var(--text-sub); font-size: var(--t-1); margin-top: 6px; }

.input-wrap { position: relative; }
.input-wrap--suffix .input { padding-right: 80px; }
.input-suffix {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-sub); font-size: var(--t-2); font-weight: 600;
  pointer-events: none;
}
.input-wrap--search .input { padding-left: 42px; }
.input-wrap__icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-sub); pointer-events: none;
}

.input-row { display: flex; gap: 10px; align-items: stretch; }
.input-row > .input { flex: 1 1 0; min-width: 0; }
.input-row > .btn { flex-shrink: 0; }

/* ---- Progress bar --------------------------------------------------- */
.progress {
  height: 6px; border-radius: 3px; background: var(--surface-3);
  overflow: hidden; position: relative;
}
.progress__bar {
  height: 100%; background: var(--g-500); border-radius: 3px;
  transition: width 0.4s ease;
}
.progress__bar--over { background: var(--warn); }

/* ---- Ring gauge ----------------------------------------------------- */
.ring {
  position: relative;
  width: 240px; height: 240px;
  margin: 8px auto 4px;
}
.ring__svg { transform: rotate(-90deg); }
.ring__track { fill: none; stroke: var(--surface-3); stroke-width: 14; }
.ring__arc {
  fill: none;
  stroke: var(--g-500);
  stroke-width: 14;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s cubic-bezier(0.22, 1, 0.36, 1), stroke 0.3s;
}
.ring__arc--over { stroke: var(--warn); filter: drop-shadow(0 0 8px var(--warn)); }
.ring__arc--on-goal { filter: drop-shadow(0 0 12px rgba(102,187,106,0.45)); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(102,187,106,0.3)); }
  50%      { filter: drop-shadow(0 0 16px rgba(102,187,106,0.55)); }
}
.ring__center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px; text-align: center; padding: 0 24px;
}
.ring__big {
  font-size: var(--t-7); font-weight: 800; color: var(--text);
  letter-spacing: -2px; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.ring__big--5 { font-size: 52px; letter-spacing: -1.5px; }
.ring__big--6 { font-size: 44px; letter-spacing: -1.2px; }
.ring__eyebrow {
  font-size: 12px; color: var(--text-sub);
  letter-spacing: 1.2px; text-transform: uppercase; font-weight: 600;
  margin-bottom: 2px;
}
.ring__of {
  font-size: 14px; color: var(--text-sub); margin-top: 4px; font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.ring__pill {
  display: inline-flex; align-items: center;
  margin-top: 10px; padding: 4px 12px;
  border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.ring__pill--over {
  background: var(--warn-bg); border-color: var(--warn); color: var(--warn);
}

.readd-list { display: flex; flex-direction: column; gap: 8px; }
.readd-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; width: 100%;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-1);
  color: var(--text); text-align: left; text-decoration: none;
  font-family: inherit; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.readd-row:hover { background: var(--surface-2); border-color: var(--border-hi); }
.readd-row__dot {
  width: 8px; height: 8px; border-radius: 4px;
  background: var(--g-500); flex-shrink: 0;
}
.readd-row__text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.readd-row__name {
  font-size: var(--t-3); font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.readd-row__meta {
  font-size: var(--t-1); color: var(--text-sub); margin-top: 1px;
  font-variant-numeric: tabular-nums;
}
.readd-row__add {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-3); color: var(--g-500);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 0.15s, transform 80ms;
  pointer-events: none;
}
.readd-row:hover .readd-row__add { background: rgba(102,187,106,0.18); }

.meal-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; padding: 0 20px;
}
.meal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-1);
  padding: 10px 6px;
  text-align: center;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.meal-box:hover { background: var(--surface-2); border-color: var(--border-hi); }
.meal-box--empty { opacity: 0.55; background: var(--bg); }
.meal-box__icon { color: var(--g-500); display: inline-flex; }
.meal-box--empty .meal-box__icon { color: var(--text-dim); }
.meal-box__label {
  font-size: 11px; color: var(--text-sub);
  margin-top: 4px; letter-spacing: 0.2px;
}
.meal-box__val {
  font-size: var(--t-3); font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; margin-top: 2px;
}
.meal-box--empty .meal-box__val { color: var(--text-dim); }

/* ---- Entry row (log entries) ---------------------------------------- */
.entry-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-2);
  overflow: hidden;
}
.entry-row {
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px; min-height: 52px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.entry-row:last-child { border-bottom: none; }
.entry-row__name {
  flex: 1; min-width: 0;
  font-size: var(--t-2); font-weight: 500; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.entry-row__cal {
  font-size: var(--t-2); font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; flex-shrink: 0;
}

.entry-row { padding: 12px 16px; }
.entry-row__meta {
  font-size: var(--t-1); color: var(--text-sub);
  font-variant-numeric: tabular-nums; flex-shrink: 0;
}
.entry-row__edit {
  width: 36px; height: 36px; border-radius: var(--r-1);
  background: transparent; border: none; color: var(--text-sub);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.entry-row__edit:hover { background: var(--surface-2); color: var(--text); }

/* ---- Meal section header (LOG screen) ------------------------------- */
.meal-head {
  display: flex; align-items: center; gap: 8px;
  padding: 0 20px; margin: 20px 0 8px;
  font-size: var(--t-2); font-weight: 700; color: var(--text);
  letter-spacing: 0.5px; text-transform: uppercase;
}
.meal-head__dot {
  display: inline-flex; width: 18px; height: 18px; color: var(--text-sub);
}
.meal-head__sep { color: var(--text-dim); margin: 0 4px; }
.meal-head__cal { color: var(--text-sub); font-weight: 600; font-variant-numeric: tabular-nums; }
.meal-head__empty { color: var(--text-dim); font-weight: 500; text-transform: none; letter-spacing: 0; font-size: var(--t-2); }

/* ---- Stat card (history Stats tab) ---------------------------------- */
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-2); padding: 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-card__label {
  font-size: var(--t-1); font-weight: 700; color: var(--text-sub);
  letter-spacing: 1px; text-transform: uppercase;
}
.stat-card__value {
  font-size: var(--t-5); font-weight: 800; color: var(--text);
  font-variant-numeric: tabular-nums; letter-spacing: -0.5px;
  display: flex; align-items: center; gap: 8px;
}
.stat-card__caption { font-size: var(--t-1); color: var(--text-sub); }

/* ---- Most-eaten mini-bar -------------------------------------------- */
.most-eaten { padding: 8px 16px; }
.most-eaten__row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.most-eaten__row:last-child { border-bottom: none; }
.most-eaten__rank { width: 22px; color: var(--text-sub); font-weight: 700; font-variant-numeric: tabular-nums; }
.most-eaten__name { flex: 1; min-width: 0; font-size: var(--t-2); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-bar {
  flex: 0 0 40%; height: 6px; border-radius: 3px;
  background: var(--surface-3); overflow: hidden;
}
.mini-bar__fill { height: 100%; background: var(--g-500); transition: width 0.4s; }

/* ---- Qty stepper ---------------------------------------------------- */
.stepper {
  display: inline-flex; align-items: center; align-self: center;
  height: 32px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--border);
  overflow: hidden;
}
.stepper--lg { height: 52px; }
.stepper__btn {
  width: 32px; height: 100%; background: transparent; border: none;
  color: var(--text); font-size: 20px; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.stepper--lg .stepper__btn { width: 52px; }
.stepper__btn:hover { background: var(--surface-3); }
.stepper__btn:disabled { color: var(--text-dim); cursor: not-allowed; }
.stepper__val {
  min-width: 32px; padding: 0 4px; text-align: center;
  font-size: var(--t-3); font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stepper--lg .stepper__val { min-width: 48px; font-size: var(--t-4); }

/* ---- Food-pick row (Add Food) -------------------------------------- */
.pick-list {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-2); overflow: hidden;
}
.pick-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; min-height: 56px;
  border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.15s;
  color: var(--text); width: 100%;
  background: transparent; border-left: none; border-right: none; border-top: none;
  text-align: left; font-family: inherit;
}
.pick-row:last-child { border-bottom: none; }
.pick-row:hover { background: var(--surface-2); }
.pick-row__circle {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--border-hi);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 0.15s, border-color 0.15s;
  color: var(--bg);
}
.pick-row--on .pick-row__circle {
  background: var(--g-500); border-color: var(--g-500);
}
.pick-row__name {
  flex: 1; min-width: 0;
  font-size: var(--t-3); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pick-row__meta {
  font-size: var(--t-2); color: var(--text-sub);
  font-variant-numeric: tabular-nums; flex-shrink: 0;
}
.pick-row__unit {
  font-size: var(--t-2); color: var(--text-sub); flex-shrink: 0;
  min-width: 32px; text-align: right;
}
.pick-row--on { background: rgba(102,187,106,0.05); }

/* Sticky cart CTA */
.sticky-cta {
  position: sticky; bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  z-index: 20; padding: 16px 20px 8px;
  background: linear-gradient(to top, var(--bg) 70%, rgba(14,15,13,0));
}
.sticky-cta .btn { box-shadow: var(--sh-2); }
/* Reserve scroll room so the sticky CTA never permanently hides list items. */
.pick-list { padding-bottom: 80px; }

/* ---- Settings row --------------------------------------------------- */
.setting-list {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-2); overflow: hidden;
}
.setting-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; min-height: 60px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}
.setting-row:last-child { border-bottom: none; }
.setting-row--link { cursor: pointer; transition: background 0.15s; }
.setting-row--link:hover { background: var(--surface-2); }
.setting-row__icon {
  width: 36px; height: 36px; border-radius: var(--r-1);
  background: var(--surface-3); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.setting-row__text { flex: 1; min-width: 0; }
.setting-row__title { font-size: var(--t-3); font-weight: 500; color: var(--text); }
.setting-row__sub { font-size: var(--t-1); color: var(--text-sub); margin-top: 2px; }
.setting-row__chev { color: var(--text-dim); flex-shrink: 0; }
.setting-row__action { flex-shrink: 0; }

/* ---- Profile avatar ------------------------------------------------- */
.avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--g-700); color: var(--bg);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; flex-shrink: 0;
  user-select: none;
}
.avatar--lg { width: 64px; height: 64px; font-size: 26px; }
.avatar--sm { width: 36px; height: 36px; font-size: 15px; }

/* ---- Bottom nav ----------------------------------------------------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  max-width: 460px; margin: 0 auto;
  background: rgba(14,15,13,0.92);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 8px 8px max(20px, env(safe-area-inset-bottom, 0px));
}
.bottom-nav__item {
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 4px 0; min-width: 0; text-decoration: none;
  color: var(--text-sub);
  transition: color 0.15s;
}
.bottom-nav__pill {
  width: 48px; height: 30px; border-radius: 15px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--text-sub);
  transition: background 0.15s, color 0.15s;
}
.bottom-nav__item--active .bottom-nav__pill {
  background: rgba(102,187,106,0.15); color: var(--g-500);
}
.bottom-nav__item--active { color: var(--g-500); }
.bottom-nav__label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.2px;
  color: inherit;
}
.bottom-nav__item--primary .bottom-nav__pill {
  background: var(--g-600); color: #0E0F0D;
  box-shadow: 0 2px 10px rgba(76,175,80,0.35);
  width: 48px; height: 32px; border-radius: 16px;
}
.bottom-nav__item--primary { color: var(--g-500); }
.bottom-nav__item--primary.bottom-nav__item--active .bottom-nav__pill {
  background: var(--g-500); color: #0E0F0D;
}

/* ---- Modal / bottom-sheet ------------------------------------------ */
.sheet-scrim {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.sheet-scrim.is-open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-width: 460px; margin: 0 auto;
  background: var(--surface-2);
  border-radius: var(--r-3) var(--r-3) 0 0;
  padding: 8px 20px max(28px, env(safe-area-inset-bottom, 0px));
  box-shadow: var(--sh-3);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 100;
  max-height: 90vh; overflow-y: auto;
}
.sheet.is-open { transform: translateY(0); }
.sheet__grab {
  width: 40px; height: 4px; border-radius: 2px;
  background: var(--border-hi); margin: 4px auto 16px;
}
.sheet__title {
  font-size: var(--t-4); font-weight: 700; text-align: center;
  margin: 0 0 12px;
}
.sheet__sub { font-size: var(--t-2); color: var(--text-sub); text-align: center; margin-bottom: 16px; }
.sheet__actions {
  display: flex; gap: 10px; margin-top: 20px;
}
.sheet__actions .btn { flex: 1; }
.sheet__actions .btn--primary { flex: 2; }

/* ---- Toast / flash -------------------------------------------------- */
#flash-messages { position: fixed; inset: auto 0 calc(104px + env(safe-area-inset-bottom, 0px)) 0; z-index: 60; pointer-events: none; }
.flash-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.flash-message {
  pointer-events: auto;
  padding: 12px 20px; border-radius: var(--r-pill);
  font-size: var(--t-2); font-weight: 600;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-hi); box-shadow: var(--sh-2);
  max-width: calc(100% - 40px);
  animation: toastIn 0.2s cubic-bezier(0.22,1,0.36,1);
  display: inline-flex; align-items: center; gap: 8px;
}
.flash-message.success { border-color: var(--g-500); color: var(--g-500); }
.flash-message.error { border-color: var(--bad); color: var(--bad); }
.flash-message.warning { border-color: var(--warn); color: var(--warn); }
@keyframes toastIn {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

/* ---- Tabs (segmented) ---------------------------------------------- */
.tabs {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 4px;
  margin: 0 20px;
}
.tabs__item {
  height: 40px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-pill); cursor: pointer;
  font-size: var(--t-2); font-weight: 600; color: var(--text-sub);
  background: transparent; border: none;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}
.tabs__item:hover { color: var(--text); }
.tabs__item--active {
  background: var(--g-600); color: #0E0F0D;
}

/* ---- Bars + line chart --------------------------------------------- */
.bars-wrap { padding: 0 20px; }
.bars {
  display: flex; align-items: flex-end; gap: 6px;
  height: 160px; padding: 4px 0;
  position: relative;
}
.bars__bar {
  flex: 1; min-width: 0; border-radius: 4px 4px 0 0;
  background: var(--g-500); transition: height 0.3s;
  position: relative;
}
.bars__bar--over { background: var(--warn); }
.bars__bar--empty { background: var(--surface-3); }
.bars__labels {
  display: flex; gap: 6px; padding-top: 6px;
}
.bars__label {
  flex: 1; text-align: center; font-size: var(--t-1);
  color: var(--text-sub); font-variant-numeric: tabular-nums;
}
.bars__goal-line {
  position: absolute; left: 0; right: 0; border-top: 1px dashed var(--text-dim);
  pointer-events: none;
}

.line-chart { width: 100%; height: 180px; display: block; }
.line-chart__path { fill: none; stroke: var(--g-500); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.line-chart__area { fill: rgba(102,187,106,0.15); }
.line-chart__goal { stroke: var(--text-dim); stroke-width: 1; stroke-dasharray: 4 4; fill: none; }
.line-chart__dot { fill: var(--g-500); stroke: var(--bg); stroke-width: 2; }

/* ---- Utilities ----------------------------------------------------- */
.text-sub { color: var(--text-sub); }
.text-dim { color: var(--text-dim); }
.text-warn { color: var(--warn); }
.text-good { color: var(--g-500); }
.text-bad  { color: var(--bad); }
.text-center { text-align: center; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.hidden { display: none !important; }
.fw-700 { font-weight: 700; }
.num    { font-variant-numeric: tabular-nums; }

/* ---- Empty states -------------------------------------------------- */
.empty {
  padding: 40px 20px; text-align: center;
}
.empty__icon { color: var(--text-dim); margin: 0 auto 12px; display: inline-flex; }
.empty__title { font-size: var(--t-3); color: var(--text); font-weight: 600; margin: 0; }
.empty__sub { font-size: var(--t-2); color: var(--text-sub); margin-top: 6px; }

/* ---- Divider ------------------------------------------------------- */
.hr { height: 1px; background: var(--border); border: none; margin: 20px 0; }
.hr--labeled {
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; margin: 32px 0 12px;
}
.hr--labeled::before, .hr--labeled::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.hr__label {
  font-size: var(--t-1); font-weight: 700; color: var(--text-sub);
  letter-spacing: 1px; text-transform: uppercase;
}

/* ---- Focus visibility ---------------------------------------------- */
a:focus-visible, button:focus-visible, .chip:focus-visible, .tabs__item:focus-visible {
  outline: 2px solid var(--g-500); outline-offset: 2px;
}

/* ---- Desktop frame hint -------------------------------------------- */
@media (min-width: 560px) {
  body { background: #050604; }
  .app-shell { box-shadow: var(--sh-3); border-left: 1px solid var(--border); border-right: 1px solid var(--border); min-height: 100vh; background: var(--bg); }
}

/* ---- Details / summary (collapsible history entries) --------------- */
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }

/* ---- Honeypot field (anti-bot) ------------------------------------- */
.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
