:root {
  --bg: #faf6f1;
  --surface: #ffffff;
  --surface-soft: #fdf3eb;
  --primary: #9c4221;
  --primary-dark: #7c3218;
  --primary-light: #bf5a34;
  --primary-soft: #fde8dd;
  --primary-border: #efc4ad;
  --nav-pill: #fbd9c7;
  --nav-pill-border: #e3a282;
  --text: #241c18;
  --muted: #6e5f58;
  --border: #eadfd7;
  --divider: #f3ece6;
  --green: #1f8a5b;
  --green-bg: #e5f6ed;
  --amber: #c27803;
  --amber-bg: #fef3dc;
  --red: #c93b3b;
  --red-bg: #fdeaea;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(48, 26, 16, 0.06);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(104px + env(safe-area-inset-bottom));
  overflow-x: hidden;
  line-height: 1.4;
}
header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--primary);
  color: #fff;
  padding-top: env(safe-area-inset-top);
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}
.header-top {
  padding: 11px 14px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.brand { display: flex; align-items: center; min-width: 0; flex: 1; }
.brand-title { font-weight: 800; font-size: 16.5px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 11.5px; opacity: 0.88; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.header-search-btn {
  height: 35px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1.3px solid rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #ffffff;
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.header-search-btn svg {
  width: 15px;
  height: 15px;
  display: block;
}
.header-search-btn:active {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(0.95);
}
@media (max-width: 355px) {
  .header-search-btn span { display: none; }
  .header-search-btn { width: 35px; padding: 0; justify-content: center; }
}
.account-btn {
  position: relative;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.32);
  background: rgba(255,255,255,0.14); color: #fff;
  padding: 0; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.account-btn.signed {
  background: rgba(255,255,255,0.22);
  border-color: rgba(255,255,255,0.48);
}
.account-btn:active { transform: scale(0.94); }
.account-btn svg { width: 19px; height: 19px; display: block; }
.account-sync-dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 10px; height: 10px; border-radius: 50%;
  background: #4ade80; border: 2px solid var(--primary);
}
.account-sync-dot.offline { background: #fbbf24; }
.dog-bar {
  background: rgba(0, 0, 0, 0.16);
  padding: 8px 14px 10px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.dog-select-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
}
.dog-select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255,255,255,0.14);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 10px;
  padding: 7px 30px 7px 11px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dog-select option {
  color: var(--text);
  background: #ffffff;
}
.dog-select-arrow {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 11px;
  opacity: 0.9;
}
.dog-action-btn {
  height: 35px;
  min-width: 35px;
  padding: 0 9px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.16);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
}
.dog-action-btn.add-btn {
  background: #ffffff;
  color: var(--primary);
  border-color: #ffffff;
  font-size: 19px;
  line-height: 1;
}
.dog-action-btn.capped {
  opacity: 0.55;
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-color: rgba(255,255,255,0.24);
}
.dog-meta-strip {
  background: var(--primary-dark);
  color: rgba(255,255,255,0.9);
  font-size: 11.5px;
  padding: 5px 14px 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
main { max-width: 680px; margin: 0 auto; padding: 14px; }
.tabs-viewport {
  position: relative;
  width: 100%;
  overflow-x: clip;
}
.tabs-viewport.animating {
  overflow: hidden;
}
.tab-panel {
  display: none;
  width: 100%;
  will-change: transform, opacity;
}
.tab-panel.active {
  display: block;
  position: relative;
  z-index: 2;
}
.tab-panel.leaving {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 1;
  pointer-events: none;
}
.tab-panel.enter-right {
  animation: tabSlideEnterRight 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.tab-panel.enter-left {
  animation: tabSlideEnterLeft 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.tab-panel.exit-left {
  animation: tabSlideExitLeft 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.tab-panel.exit-right {
  animation: tabSlideExitRight 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.sub-slide-right {
  animation: tabSlideEnterRight 0.24s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.sub-slide-left {
  animation: tabSlideEnterLeft 0.24s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes tabSlideEnterRight {
  from { opacity: 0; transform: translate3d(34px, 0, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes tabSlideEnterLeft {
  from { opacity: 0; transform: translate3d(-34px, 0, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes tabSlideExitLeft {
  from { opacity: 1; transform: translate3d(0, 0, 0); }
  to   { opacity: 0; transform: translate3d(-34px, 0, 0); }
}
@keyframes tabSlideExitRight {
  from { opacity: 1; transform: translate3d(0, 0, 0); }
  to   { opacity: 0; transform: translate3d(34px, 0, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .tab-panel.enter-right,
  .tab-panel.enter-left,
  .tab-panel.exit-left,
  .tab-panel.exit-right,
  .sub-slide-right,
  .sub-slide-left {
    animation: none !important;
  }
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.empty-hero {
  text-align: center;
  padding: 28px 18px;
}
.empty-hero .hero-ico { font-size: 46px; margin-bottom: 8px; }
.empty-hero h2 { margin: 0 0 6px; font-size: 19px; color: var(--primary); }
.empty-hero p { margin: 0 0 16px; font-size: 13.5px; color: var(--muted); }
.date-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 10px;
}
.nav-arrow {
  width: 38px; height: 38px; border-radius: 11px;
  border: 1.5px solid #dfd2c8; background: #fff;
  padding: 0; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text); flex-shrink: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.nav-arrow svg {
  width: 22px; height: 22px; display: block; flex-shrink: 0;
}
.nav-arrow:active {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
  transform: scale(0.95);
}
.date-picker-wrap {
  flex: 1; text-align: center; position: relative;
  background: #fff; border: 1px solid var(--border); border-radius: 11px;
  padding: 8px 10px; font-weight: 700; font-size: 14px; cursor: pointer;
}
.date-picker-wrap input[type="date"] {
  position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer;
}
.banner {
  border-radius: 12px; padding: 10px 12px; font-size: 12.5px; margin-bottom: 12px;
  display: flex; align-items: flex-start; gap: 8px;
}
.banner.info { background: var(--primary-soft); color: var(--primary); border: 1px solid var(--primary-border); }
.banner.amber { background: var(--amber-bg); color: #8a5300; border: 1px solid #f4d69c; }
.banner.red { background: var(--red-bg); color: #991b1b; border: 1px solid #f5c2c2; }
.banner.green { background: var(--green-bg); color: #166534; border: 1px solid #bce8cf; }
.progress-row { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.progress-track { height: 9px; background: #efe6de; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-light)); transition: width 0.25s ease; }
.meal-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding-bottom: 10px; margin-bottom: 6px; border-bottom: 1px solid var(--border);
}
.meal-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.meal-sub { font-size: 12px; color: var(--muted); font-weight: 500; }
.btn {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 10px; padding: 7px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.soft { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-border); }
.btn.danger { background: var(--red-bg); color: var(--red); border-color: #f4c6c6; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.item-row {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 10px 4px; border-bottom: 1px solid var(--divider);
}
.item-row:last-child { border-bottom: none; }
.check-box {
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0; margin-top: 1px;
  border: 2px solid #cbbab0; background: #fff; cursor: pointer;
  display: grid; place-items: center; color: #fff; font-size: 15px; font-weight: 800;
  transition: background-color 0.14s ease, border-color 0.14s ease, transform 0.1s ease;
}
.check-box:active { transform: scale(0.93); }
.check-box.checked { background: var(--green); border-color: var(--green); }
.item-body { flex: 1; min-width: 0; }
.item-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.item-name { font-weight: 650; font-size: 14px; }
.item-row.done .item-name { text-decoration: line-through; color: var(--muted); }
.item-brand { font-size: 12px; color: var(--primary-light); font-weight: 600; margin-top: 1px; }
.item-note { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.qty-pill {
  background: #f6efe9; border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; padding: 4px 9px; font-size: 12px; font-weight: 700;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.qty-pill.overridden { background: var(--primary-soft); border-color: var(--primary-light); color: var(--primary); }
.qty-pill.warn { background: var(--amber-bg); border-color: #e6b450; color: #8a5300; }
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.chip {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: #fff; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--muted);
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip.warn.active { background: var(--amber); border-color: var(--amber); }
.chip.bad.active { background: var(--red); border-color: var(--red); }
textarea, input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"], input[type="date"], input[type="search"], select.form-control {
  width: 100%; max-width: 100%; min-width: 0;
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px;
  font: inherit; font-size: 13.5px; background: #fff; color: var(--text);
}
.field input[type="date"] {
  display: block;
  width: 100%; max-width: 100%; min-width: 0;
  min-height: 40px;
  -webkit-appearance: none;
  appearance: none;
}
.field input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
  min-height: 1.3em;
}
.segmented {
  display: grid; grid-template-columns: 1fr 1fr; background: #efe6de;
  padding: 4px; border-radius: 12px; margin-bottom: 12px;
}
.segmented button {
  border: none; background: transparent; padding: 8px; border-radius: 9px;
  font-weight: 700; font-size: 13px; color: var(--muted); cursor: pointer;
}
.segmented button.active { background: #fff; color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 6px; text-align: center;
}
.kpi-val { font-size: 18px; font-weight: 800; color: var(--primary); }
.kpi-lbl { font-size: 11px; color: var(--muted); margin-top: 2px; }
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; text-align: center; }
.cal-dow { font-size: 11px; font-weight: 700; color: var(--muted); padding-bottom: 4px; }
.cal-day {
  aspect-ratio: 1; border-radius: 10px; border: 1px solid transparent;
  display: grid; place-items: center; font-size: 13px; font-weight: 700; cursor: pointer;
  background: #f4ede7; color: var(--muted);
}
.cal-day.complete { background: var(--green-bg); color: var(--green); border-color: #b7e4cc; }
.cal-day.partial { background: var(--amber-bg); color: var(--amber); border-color: #f3d28f; }
.cal-day.missed { background: var(--red-bg); color: var(--red); border-color: #f5c2c2; }
.cal-day.selected { outline: 2.5px solid var(--primary); outline-offset: 1px; }
.cal-day.empty { background: transparent; cursor: default; }
.legend { display: flex; gap: 12px; justify-content: center; font-size: 11.5px; color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700;
}
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.gray { background: #f1e9e2; color: var(--muted); }
.bottom-nav {
  position: fixed;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: 12px;
  right: 12px;
  max-width: 500px;
  margin: 0 auto;
  z-index: 35;
  padding: 5px;
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(255, 250, 246, 0.70) 0%, rgba(250, 236, 226, 0.58) 100%);
  backdrop-filter: blur(22px) saturate(190%);
  -webkit-backdrop-filter: blur(22px) saturate(190%);
  border: 1px solid rgba(255, 255, 255, 0.82);
  box-shadow:
    0 10px 30px rgba(124, 50, 24, 0.17),
    0 2px 8px rgba(36, 28, 24, 0.06),
    inset 0 1.5px 0 rgba(255, 255, 255, 0.92),
    inset 0 -1px 0 rgba(156, 66, 33, 0.13);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .bottom-nav {
    background: rgba(255, 248, 242, 0.95);
  }
}
.bottom-nav-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: stretch;
}
.nav-glider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 25%;
  border-radius: 21px;
  pointer-events: none;
  z-index: 0;
  background: linear-gradient(
    145deg,
    rgba(156, 66, 33, 0.22) 0%,
    rgba(191, 90, 52, 0.13) 56%,
    rgba(255, 255, 255, 0.55) 100%
  );
  border: 1px solid rgba(156, 66, 33, 0.30);
  box-shadow:
    0 4px 14px rgba(156, 66, 33, 0.16),
    inset 0 1.5px 1px rgba(255, 255, 255, 0.92),
    inset 0 -1px 2px rgba(156, 66, 33, 0.08);
  transform: translate3d(calc(var(--nav-idx, 0) * 100%), 0, 0);
  transition: transform 0.36s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}
.nav-item {
  position: relative;
  z-index: 1;
  border: none;
  background: transparent;
  color: #6b584f;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 2px 5px;
  cursor: pointer;
  border-radius: 21px;
  transition: color 0.22s ease, transform 0.14s ease;
}
.nav-item:active {
  transform: scale(0.95);
}
.nav-item span.ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 24px;
}
.nav-svg {
  width: 22px;
  height: 22px;
  display: block;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.nav-svg .svg-fill {
  fill: transparent;
  transition: fill 0.24s ease;
}
.nav-item.active {
  color: var(--primary);
  font-weight: 800;
}
.nav-item.active .nav-svg {
  transform: translateY(-1px) scale(1.07);
}
.nav-item.active .nav-svg .svg-fill {
  fill: rgba(156, 66, 33, 0.18);
}
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(32, 18, 12, 0.52);
  z-index: 50; display: none; align-items: flex-end; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
}
@media (min-width: 600px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 18px; }
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-title { font-size: 16px; font-weight: 800; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.field { margin-bottom: 10px; position: relative; min-width: 0; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.toast {
  position: fixed; bottom: calc(92px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 9px 16px; border-radius: 999px;
  font-size: 13px; font-weight: 600; z-index: 60; opacity: 0; pointer-events: none;
  transition: opacity 0.2s; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; }
.inline-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.small-muted { font-size: 12px; color: var(--muted); }
.cost-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.toggle-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  background: var(--surface-soft); border: 1px solid var(--primary-border); color: var(--primary);
  padding: 5px 10px; border-radius: 999px; cursor: pointer; margin-top: 5px;
}
.profile-card-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 0; border-bottom: 1px solid var(--divider);
}
.profile-card-row:last-child { border-bottom: none; }
.autocomplete-box {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(48, 26, 16, 0.14);
  max-height: 175px;
  overflow-y: auto;
  z-index: 70;
  display: none;
}
.autocomplete-box.open { display: block; }
.autocomplete-item {
  padding: 8px 11px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--divider);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item:active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

/* Stage 2: Offline Food Library & 8-Nutrient Editor */
.nutr-box {
  background: var(--surface-soft);
  border: 1px solid var(--primary-border);
  border-radius: 12px;
  padding: 10px 11px;
  margin-bottom: 12px;
}
.nutr-box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.nutr-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.nutr-grid .field { margin-bottom: 2px; }
.nutr-grid .field label { font-size: 11px; margin-bottom: 3px; }
.nutr-grid input { padding: 7px 9px; font-size: 13px; }
.item-nutr {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
}
.nutr-pill {
  background: var(--surface-soft);
  border: 1px solid var(--primary-border);
  color: var(--primary);
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 650;
}
.nutr-pill.muted {
  background: #f5efe9;
  border-color: var(--border);
  color: var(--muted);
}
.lib-cats {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin: 8px 0;
  scrollbar-width: none;
}
.lib-cats::-webkit-scrollbar { display: none; }
.lib-cats .chip { white-space: nowrap; flex-shrink: 0; padding: 5px 10px; font-size: 12px; }
.lib-list {
  max-height: 52vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.lib-row {
  padding: 10px 11px;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
}
.lib-row:last-child { border-bottom: none; }
.lib-row:hover, .lib-row:active { background: var(--primary-soft); }
.lib-row-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.lib-name { font-weight: 700; font-size: 13.5px; color: var(--text); }
.lib-meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.lib-tag {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: #f1e9e2;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.lib-tag.chilled { background: #e0f2fe; color: #075985; }
.lib-tag.raw { background: var(--amber-bg); color: #8a5300; }
.lib-tag.cooked { background: var(--green-bg); color: var(--green); }

/* Stage 2.1: Raw <-> Cooked Yield Helpers */
.cooked-line {
  font-size: 11.5px;
  color: var(--primary);
  font-weight: 650;
  margin-top: 3px;
}
.scoop-box {
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 10px;
}
.scoop-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.scoop-row input {
  flex: 1;
  padding: 7px 10px;
  font-size: 13px;
}


/* Stage 4B: Commercial Food Guaranteed Analysis & AAFCO Builder */
.ga-type-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 10px;
  scrollbar-width: none;
}
.ga-type-row::-webkit-scrollbar { display: none; }
.ga-type-row .chip {
  white-space: nowrap;
  flex-shrink: 0;
  padding: 6px 11px;
  font-size: 12px;
}
.ga-preview {
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 8px;
}
.ga-preview.warn {
  background: var(--amber-bg);
  border-color: #f3d28f;
}
.ga-nfe-readout {
  padding: 7px 9px;
  border: 1px dashed var(--primary-border);
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
}
.input-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 6px;
}


/* Stage 5A (USP): Inbuilt Whole-Food Diet Plan */
.segmented.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.segmented.three button {
  padding: 8px 3px;
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.supp-omega-box {
  background: #fff;
  border: 1px solid var(--primary-border);
  border-radius: 10px;
  padding: 8px 9px;
  margin-bottom: 8px;
}
.dp-meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}
.dp-weight-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 10px;
  align-items: end;
  background: var(--surface-soft);
  border: 1px solid var(--primary-border);
  border-radius: 12px;
  padding: 10px 11px;
}
.dp-cur-box {
  padding: 8px 10px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}
.dp-stepper {
  display: flex;
  align-items: center;
  gap: 5px;
}
.dp-stepper input {
  text-align: center;
  font-weight: 800;
  padding: 8px 6px;
}
.dp-step-btn {
  width: 34px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--primary);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
}
.dp-step-btn:active {
  background: var(--primary-soft);
}
.dp-req-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.dp-req-card {
  background: var(--surface-soft);
  border: 1px solid var(--primary-border);
  border-radius: 12px;
  padding: 9px 7px;
  text-align: center;
}
.dp-req-val {
  font-size: 16.5px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.15;
}
.dp-req-lbl {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
}
.dp-req-sub {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 2px;
}
.dp-why-box {
  background: #faf6f1;
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 9px 11px;
  font-size: 12px;
  color: var(--text);
  line-height: 1.45;
}
.dp-portion-row {
  padding: 11px 2px;
  border-bottom: 1px solid var(--divider);
}
.dp-portion-row:last-of-type {
  border-bottom: none;
}
.dp-serve-pill {
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  color: var(--primary);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  flex-shrink: 0;
}


/* Quiet inline safety note in Manage — rendered only when an imbalance exists */
.quiet-alert-note {
  margin-top: 8px;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--amber-bg);
  border: 1px solid #f3d28f;
  color: #6f4200;
  font-size: 11.5px;
  line-height: 1.35;
}
.quiet-alert-note + .quiet-alert-note {
  margin-top: 6px;
}


/* Upgraded Diet Planner micro-balancer toggles & safety-pass banner */
.dp-toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.dp-toggle-chip {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.dp-toggle-chip.active {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
}
.quiet-pass-note {
  margin-top: 8px;
  padding: 7px 10px;
  border-radius: 10px;
  background: #eaf7ee;
  border: 1px solid #addebd;
  color: #186834;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.35;
}
.dp-action-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 10px;
}


/* v18 UX & UI Polish: Compact single-dog header, 1-tap Settings rows, dismissible tip & iOS no-zoom */
.dog-bar.single-mode {
  background: var(--primary-dark);
  padding: 7px 14px 8px;
  justify-content: space-between;
  gap: 10px;
}
.single-dog-info {
  min-width: 0;
  flex: 1;
}
.single-dog-name {
  font-size: 13.5px;
  font-weight: 800;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.single-dog-meta {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.86);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.edit-pill-btn {
  height: 32px;
  padding: 0 11px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  white-space: nowrap;
}
.edit-pill-btn:active {
  background: rgba(255, 255, 255, 0.26);
}
.item-title-tap {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  padding: 1px 0;
}
.banner-dismiss-btn {
  margin-left: auto;
  border: none;
  background: rgba(156, 66, 33, 0.12);
  color: var(--primary);
  border-radius: 7px;
  width: 24px;
  height: 24px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.banner-dismiss-btn:active {
  background: rgba(156, 66, 33, 0.22);
}
.profile-card-row.clickable {
  cursor: pointer;
  padding: 10px 9px;
  margin: 0 -4px;
  border-radius: 10px;
  transition: background-color 0.14s ease;
}
.profile-card-row.clickable:hover,
.profile-card-row.clickable:active {
  background: var(--surface-soft);
}
.profile-card-row.active-row {
  background: var(--primary-soft);
}
.autosave-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--green);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.autosave-badge.visible {
  opacity: 1;
}
@media (max-width: 600px) {
  textarea,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="url"],
  input[type="date"],
  input[type="search"],
  select.form-control,
  .nutr-grid input,
  .scoop-row input,
  #dp-target-kg {
    font-size: 16px;
  }
}


/* v19 Deployment 1: Native Slide-Out Sidebar Drawer, Universal Search & Email Auth */
.modal-backdrop.top-sheet {
  align-items: flex-start;
  padding: max(12px, env(safe-area-inset-top)) 10px 12px;
}
.modal-backdrop.top-sheet .modal {
  border-radius: 20px;
  max-height: 84vh;
  box-shadow: 0 18px 44px rgba(32, 18, 12, 0.28);
}

body.overlay-open {
  overflow: hidden !important;
  overscroll-behavior: none;
}

.modal {
  overscroll-behavior: contain;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 48;
  background: rgba(32, 18, 12, 0.44);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  touch-action: none;
  overscroll-behavior: none;
  transition: opacity 0.26s ease;
}
.sidebar-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.sidebar-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(86vw, 342px);
  background: linear-gradient(180deg, rgba(254, 250, 246, 0.98) 0%, rgba(249, 241, 234, 0.98) 100%);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-left: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: -12px 0 36px rgba(36, 20, 12, 0.20);
  padding: max(14px, calc(8px + env(safe-area-inset-top))) 14px calc(18px + env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  transform: translate3d(104%, 0, 0);
  transition: transform 0.30s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.sidebar-backdrop.open .sidebar-drawer {
  transform: translate3d(0, 0, 0);
}
.sb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 2px 0;
  flex-shrink: 0;
}
.sb-brand {
  font-size: 15.5px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.01em;
}
.sb-account-card {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #ffffff;
  border-radius: 14px;
  padding: 11px 12px;
  box-shadow: 0 5px 15px rgba(156, 66, 33, 0.20);
  flex-shrink: 0;
}
.sb-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.20);
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
}
.sb-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.sb-section-lbl {
  font-size: 10.2px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0 4px;
  flex-shrink: 0;
}
.sb-group {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 2px 6px rgba(48, 26, 16, 0.03);
  flex-shrink: 0;
}
.sb-item {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--divider);
  background: transparent;
  padding: 9.5px 11px;
  font: inherit;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.14s ease;
}
.sb-item:first-child {
  border-radius: 14px 14px 0 0;
}
.sb-item:last-child {
  border-bottom: none;
  border-radius: 0 0 14px 14px;
}
.sb-item:only-child {
  border-radius: 14px;
}
.sb-item:hover,
.sb-item:active {
  background: var(--surface-soft);
}
.sb-ico {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sb-ico svg {
  width: 16px;
  height: 16px;
  display: block;
}
.sb-item-body {
  flex: 1;
  min-width: 0;
}
.sb-item-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.24;
}
.sb-item-sub {
  font-size: 10.8px;
  color: var(--muted);
  margin-top: 1.5px;
  line-height: 1.24;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-tag {
  font-size: 9.8px;
  font-weight: 800;
  padding: 2.5px 7px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  flex-shrink: 0;
}
.sb-tag.live {
  background: var(--green-bg);
  color: var(--green);
  border-color: #b7e4cc;
}
.sb-tag.warn {
  background: var(--amber-bg);
  color: #8a5300;
  border-color: #f3d28f;
}
.sb-tag.alert {
  background: var(--red-bg);
  color: var(--red);
  border-color: #f5c2c2;
}
.sb-tag.muted {
  background: #f2ebe4;
  color: var(--muted);
  border-color: var(--border);
}
.sb-chev {
  font-size: 15px;
  font-weight: 700;
  color: #b7a79e;
  flex-shrink: 0;
  padding-right: 2px;
}

/* v20 Single-Meal Generator & Tailored Kibble Finder UI */
.v20-tool-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.v20-tool-card {
  border: 1px solid var(--primary-border);
  background: linear-gradient(145deg, #ffffff 0%, var(--surface-soft) 100%);
  border-radius: 13px;
  padding: 10px 11px;
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.14s ease;
}
.v20-tool-card:active {
  transform: scale(0.98);
  border-color: var(--primary);
}
.v20-tool-title {
  font-size: 12.8px;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 5px;
}
.v20-tool-sub {
  font-size: 10.8px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.3;
}
.sm-preset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}
.sm-preset-btn {
  border: 1px solid var(--border);
  background: #ffffff;
  border-radius: 10px;
  padding: 7px 9px;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.sm-preset-btn:hover,
.sm-preset-btn:active {
  background: var(--primary-soft);
  border-color: var(--primary-border);
}
.sm-preset-lbl {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.sm-preset-sub {
  font-size: 10.2px;
  color: var(--muted);
  margin-top: 1px;
}
.sm-shelf-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  margin: 8px 0 5px;
}
.sm-chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.sm-ing-chip {
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  border-radius: 999px;
  padding: 5px 10px;
  font: inherit;
  font-size: 11.8px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.sm-ing-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  font-weight: 700;
}
.kibble-card {
  border: 1px solid var(--border);
  background: #ffffff;
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: 0 2px 7px rgba(48, 26, 16, 0.04);
}
.kibble-usp-list {
  margin: 8px 0;
  padding-left: 16px;
  font-size: 11.8px;
  color: var(--text);
  line-height: 1.42;
}
.kibble-usp-list li {
  margin-bottom: 3px;
}
.kibble-portion-box {
  background: var(--surface-soft);
  border: 1px solid var(--primary-border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 11.5px;
  margin-bottom: 9px;
}
.kibble-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.buy-aff-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-decoration: none;
  background: var(--primary);
  color: #ffffff;
  border: 1px solid var(--primary);
  border-radius: 9px;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 700;
}
.buy-aff-btn:active {
  opacity: 0.9;
}

/* Universal Spotlight Search */
.u-search-box {
  position: relative;
  margin-bottom: 10px;
}
.u-search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--primary);
  pointer-events: none;
}
.u-search-box input[type="search"] {
  padding-left: 38px;
  border: 1.5px solid var(--primary-border);
  border-radius: 12px;
  background: var(--surface-soft);
  font-weight: 600;
}
.u-search-box input[type="search"]:focus {
  outline: none;
  border-color: var(--primary);
  background: #ffffff;
}
.u-search-results {
  max-height: 60vh;
  overflow-y: auto;
}
.u-cat-head {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 10px 2px 5px;
}
.u-cat-head:first-child {
  margin-top: 2px;
}
.u-row {
  width: 100%;
  border: 1px solid var(--divider);
  background: #ffffff;
  border-radius: 11px;
  padding: 9px 11px;
  margin-bottom: 6px;
  font: inherit;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.u-row:hover,
.u-row:active {
  background: var(--primary-soft);
  border-color: var(--primary-border);
}
.u-row-main {
  min-width: 0;
  flex: 1;
}
.u-row-title {
  font-size: 13.2px;
  font-weight: 700;
  color: var(--text);
}
.u-row-sub {
  font-size: 11.2px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.u-jump-pill {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: var(--surface-soft);
  border: 1px solid var(--primary-border);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Email + Password Auth UI */
.pw-field-wrap {
  position: relative;
}
.pw-field-wrap input {
  padding-right: 58px;
}
.pw-toggle-btn {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: var(--surface-soft);
  color: var(--primary);
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 11px 0;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.google-auth-btn {
  width: 100%;
  border: 1.5px solid var(--border);
  background: #ffffff;
  color: var(--text);
  border-radius: 11px;
  padding: 9px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  transition: background-color 0.14s ease, border-color 0.14s ease;
}
.google-auth-btn:hover,
.google-auth-btn:active {
  background: #faf6f2;
  border-color: #d6c7bc;
}
.auth-msg-box {
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 9px;
  display: none;
}
.auth-msg-box.error {
  display: block;
  background: var(--red-bg);
  color: #991b1b;
  border: 1px solid #f5c2c2;
}
.auth-msg-box.ok {
  display: block;
  background: var(--green-bg);
  color: #166534;
  border: 1px solid #bce8cf;
}
.text-link-btn {
  border: none;
  background: none;
  color: var(--primary);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 0;
  cursor: pointer;
  text-decoration: underline;
}

.req-star {
  color: var(--red);
  font-weight: 800;
  margin-left: 2px;
}
.auth-email-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 11px;
  background: var(--surface-soft);
  border: 1px solid var(--primary-border);
  margin-bottom: 10px;
}
.auth-email-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.auth-step-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}


/* v21 Polish: iOS Bottom-Nav Safe Lift, Active Combo State, Editable Single-Meal Quantities & Health/Medical Suite */
@supports (-webkit-touch-callout: none) {
  .bottom-nav {
    bottom: max(24px, calc(10px + env(safe-area-inset-bottom)));
  }
  body {
    padding-bottom: max(116px, calc(102px + env(safe-area-inset-bottom)));
  }
  .toast {
    bottom: max(106px, calc(96px + env(safe-area-inset-bottom)));
  }
}
body.ios-device .bottom-nav {
  bottom: max(24px, calc(10px + env(safe-area-inset-bottom)));
}
body.ios-device {
  padding-bottom: max(116px, calc(102px + env(safe-area-inset-bottom)));
}
body.ios-device .toast {
  bottom: max(106px, calc(96px + env(safe-area-inset-bottom)));
}

.sm-preset-btn {
  position: relative;
  transition: background-color 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}
.sm-preset-btn.active {
  background: var(--primary-soft);
  border: 1.5px solid var(--primary);
  box-shadow: 0 2px 8px rgba(156, 66, 33, 0.13);
}
.sm-preset-btn.active .sm-preset-lbl {
  color: var(--primary);
  font-weight: 800;
}
.sm-preset-check {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--primary);
  color: #ffffff;
  margin-left: 4px;
  vertical-align: middle;
}

.sm-qty-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  padding: 5px 8px;
  border-radius: 9px;
  background: #faf6f2;
  border: 1px solid var(--border);
  flex-wrap: wrap;
}
.sm-mini-stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.sm-mini-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--primary-border);
  background: #ffffff;
  color: var(--primary);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.sm-mini-btn:active {
  background: var(--primary-soft);
}
.sm-mini-input {
  width: 64px !important;
  height: 28px;
  padding: 2px 6px !important;
  text-align: center;
  font-weight: 800;
  font-size: 13.5px !important;
  border-radius: 7px !important;
  border: 1px solid var(--border) !important;
  background: #ffffff !important;
}
@media (max-width: 600px) {
  .sm-mini-input {
    font-size: 16px !important;
  }
}
.sm-unit-toggle {
  display: inline-flex;
  background: #efe6de;
  padding: 2px;
  border-radius: 8px;
  gap: 2px;
}
.sm-unit-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.sm-unit-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.hw-form-card {
  background: #fcf9f6;
  border: 1px solid var(--primary-border);
  border-radius: 13px;
  padding: 11px 12px;
  margin-bottom: 12px;
}
.hw-record-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 11px 12px;
  margin-bottom: 9px;
}
.hw-record-card.resolved {
  opacity: 0.72;
  background: #faf7f4;
}
.notif-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
}
.notif-row:last-child {
  border-bottom: none;
}
.switch-pill {
  border: 1.5px solid var(--border);
  background: #f1e9e2;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
}
.switch-pill.on {
  background: var(--green-bg);
  border-color: #9cdbb8;
  color: var(--green);
}
input[type="time"] {
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  background: #ffffff;
  color: var(--text);
}
@media (max-width: 600px) {
  input[type="time"] {
    font-size: 16px;
  }
}

/* v21.1 Notification Pre-Prompt Guard & WebAPK Recovery Card */
.notif-guard-box {
  background: #fff8f3;
  border: 1.5px solid var(--primary);
  border-radius: 11px;
  padding: 10px 11px;
}
.notif-fix-steps {
  background: #fffaf5;
  border: 1px dashed var(--primary-border);
  border-radius: 10px;
  padding: 9px 10px;
}
.notif-fix-steps li {
  margin-bottom: 4px;
}
.notif-fix-steps li:last-child {
  margin-bottom: 0;
}
