/* ============================================================
   Trung Routine App — iOS-style design system (dark)
   SF Pro stack · true-black canvas · grouped cards · switches
   One spacing scale: 4 / 8 / 12 / 16 / 20 / 24 / 32
   ============================================================ */

:root {
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s7: 32px;

  /* iOS dark surfaces */
  --bg: #000000;
  --card: #1c1c1e;
  --card-2: #2c2c2e;
  --card-3: #3a3a3c;
  --separator: rgba(255,255,255,0.10);
  --hairline: rgba(255,255,255,0.07);

  /* iOS labels */
  --label: #ffffff;
  --label-2: rgba(235,235,245,0.62);
  --label-3: rgba(235,235,245,0.32);

  /* iOS system colors (dark) */
  --blue: #0a84ff;
  --green: #30d158;
  --orange: #ff9f0a;
  --red: #ff453a;
  --teal: #64d2ff;
  --purple: #bf5af2;

  --blue-tint: rgba(10,132,255,0.16);
  --green-tint: rgba(48,209,88,0.16);
  --orange-tint: rgba(255,159,10,0.16);
  --red-tint: rgba(255,69,58,0.16);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          "Inter", "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;

  --radius: 18px;       /* cards */
  --radius-sm: 12px;    /* buttons, inputs */
  --radius-xs: 9px;

  --shadow-card: 0 1px 0 rgba(255,255,255,0.04) inset;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; }

html, body { max-width: 100%; overflow-x: hidden; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: -0.01em;
  color: var(--label);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; -webkit-tap-highlight-color: transparent; }
input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: var(--radius-xs); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- App layout ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.app > * { min-width: 0; }   /* grid items may shrink below content width */

.main {
  padding: var(--s6) var(--s7) var(--s7);
  max-width: 1140px;
  width: 100%;
}

/* ---------- Sidebar (desktop) ---------- */
.sidebar {
  background: rgba(18,18,20,0.9);
  border-right: 0.5px solid var(--separator);
  padding: var(--s6) var(--s3);
  display: flex; flex-direction: column; gap: var(--s6);
  position: sticky; top: 0; height: 100vh;
}

.brand { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s2); }
.brand-mark {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 700; letter-spacing: 0.02em;
  color: #fff;
  background: linear-gradient(145deg, var(--blue), #0060df);
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(10,132,255,0.35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-name { font-weight: 600; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--label-3); }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s3);
  min-height: 40px;
  border-radius: var(--radius-xs);
  color: var(--label-2);
  font-size: 14px; font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--card); color: var(--label); }
.nav-item.is-active { background: var(--blue-tint); color: var(--blue); }

.nav-icon { width: 21px; height: 21px; flex: none; }

.sidebar-foot {
  margin-top: auto; padding: 0 var(--s3);
  display: flex; flex-direction: column; gap: 2px;
  font-size: 13px; color: var(--label-2);
}
.sidebar-foot-dim { font-size: 11px; color: var(--label-3); }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s4); flex-wrap: wrap;
  margin-bottom: var(--s5);
}
.topbar-title {
  font-size: 32px; font-weight: 700; letter-spacing: -0.03em;
}
.date-nav { display: flex; align-items: center; gap: var(--s2); position: relative; }

.date-pill {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: var(--s2) var(--s4);
  min-height: 38px;
  color: var(--label);
  font-size: 15px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: background 0.15s;
}
.date-pill:hover { background: var(--card-2); }
.date-pill.is-open { background: var(--card-2); color: var(--blue); }

/* ---------- iOS calendar popover ---------- */
.cal-pop {
  position: absolute;
  top: calc(100% + var(--s2));
  right: 0;
  z-index: 40;
  width: 312px;
  max-width: calc(100vw - var(--s7));
  background: rgba(36,36,38,0.92);
  backdrop-filter: blur(28px) saturate(1.6);
  -webkit-backdrop-filter: blur(28px) saturate(1.6);
  border: 0.5px solid var(--separator);
  border-radius: var(--radius);
  padding: var(--s4);
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
  animation: calIn 0.18s cubic-bezier(0.2,0.8,0.4,1);
}
@keyframes calIn { from { opacity: 0; transform: translateY(-6px) scale(0.98); } to { opacity: 1; transform: none; } }

