/* Vimra — single stylesheet for the app shell and the login page.
   Mobile-first (designed at 390–430px), max 640px column, quiet ≥1024px
   enhancements. Tokens per docs/ARCHITECTURE.md — change them there first. */

/* ---------------------------------------------------------------- tokens */

:root {
  --bg: #F6F5F2;
  --surface: #FFFFFF;
  --surface-2: #FBFAF8;
  --ink: #16181A;
  --ink-2: #5C6165;
  --ink-3: #8A8F94;
  --line: #E7E4DE;
  --line-2: #F0EEE9;
  --brand: #14604B;
  --brand-ink: #0D4A3A;
  --brand-soft: #E4EFE9;
  --data: #0E8A5F;
  --amber: #B4690E;
  --amber-soft: #F6EBDD;
  --danger: #B3261E;
  --radius: 16px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(22, 24, 26, .05), 0 4px 16px rgba(22, 24, 26, .04);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, Inter, sans-serif;
  --header-h: 56px;
  --nav-h: 60px;
  --ease: cubic-bezier(.32, .72, .24, 1);
}

/* ----------------------------------------------------------------- reset */

*, *::before, *::after { box-sizing: border-box; }

html {
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand-ink); }
svg.icon { width: 20px; height: 20px; flex: none; display: block; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* -------------------------------------------------------------- wordmark */

.wordmark {
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  line-height: 1;
  display: inline-flex;
  align-items: baseline;
}

.wordmark-dot {
  display: inline-block;
  width: 0.26em;
  height: 0.26em;
  margin-left: 0.14em;
  background: var(--brand);
  border-radius: 27%;
}

/* ---------------------------------------------------------------- header */

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(246, 245, 242, .88);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-2);
  padding-top: env(safe-area-inset-top);
}

.header-inner {
  max-width: 640px;
  margin: 0 auto;
  height: var(--header-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* member switcher — segmented pill */

.member-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: #ECEAE4;
  border-radius: var(--radius-pill);
  max-width: 62vw;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.member-switcher::-webkit-scrollbar { display: none; }

.seg {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .15s ease, color .15s ease;
}
.seg:hover { color: var(--ink); }
.seg.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(22, 24, 26, .12);
}
.seg-add { padding: 0 10px; color: var(--ink-3); }
.seg-add:hover { color: var(--brand-ink); }
.seg-add .icon { width: 16px; height: 16px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink-2);
  transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--line-2); color: var(--ink); }
.icon-btn:active { background: var(--line); }

/* ------------------------------------------------------------- save chip */

.save-chip {
  position: fixed;
  top: calc(env(safe-area-inset-top) + var(--header-h) + 10px);
  right: 16px;
  z-index: 60;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition: opacity .25s ease, transform .25s ease;
}
.save-chip[hidden] { display: none; }
.save-chip.is-saved,
.save-chip.is-flash {
  background: var(--brand-soft);
  color: var(--brand-ink);
  border-color: var(--brand-soft);
}
.save-chip.is-error {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  cursor: pointer;
}

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

.tab-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  justify-content: center;
  gap: 4px;
  background: rgba(255, 255, 255, .9);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line-2);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}

.tab {
  flex: 1;
  max-width: 96px;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .01em;
  border-radius: var(--radius-sm);
  transition: color .15s ease;
}
.tab .icon { width: 22px; height: 22px; }
.tab:hover { color: var(--ink-2); }
.tab[aria-selected="true"] { color: var(--brand); }

/* ------------------------------------------------------------------ view */

.view {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 32px);
  min-height: calc(100dvh - var(--header-h));
}

.stack { display: grid; gap: 16px; }
.stack-sm { display: grid; gap: 10px; }

.view-head { display: grid; gap: 2px; padding: 2px 2px 6px; }
.view-head h1 {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.view-sub, .date-line { font-size: 14px; color: var(--ink-2); }

.section-title {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
  padding: 6px 2px 0;
}

.micro-label {
  display: block;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.micro-note { font-size: 13px; color: var(--ink-3); }

.card {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card-title { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.btn:disabled { opacity: .45; cursor: default; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-ink); }
.btn-primary:active:not(:disabled) { background: var(--brand-ink); }

.btn-ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--ink-3); }

.btn-danger-ghost { color: var(--danger); border-color: var(--line); background: var(--surface); }
.btn-danger-ghost:hover:not(:disabled) { border-color: var(--danger); }
.btn-danger-ghost.is-armed { background: var(--danger); border-color: var(--danger); color: #fff; }

.btn-compact { min-height: 44px; padding: 0 14px; font-size: 14px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ----------------------------------------------------------------- chips */

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  white-space: nowrap;
}

.mchip strong { color: var(--ink); font-weight: 650; }

.tag-chip { color: var(--ink-3); background: transparent; border-color: var(--line); }

.for-chip {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: var(--amber-soft);
}

/* selectable chips (goals, day picker, build sheet) */

.chip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.chip-btn:hover { border-color: var(--ink-3); }
.chip-btn.is-on {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-ink);
}

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

.field { display: grid; gap: 6px; min-width: 0; }
.field-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field-label small { font-weight: 500; color: var(--ink-3); }

input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 16px;
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
}
textarea { resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 0;
  border-color: var(--brand);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235C6165' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 34px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-error {
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
}
.form-error[hidden] { display: none; }