.cal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--s3);
}
.cal-month { font-size: 16px; font-weight: 600; }
.cal-month .cal-year { color: var(--label-2); font-weight: 500; }
.cal-arrows { display: flex; gap: var(--s1); }
.cal-arrow {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--blue);
  font-size: 20px; font-weight: 500; line-height: 1;
  transition: background 0.15s;
}
.cal-arrow:hover { background: var(--card-2); }

.cal-weekdays, .cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-weekdays {
  margin-bottom: var(--s1);
}
.cal-weekdays span {
  text-align: center;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--label-3);
  padding: var(--s1) 0;
}

.cal-day {
  position: relative;
  aspect-ratio: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 15px; font-weight: 400;
  font-variant-numeric: tabular-nums;
  color: var(--label);
  transition: background 0.12s;
}
.cal-day:hover { background: var(--card-2); }
.cal-day.is-today { color: var(--blue); font-weight: 700; }
.cal-day.is-selected { background: var(--blue); color: #fff; font-weight: 600; }
.cal-day.is-selected:hover { background: var(--blue); }
.cal-day.is-future { color: var(--label-3); }

.cal-dot {
  position: absolute;
  bottom: 4px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--green);
}
.cal-day.is-selected .cal-dot { background: #fff; }

.cal-blank { aspect-ratio: 1; }

/* ---------- Tabs ---------- */
.tab-panel { display: none; }
.tab-panel.is-active { display: block; animation: panelIn 0.22s cubic-bezier(0.2,0.8,0.4,1); }
@keyframes panelIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Grid ---------- */
.grid { display: grid; gap: var(--s4); }
.grid > * { min-width: 0; }  /* cards in grids may shrink below content width */
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1020px) { .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px)  { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------- Card system ---------- */
.card {
  min-width: 0;
  background: var(--card);
  border-radius: var(--radius);
  padding: var(--s5);
  box-shadow: var(--shadow-card);
}
.card + .card, .grid + .card, .card + .grid, .grid + .grid { margin-top: var(--s4); }
/* inside a grid, the grid gap owns the spacing — kill stacking margins */
.grid > .card, .grid > .grid { margin-top: 0; }
.card-compact { padding: var(--s4); }

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3); margin-bottom: var(--s4);
  flex-wrap: wrap;
  min-width: 0;
}
.card-head > * { min-width: 0; }
.card-title {
  font-size: 13px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--label-2);
  display: inline-flex; align-items: center; gap: var(--s2);
}
.card-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--card-2);
  color: var(--label-2);
  font-size: 17px; font-weight: 600; line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.card-link:hover { background: var(--card-3); color: var(--label); }

/* status tint strip on overview cards */
.card.status-ok    { box-shadow: var(--shadow-card), inset 3px 0 0 var(--green); }
.card.status-warn  { box-shadow: var(--shadow-card), inset 3px 0 0 var(--orange); }
.card.status-alert { box-shadow: var(--shadow-card), inset 3px 0 0 var(--red); }
.card.status-idle  { }

/* ---------- Section title ---------- */
.section-title { font-size: 17px; font-weight: 600; margin: var(--s6) 0 var(--s3); }
.section-title:first-child { margin-top: 0; }

/* ---------- Stats / readouts ---------- */
.stat-row { display: flex; align-items: baseline; gap: var(--s2); flex-wrap: wrap; }
.stat-big {
  font-size: 34px; font-weight: 700; letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.stat-unit { font-size: 14px; color: var(--label-2); }
.stat-list { display: flex; flex-direction: column; margin-top: var(--s3); }
.stat-line {
  display: flex; justify-content: space-between; align-items: center; gap: var(--s3);
  font-size: 14px; color: var(--label-2);
  padding: 7px 0;
  border-bottom: 0.5px solid var(--hairline);
}
.stat-line:last-child { border-bottom: none; padding-bottom: 0; }
.stat-line b { font-weight: 500; color: var(--label); font-variant-numeric: tabular-nums; }

.mono { font-family: var(--font-mono); }

/* pills */
.pill {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600; letter-spacing: 0.03em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--card-2);
  color: var(--label-2);
}
.pill-ok    { color: var(--green);  background: var(--green-tint); }
.pill-info  { color: var(--blue);   background: var(--blue-tint); }
.pill-warn  { color: var(--orange); background: var(--orange-tint); }
.pill-alert { color: var(--red);    background: var(--red-tint); }