/* segmented control (sex) */

.seg-control {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: #ECEAE4;
  border-radius: var(--radius-sm);
}
.seg-opt {
  flex: 1;
  border: 0;
  background: transparent;
  min-height: 40px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  transition: background .15s ease, color .15s ease;
}
.seg-opt[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(22, 24, 26, .12);
}

/* stepper */

.stepper { display: flex; align-items: center; gap: 14px; }
.step-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
  transition: border-color .15s ease, background .15s ease;
}
.step-btn:hover:not(:disabled) { border-color: var(--ink-3); }
.step-btn:disabled { opacity: .35; cursor: default; }
.step-val { font-size: 18px; font-weight: 650; min-width: 2.4ch; text-align: center; }

/* checkbox rows */

.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  font-size: 15px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.check-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.checkbox {
  position: relative;
  width: 22px;
  height: 22px;
  flex: none;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  border: 1.5px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  transition: background .15s ease, border-color .15s ease;
}
.checkbox:checked { background: var(--brand); border-color: var(--brand); }
.checkbox:checked::after {
  content: '';
  position: absolute;
  left: 7px;
  top: 3px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}

/* ----------------------------------------------------------- empty states */

.empty {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 8px;
  padding: 30px 20px;
}
.empty-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-pill);
  background: var(--brand-soft);
  color: var(--brand-ink);
  margin-bottom: 2px;
}
.empty-icon .icon { width: 24px; height: 24px; }
.empty-title { font-size: 16px; font-weight: 650; }
.empty-text { font-size: 14px; color: var(--ink-2); max-width: 34ch; }
.empty .btn { margin-top: 8px; }

.mini-empty {
  display: grid;
  gap: 8px;
  justify-items: start;
  font-size: 14px;
  color: var(--ink-2);
}

/* -------------------------------------------------------------- skeleton */

.skeleton { display: grid; gap: 14px; padding-top: 8px; }
.sk {
  background: var(--line-2);
  border-radius: var(--radius);
  animation: sk-pulse 1.1s ease-in-out infinite alternate;
}
.sk-title { height: 28px; width: 40%; border-radius: 8px; }
.sk-line { height: 16px; width: 65%; border-radius: 6px; }
.sk-card { height: 116px; }
.sk-card.tall { height: 180px; }

@keyframes sk-pulse {
  from { opacity: 1; }
  to { opacity: .45; }
}

/* boot error */

.boot-error {
  min-height: 60dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  text-align: center;
}
.boot-error .wordmark { font-size: 26px; margin-bottom: 8px; }

/* ------------------------------------------------------------------ today */

.meter-row { display: grid; gap: 6px; }
.meter-row + .meter-row { margin-top: 14px; }
.meter-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.meter-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.meter-val { font-size: 13px; color: var(--ink-2); }
.meter-val strong { font-size: 15px; font-weight: 650; color: var(--ink); }
.meter-val.is-over strong { color: var(--amber); }

.meter {
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--line-2);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--data);
  transition: width .4s var(--ease);
}
.meter-fill.is-over { background: var(--amber); }

.meter-foot { margin-top: 12px; }

.today-meals { display: grid; gap: 8px; }

.meal-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px 16px;
  min-height: 62px;
  transition: border-color .15s ease;
}
.meal-row:hover { border-color: var(--line); }
.meal-row:active { background: var(--surface-2); }

.meal-row-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.slot-eyebrow {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 6px;
}
.slot-eyebrow .for-chip { text-transform: none; letter-spacing: 0; }
.meal-row-title {
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meal-row-title.is-muted { color: var(--ink-3); font-weight: 500; }
.meal-row-kcal { font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }

.train-today {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  transition: border-color .15s ease;
}
.train-today:hover { border-color: var(--line); }
.train-today-main { flex: 1; min-width: 0; display: grid; gap: 4px; justify-items: start; }
.train-today-title { font-size: 16px; font-weight: 650; }
.train-today-meta { font-size: 13px; color: var(--ink-2); }
.train-today > .icon { color: var(--ink-3); }

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

.day-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px;
  margin: 0 -2px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.day-chips::-webkit-scrollbar { display: none; }

.day-chip {
  flex: none;
  min-width: 52px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.day-chip:hover { border-color: var(--ink-3); }
.day-chip.is-on {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
}

.meal-grid { display: grid; gap: 10px; }

.meal-card {
  display: grid;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  transition: border-color .15s ease;
}
.meal-card:hover { border-color: var(--line); }
.meal-card:active { background: var(--surface-2); }

.meal-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.meal-title { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.meal-desc { font-size: 14px; color: var(--ink-2); }

/* meal detail sheet */

.meal-detail { display: grid; gap: 16px; }

.macro-strip {
  display: flex;
  gap: 6px;
}
.macro-cell {
  flex: 1;
  display: grid;
  gap: 1px;
  justify-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 10px 4px;
}
.macro-num { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.macro-name { font-size: 11px; font-weight: 600; color: var(--ink-3); }

.ing-list { display: grid; gap: 0; }
.ing-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-2);
  font-size: 14.5px;
}
.ing-item:last-child { border-bottom: 0; }
.ing-item-qty { color: var(--ink-2); white-space: nowrap; }

.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 10px; }
.steps li {
  counter-increment: step;
  display: flex;
  gap: 12px;
  font-size: 14.5px;
  line-height: 1.5;
}
.steps li::before {
  content: counter(step);
  flex: none;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-pill);
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 12px;
  font-weight: 650;
  margin-top: 1px;
}

.tip-list { margin: 0; padding: 0 0 0 18px; display: grid; gap: 6px; font-size: 14px; color: var(--ink-2); }

.detail-h {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 8px;
}

/* meal edit form */

.sheet-form { display: grid; gap: 16px; }

.ing-rows { display: grid; gap: 8px; }
.ing-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, .8fr) minmax(0, 1fr) 44px;
  gap: 6px;
  align-items: center;
}
.ing-row .icon-btn { color: var(--ink-3); }
.ing-row .icon-btn:hover { color: var(--danger); background: var(--line-2); }
.add-ing { justify-self: start; }

/* --------------------------------------------------------------- shopping */

.shop-progress { display: grid; gap: 10px; }
.progress-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.progress-count { font-size: 15px; font-weight: 650; }
.progress-count small { font-weight: 500; color: var(--ink-2); font-size: 13px; }
.shop-actions { display: flex; gap: 8px; margin-top: 4px; }
.shop-actions .btn { flex: 1; }

.shop-group { display: grid; gap: 6px; }
.shop-group-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 2px 0;
}
.shop-group-head h2 { font-size: 14px; font-weight: 650; letter-spacing: -0.01em; }
.shop-group-count { font-size: 12px; font-weight: 600; color: var(--ink-3); }

.shop-rows {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.shop-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 10px 16px;
  border: 0;
  border-bottom: 1px solid var(--line-2);
  background: transparent;
  text-align: left;
  font-size: 15px;
  transition: background .12s ease;
}
.shop-row:last-child { border-bottom: 0; }
.shop-row:hover { background: var(--surface-2); }
.shop-row:focus-visible { outline-offset: -2px; }

.tick {
  position: relative;
  width: 22px;
  height: 22px;
  flex: none;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  transition: background .15s ease, border-color .15s ease;
}
.tick::after {
  content: '';
  position: absolute;
  left: 6.5px;
  top: 3px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
  opacity: 0;
}
.shop-row.is-checked .tick { background: var(--brand); border-color: var(--brand); }
.shop-row.is-checked .tick::after { opacity: 1; }