/* ---------- Progress bar system ---------- */
.progress { display: flex; flex-direction: column; gap: 6px; }
.progress-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--label-2); }
.progress-label b { font-weight: 500; color: var(--label); font-variant-numeric: tabular-nums; }
.progress-track { height: 7px; border-radius: 999px; background: var(--card-2); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: var(--green); transition: width 0.3s cubic-bezier(0.2,0.8,0.4,1); }
.progress-fill.fill-blue  { background: var(--blue); }
.progress-fill.fill-amber { background: var(--orange); }
.progress-fill.fill-red   { background: var(--red); }

/* ---------- Button system ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  font-weight: 600; font-size: 15px;
  padding: var(--s2) var(--s4);
  min-height: 40px;
  border-radius: var(--radius-sm);
  transition: filter 0.15s, background 0.15s, transform 0.1s;
  user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(0.97); filter: brightness(0.85); }

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); }

.btn-secondary { background: var(--card-2); color: var(--label); }
.btn-secondary:hover { background: var(--card-3); }

.btn-tint { background: var(--blue-tint); color: var(--blue); }
.btn-tint:hover { filter: brightness(1.15); }

.btn-ghost { color: var(--blue); }
.btn-ghost:hover { background: var(--card); }

.btn-danger { background: var(--red-tint); color: var(--red); }

.btn:disabled, .btn.is-disabled { opacity: 0.35; pointer-events: none; }

.btn-icon { padding: var(--s2); min-width: 40px; font-size: 22px; font-weight: 400; }
.btn-sm { min-height: 32px; padding: var(--s1) var(--s3); font-size: 14px; border-radius: var(--radius-xs); }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--s2); }

/* big water-logging tiles */
.btn-log {
  flex-direction: column; gap: 2px;
  padding: var(--s3) var(--s4);
  min-width: 96px; min-height: 64px;
  border-radius: var(--radius-sm);
  flex: 1 1 auto;
}
.btn-log .btn-log-main { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.btn-log .btn-log-sub { font-size: 12px; font-weight: 500; opacity: 0.7; }

/* ---------- Form system ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s4); }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr 1fr; gap: var(--s3); } }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 500; color: var(--label-2); }
.field-input,
.field select,
.field textarea {
  background: var(--card-2);
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--s3);
  min-height: 44px;
  color: var(--label);
  width: 100%;
  font-size: 16px; /* prevents iOS zoom on focus */
}
.field-input::placeholder, .field textarea::placeholder { color: var(--label-3); }
.field-input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--blue);
}
.field input[type="number"] { font-variant-numeric: tabular-nums; }
.field textarea { resize: vertical; min-height: 72px; }

/* iOS segmented control */
.segmented {
  display: inline-flex;
  background: var(--card-2);
  border-radius: var(--radius-xs);
  padding: 2px;
  gap: 2px;
  max-width: 100%;
  overflow-x: auto;
}
.segmented button {
  padding: 6px var(--s3);
  min-height: 30px;
  border-radius: 7px;
  font-size: 13px; font-weight: 600;
  color: var(--label-2);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.segmented button.is-active {
  background: var(--card-3);
  color: var(--label);
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* ---------- iOS switch rows ---------- */
.check-group {
  display: flex; flex-direction: column;
  background: var(--card-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  min-height: 48px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.switch-row + .switch-row { border-top: 0.5px solid var(--hairline); }
.switch-label { font-size: 15px; font-weight: 400; color: var(--label); }
.switch-row input { display: none; }

.switch {
  position: relative; flex: none;
  width: 51px; height: 31px;
  background: var(--card-3);
  border-radius: 999px;
  transition: background 0.2s;
}
.switch::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0,0,0,0.35);
  transition: transform 0.2s cubic-bezier(0.2,0.8,0.4,1);
}
.switch-row input:checked + .switch { background: var(--green); }
.switch-row input:checked + .switch.switch-warn { background: var(--orange); }
.switch-row input:checked + .switch::after { transform: translateX(20px); }

/* ---------- Action-row system ---------- */
.action-rows {
  display: flex; flex-direction: column;
  background: var(--card-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.action-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
}
.action-row + .action-row { border-top: 0.5px solid var(--hairline); }
.action-row-label { font-size: 15px; }
.action-row-sub { font-size: 12px; color: var(--label-3); }
.action-row-value { font-size: 13px; color: var(--label-2); font-variant-numeric: tabular-nums; }
.action-row-controls { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; justify-content: flex-end; }

/* ---------- Today: score ring + anchors (signature) ---------- */
.status-strip {
  display: flex; align-items: center; gap: var(--s6);
  flex-wrap: wrap;
  background: linear-gradient(160deg, #1d1d20, #161618);
  border-radius: var(--radius);
  padding: var(--s5);
  margin-bottom: var(--s4);
  box-shadow: var(--shadow-card);
}

.score-ring { position: relative; width: 84px; height: 84px; flex: none; }
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-ring .ring-bg { stroke: var(--card-2); }
.score-ring .ring-fg {
  stroke: var(--green);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s cubic-bezier(0.2,0.8,0.4,1);
}
.score-ring .ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  line-height: 1.05;
}
.score-ring .ring-num { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.score-ring .ring-cap { font-size: 9px; font-weight: 600; letter-spacing: 0.08em; color: var(--label-3); text-transform: uppercase; }

.status-anchors { display: flex; gap: var(--s4); flex-wrap: wrap; }
.anchor { display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 52px; }
.anchor-pip {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--card-2);
  display: grid; place-items: center;
  font-size: 13px; color: transparent;
  transition: background 0.2s;
}
.anchor.is-done .anchor-pip { background: var(--green); color: #fff; }
.anchor-label { font-size: 10px; font-weight: 500; letter-spacing: 0.02em; color: var(--label-3); }
.anchor.is-done .anchor-label { color: var(--label-2); }

/* ---------- Food library / log ---------- */
.cat-scroller {
  display: flex; gap: var(--s2);
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin-bottom: var(--s3);
  padding-bottom: 2px;
}
.cat-scroller::-webkit-scrollbar { display: none; }
.cat-pill {
  flex: none;
  padding: 6px var(--s3);
  min-height: 32px;
  border-radius: 999px;
  background: var(--card-2);
  color: var(--label-2);
  font-size: 13px; font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.cat-pill:hover { background: var(--card-3); }
.cat-pill.is-active { background: var(--blue); color: #fff; }

.food-groups {
  max-height: 420px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
}
.food-cat-head {
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--label-3);
  padding: var(--s3) var(--s1) var(--s2);
}
.food-groups .food-cat-head:first-child { padding-top: 0; }

.food-list {
  display: flex; flex-direction: column;
  background: var(--card-2);
  border-radius: var(--radius-sm);
}
.food-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4);
}
.food-item + .food-item { border-top: 0.5px solid var(--hairline); }
.food-name { font-size: 15px; }
.food-serving { font-size: 12px; color: var(--label-3); }
.food-macros { font-size: 12px; color: var(--label-2); white-space: nowrap; font-variant-numeric: tabular-nums; }

.btn-add {
  width: 30px; height: 30px; min-height: 30px; padding: 0;
  border-radius: 50%;
  background: var(--blue-tint); color: var(--blue);
  font-size: 19px; font-weight: 600; line-height: 1;
}
.btn-add:active { transform: scale(0.92); }

.search-input {
  background: var(--card-2);
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--s3) var(--s4);
  min-height: 40px;
  color: var(--label);
  width: 100%;
  font-size: 16px;
  margin-bottom: var(--s3);
}
.search-input::placeholder { color: var(--label-3); }
.search-input:focus { outline: none; box-shadow: 0 0 0 2px var(--blue); }

/* ---------- Tables (insights) ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); background: var(--card-2); max-width: 100%; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td {
  padding: var(--s2) var(--s3);
  text-align: right;
  border-bottom: 0.5px solid var(--hairline);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
table.data tr:last-child td { border-bottom: none; }
table.data th {
  font-weight: 600; font-size: 11px;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--label-3);
}
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data td.is-low { color: var(--orange); }
table.data td.is-bad { color: var(--red); }

/* alerts */
.alert-line {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) 0;
  font-size: 14px;
}
.alert-line + .alert-line { border-top: 0.5px solid var(--hairline); }
.alert-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.alert-dot.warn  { background: var(--orange); }
.alert-dot.alert { background: var(--red); }
.alert-dot.ok    { background: var(--green); }

/* exercise log */
.exercise-rows { display: flex; flex-direction: column; gap: var(--s2); }
.exercise-row {
  display: grid;
  grid-template-columns: 1.7fr repeat(3, minmax(58px, 0.55fr)) auto;
  gap: var(--s2);
  align-items: center;
}
@media (max-width: 700px) {
  .exercise-row { grid-template-columns: 1fr 1fr 1fr; }
  .exercise-row .field-input:first-child { grid-column: 1 / -1; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: calc(var(--s6) + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: rgba(44,44,46,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 999px;
  padding: var(--s2) var(--s5);
  font-size: 14px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 60;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* helpers */
.hint { font-size: 13px; color: var(--label-3); line-height: 1.5; }
.divider { height: 0.5px; background: var(--separator); margin: var(--s4) 0; }

/* ============================================================
   MOBILE — iOS app shell: large title, bottom tab bar
   ============================================================ */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }

  .sidebar {
    /* becomes the bottom tab bar */
    position: fixed;
    bottom: 0; left: 0; right: 0; top: auto;
    height: auto;
    z-index: 50;
    flex-direction: row;
    padding: 6px var(--s2) calc(6px + env(safe-area-inset-bottom));
    background: rgba(22,22,24,0.82);
    backdrop-filter: blur(24px) saturate(1.6);
    -webkit-backdrop-filter: blur(24px) saturate(1.6);
    border-right: none;
    border-top: 0.5px solid var(--separator);
  }
  .brand, .sidebar-foot { display: none; }

  .nav {
    flex-direction: row;
    width: 100%;
    justify-content: space-between;
    gap: 0;
  }
  .nav-item {
    flex: 1 1 0;
    flex-direction: column;
    gap: 3px;
    padding: var(--s1) 0;
    min-height: 46px;
    font-size: 9.5px;
    font-weight: 500;
    letter-spacing: 0;
    border-radius: var(--radius-xs);
    color: var(--label-3);
  }
  .nav-item:hover { background: none; }
  .nav-item.is-active { background: none; color: var(--blue); }
  .nav-icon { width: 23px; height: 23px; }

  .main {
    padding: var(--s4) var(--s4) calc(84px + env(safe-area-inset-bottom));
  }

  .topbar { margin-bottom: var(--s4); }
  .topbar-title { font-size: 30px; width: 100%; }
  .date-nav { width: 100%; }
  .date-pill { flex: 1 1 auto; min-width: 0; }
  .cal-pop { left: 0; right: 0; width: auto; max-width: none; }

  .card { padding: var(--s4); border-radius: var(--radius); }

  .status-strip { gap: var(--s4); justify-content: center; text-align: center; }
  .status-anchors { justify-content: center; gap: var(--s3); }
  .anchor { min-width: 44px; }

  .btn-log { min-width: calc(50% - var(--s1)); }

  .toast { bottom: calc(92px + env(safe-area-inset-bottom)); max-width: 88vw; text-align: center; }
}

/* very small screens */
@media (max-width: 380px) {
  .nav-item span { display: none; }   /* icons only */
  .nav-item { min-height: 42px; }
  .anchor { min-width: 40px; }
}

/* ---------- Training: template picker row ---------- */
.template-row {
  display: flex;
  align-items: flex-end;
  gap: var(--s3);
}
.template-row select {
  background: var(--card-2);
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--s3);
  min-height: 44px;
  color: var(--label);
  width: 100%;
  font-size: 16px;
}
.template-row .btn { min-height: 44px; flex: none; }

/* ---------- Vitals: breathing room between merged sections ---------- */
#tab-vitals .section-title { margin-top: var(--s7); }
#tab-vitals .section-title:first-child { margin-top: 0; }

/* ---------- Nutrition mobile polish ---------- */
@media (max-width: 860px) {
  .food-list { max-height: none; overflow-y: visible; } /* page scrolls; no nested scroll glitches */
  .cat-pill { min-height: 36px; }        /* thumb-friendlier pills */
  .food-item { padding: var(--s3) var(--s4); }
  .btn-add { width: 36px; height: 36px; min-height: 36px; font-size: 21px; }
}