.shop-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shop-qty {
  font-size: 13px;
  color: var(--ink-3);
  white-space: nowrap;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.shop-row.is-checked .shop-name { text-decoration: line-through; color: var(--ink-3); }
.shop-row.is-checked .shop-qty { text-decoration: line-through; }

/* ------------------------------------------------------------------ train */

.train-head-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 650;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.badge .icon { width: 13px; height: 13px; }
.t-gym { background: var(--brand-soft); color: var(--brand-ink); }
.t-cardio { background: var(--amber-soft); color: #8A4E09; }
.t-racquet { background: #E8ECF5; color: #37507D; }
.t-swim { background: #E2EFF2; color: #16606E; }
.t-recovery { background: #ECEAE2; color: #5F5A44; }
.t-rest { background: var(--line-2); color: var(--ink-2); }

.day-card { display: grid; gap: 6px; }
.day-card.is-today { border-color: var(--brand); }
.day-card.is-rest { background: var(--surface-2); box-shadow: none; }

.day-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.day-name { font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.day-name .today-mark { color: var(--brand); }
.day-title { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.day-card.is-rest .day-title { color: var(--ink-2); font-weight: 600; }
.day-focus { font-size: 13.5px; color: var(--ink-2); }
.day-fac { font-size: 12.5px; font-weight: 600; color: var(--ink-3); }

.blocks-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  margin-top: 4px;
  padding: 0 2px;
  border: 0;
  border-top: 1px solid var(--line-2);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.blocks-toggle .icon { width: 16px; height: 16px; color: var(--ink-3); transition: transform .2s var(--ease); }
.blocks-toggle[aria-expanded="true"] .icon { transform: rotate(180deg); }
.blocks-toggle:hover { color: var(--ink); }

.blocks { display: grid; gap: 0; padding-top: 2px; }
.block { padding: 10px 0; border-bottom: 1px solid var(--line-2); display: grid; gap: 3px; }
.block:last-child { border-bottom: 0; }
.block-main { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.block-name { font-size: 14.5px; font-weight: 600; }
.block-dose { font-size: 13.5px; font-weight: 650; color: var(--brand-ink); white-space: nowrap; }
.block-meta { font-size: 12.5px; color: var(--ink-2); }
.block-notes { font-size: 12.5px; color: var(--ink-3); }

/* build sheet */

.build-section { display: grid; gap: 10px; }
.build-section + .build-section { margin-top: 18px; }

.preview-list {
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
}
.preview-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-2);
  font-size: 14px;
}
.preview-row:last-child { border-bottom: 0; }
.preview-day { width: 40px; flex: none; font-size: 12px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
.preview-main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.preview-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-fac { font-size: 12px; color: var(--ink-3); }

/* facilities reference */

.fac-card { padding: 0; overflow: hidden; }
.fac-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 12px 16px;
  border: 0;
  background: transparent;
  text-align: left;
}
.fac-head:hover { background: var(--surface-2); }
.fac-head:focus-visible { outline-offset: -2px; }
.fac-names { display: grid; gap: 1px; min-width: 0; }
.fac-names strong { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }
.fac-loc { font-size: 12.5px; color: var(--ink-3); }
.fac-head .icon { width: 16px; height: 16px; color: var(--ink-3); transition: transform .2s var(--ease); flex: none; }
.fac-head[aria-expanded="true"] .icon { transform: rotate(180deg); }

.fac-body { padding: 0 16px 16px; display: grid; gap: 12px; border-top: 1px solid var(--line-2); }
.fac-summary { font-size: 14px; color: var(--ink-2); padding-top: 12px; }
.fac-group { display: grid; gap: 3px; }
.fac-group h4 {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.fac-group p { font-size: 13.5px; color: var(--ink-2); line-height: 1.55; }
.fac-notes { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 13px; color: var(--ink-3); }

/* ------------------------------------------------------------------- body */

.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.profile-grid .field.span-2 { grid-column: 1 / -1; }

.goal-chips { display: flex; flex-wrap: wrap; gap: 8px; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile {
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: grid;
  gap: 2px;
  align-content: start;
}
.tile:last-child:nth-child(odd) { grid-column: 1 / -1; }
.tile-val { font-size: 20px; font-weight: 650; letter-spacing: -0.01em; display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; }
.tile-unit { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.est { font-size: 10.5px; font-weight: 600; color: var(--ink-3); }
.tile-label { font-size: 12px; font-weight: 600; color: var(--ink-2); }

.history { display: grid; }
.hist-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-2);
}
.hist-row:last-child { border-bottom: 0; }
.hist-main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.hist-date { font-size: 14px; font-weight: 600; }
.hist-notes { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-right { display: grid; gap: 1px; justify-items: end; }
.hist-weight { font-size: 15px; font-weight: 650; }
.hist-bf { font-size: 12px; color: var(--ink-3); }

.delta { font-size: 12.5px; font-weight: 650; color: var(--ink-2); }
.delta.up { color: var(--amber); }
.delta.down { color: var(--ink); }

.spark-wrap { position: relative; }
.spark-wrap svg { display: block; width: 100%; height: auto; }
.spark-hit { cursor: pointer; }
.spark-hit:focus-visible { outline: none; }
.spark-tip {
  position: absolute;
  transform: translate(-50%, -100%);
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow);
}
.spark-tip strong { font-weight: 650; }
.spark-tip[hidden] { display: none; }
.spark-fallback { font-size: 14px; color: var(--ink-2); }

.footnote {
  font-size: 12px;
  color: var(--ink-3);
  text-align: center;
  padding: 8px 16px 0;
}

/* --------------------------------------------------------------- settings */

.settings { display: grid; gap: 20px; }
.settings-block { display: grid; gap: 6px; justify-items: start; }
.settings-name { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }

/* ----------------------------------------------------------------- sheets */

#sheet-root { position: relative; z-index: 80; }

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(22, 24, 26, .42);
  animation: scrim-in .2s ease both;
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 640px;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 40px rgba(22, 24, 26, .18);
  animation: sheet-up .28s var(--ease) both;
}

@keyframes sheet-up {
  from { transform: translate(-50%, 24px); opacity: .4; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
@keyframes scrim-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sheet-grab {
  width: 36px;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--line);
  margin: 8px auto 0;
  flex: none;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px 6px 20px;
  flex: none;
}
.sheet-head h2 { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }

.sheet-body {
  padding: 4px 20px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.sheet-foot {
  flex: none;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line-2);
  background: var(--surface);
}

body.sheet-open { overflow: hidden; }

/* ------------------------------------------------------ runtime frontend */

.muted { color: var(--ink-2); font-size: 14px; }

.hero-panel {
  display: grid;
  gap: 8px;
  padding: 8px 2px 2px;
}
.hero-panel h1 {
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: -0.035em;
}
.hero-panel p:not(.section-title) { color: var(--ink-2); font-size: 14.5px; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.metric-card {
  display: grid;
  gap: 4px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow);
}
.metric-card span { font-size: 12px; font-weight: 650; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.metric-card strong { font-size: 21px; letter-spacing: -0.025em; }

.meal-list, .workout-week, .block-list, .facility-list { display: grid; gap: 10px; }
.workout-card.is-compact { box-shadow: none; background: var(--surface-2); }
.workout-block {
  display: grid;
  gap: 2px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-2);
}
.workout-block:last-child { border-bottom: 0; }
.workout-block strong { font-size: 14.5px; }
.workout-block span { font-size: 13.5px; color: var(--brand-ink); font-weight: 650; }
.workout-block small { color: var(--ink-3); }

.facility-card {
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 0;
  overflow: hidden;
}
.facility-card summary {
  display: grid;
  gap: 3px;
  padding: 13px 14px;
  cursor: pointer;
}
.facility-card summary span { color: var(--ink-2); font-size: 13.5px; }
.facility-card > .chip-row,
.facility-card > .muted,
.facility-card > .mini-list { padding: 0 14px 14px; }

.mini-list { margin: 0; padding-left: 20px; color: var(--ink-2); font-size: 14px; }
.mini-list p { margin: 0 0 8px; }

.btn.primary, .btn-primary { background: var(--brand); color: #fff; }
.btn.primary:hover, .btn-primary:hover { background: var(--brand-ink); }

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(22, 24, 26, .42);
  animation: scrim-in .2s ease both;
}
.sheet-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  background: var(--surface-2);
}
.sheet > .sheet-form,
.sheet > .meal-detail {
  padding: 44px 20px calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto;
}

/* ------------------------------------------------------------------ login */

.login-body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 36px 28px 28px;
  display: grid;
  gap: 10px;
}

.login-card .wordmark { font-size: 30px; }
.login-lede { font-size: 14.5px; color: var(--ink-2); margin-bottom: 8px; }

.login-form { display: grid; gap: 10px; }
.login-form input { min-height: 48px; }
.login-form button {
  min-height: 48px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  transition: background .15s ease;
}
.login-form button:hover { background: var(--brand-ink); }

.login-error {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--danger);
  background: #F9ECEB;
  border: 1px solid #F0D7D5;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.login-foot {
  font-size: 12px;
  color: var(--ink-3);
  text-align: center;
  margin-top: 8px;
}

/* ---------------------------------------------------------------- desktop */

@media (min-width: 1024px) {
  .view { padding-top: 28px; }
  .meal-grid { grid-template-columns: 1fr 1fr; align-items: start; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .tile:last-child:nth-child(odd) { grid-column: auto; }
  .sheet { border-radius: 20px 20px 0 0; }
  .member-switcher { max-width: none; }
}

/* --------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
