/* Nibble — styles. Strict CSP-friendly: all styling lives here, none inline. */

:root {
  --bg: #f4f7f4;
  --card: #ffffff;
  --ink: #1e2620;
  --muted: #6b7770;
  --line: #e6ece7;
  --brand: #2fae60;
  --brand-ink: #1f8f4d;
  --btn-primary-bg: #22a457;
  --good: #1f8f4d;
  --bad: #dc4d3f;
  /* macronutrient accent colours (radar + bars) */
  --macro-protein: #22b866;
  --macro-carbs: #3b82f6;
  --macro-fat: #8b5cf6;
  --macro-fiber: #14b8a6;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(20, 40, 30, 0.06), 0 8px 24px rgba(20, 40, 30, 0.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Dark palette — applied when the user explicitly picks Dark (data-theme="dark"), or (below)
   when the system prefers dark AND no theme is set. "System" removes data-theme so the media
   query decides live; "light"/"dark" force the palette regardless of the system. */
:root[data-theme="dark"] {
  --bg: #14181a;
  --card: #1c2124;
  --ink: #eef2ee;
  --muted: #9aa5a0;
  --line: #2b3238;
  --brand: #34c26e;
  --brand-ink: #5fd48f;
  --btn-primary-bg: #1f8f4d;
  --good: #34c26e;
  --bad: #e2685c;
  --macro-protein: #34c26e;
  --macro-carbs: #5b9bf8;
  --macro-fat: #a78bfa;
  --macro-fiber: #2dd4bf;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #14181a;
    --card: #1c2124;
    --ink: #eef2ee;
    --muted: #9aa5a0;
    --line: #2b3238;
    --brand: #34c26e;
    --brand-ink: #5fd48f;
    --btn-primary-bg: #1f8f4d;
    --good: #34c26e;
    --bad: #e2685c;
    --macro-protein: #34c26e;
    --macro-carbs: #5b9bf8;
    --macro-fat: #a78bfa;
    --macro-fiber: #2dd4bf;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
  }
}

* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}

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

a {
  color: var(--brand-ink);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Consent gate ---- */
#consent-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(20, 17, 15, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}
body[data-consented] #consent-overlay {
  display: none;
}
.consent-card {
  background: var(--card);
  color: var(--ink);
  max-width: 560px;
  width: 100%;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin: auto;
}
.intro-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  padding: 8px 0 20px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line, rgba(0, 0, 0, 0.08));
}
.intro-logo {
  width: 76px;
  height: 76px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 22px;
  background: color-mix(in srgb, var(--brand) 14%, var(--card));
  font-size: 2.6rem;
  line-height: 1;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 22%, transparent);
}
.intro-wordmark {
  margin-top: 12px;
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--brand-ink);
}
.intro-tagline {
  font-size: 0.92rem;
  color: var(--muted);
}
.consent-card h1 {
  margin-top: 0;
  font-size: 1.4rem;
}

/* Branded launch/splash screen. All rules live here (not inline in <head>) because the
   app's CSP is `style-src 'self'`, which blocks inline <style>; styles.css is render-
   blocking in <head>, so the splash is still fully styled on the first paint. */
#splash {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: linear-gradient(160deg, #2fae60 0%, #1f8f4c 100%);
  transition: opacity 0.4s ease;
}
#splash .splash-logo {
  width: 104px;
  height: 104px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 3.4rem;
  line-height: 1;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  animation: splash-pop 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
#splash .splash-word {
  /* Distinct geometric wordmark font (self-hosted stack — no external fonts under CSP),
     uppercase with wide tracking for a branded logotype look. */
  font-family: "Avenir Next", "Futura", "Century Gothic", ui-rounded, "SF Pro Rounded",
    "Trebuchet MS", system-ui, sans-serif;
  font-size: 1.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  /* the tracking adds trailing space on the right; nudge back so it stays optically centered */
  text-indent: 0.22em;
  color: #fff;
  animation: splash-rise 0.5s ease 0.18s both;
}
#splash.is-hiding {
  opacity: 0;
  pointer-events: none;
}
#splash[hidden] {
  display: none;
}
@keyframes splash-pop {
  0% {
    opacity: 0;
    transform: scale(0.72);
  }
  60% {
    transform: scale(1.06);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}
@keyframes splash-rise {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}
@media (prefers-reduced-motion: reduce) {
  #splash .splash-logo,
  #splash .splash-word {
    animation: none;
  }
}

/* First-launch onboarding carousel (installed / standalone only) */
.onboarding {
  position: fixed;
  inset: 0;
  z-index: 110; /* above the consent gate (z-index 100), which it precedes on first launch */
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg);
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
}
.onboarding[hidden] {
  display: none;
}
.onb-skip {
  align-self: flex-end;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 6px 8px;
  cursor: pointer;
}
.onb-viewport {
  flex: 1 1 auto;
  width: 100%;
  max-width: 520px;
  overflow: hidden;
  align-self: center;
}
.onb-track {
  display: flex;
  height: 100%;
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}
.onb-slide {
  flex: 0 0 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 12px;
  gap: 6px;
}
.onb-art {
  width: 128px;
  height: 128px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 32px;
  margin-bottom: 22px;
  background: color-mix(in srgb, var(--brand) 12%, var(--card));
  color: var(--brand);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--brand) 20%, transparent);
}
.onb-art .fa-ic {
  height: 3.4rem;
}
.onb-art-brand {
  font-size: 4rem;
  line-height: 1;
}
.onb-title {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--brand-ink);
}
.onb-body {
  margin: 4px 0 0;
  max-width: 22rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}
.onb-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 20px 0;
}
.onb-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--brand) 25%, transparent);
  transition: width 0.24s ease, background 0.24s ease;
}
.onb-dot.is-active {
  width: 22px;
  border-radius: 4px;
  background: var(--brand);
}
.onb-next {
  width: 100%;
  max-width: 520px;
  padding: 15px;
  border: none;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 30%, transparent);
}
.onb-next:active {
  transform: scale(0.99);
}
.consent-card ul {
  padding-left: 1.1rem;
}
.consent-check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  margin: 16px 0;
  font-size: 0.95rem;
  cursor: pointer;
}
.consent-check input {
  flex: 0 0 auto;
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 2px;
  padding: 0;
}

/* ---- Layout ---- */
.site-header {
  text-align: center;
  padding: 28px 16px 8px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.8rem;
}
.brand-mark {
  font-size: 1.8rem;
}
.brand-name {
  color: var(--brand-ink);
}
.tagline {
  color: var(--muted);
  margin: 6px 0 0;
  font-size: 1rem;
  font-weight: 400;
}

#app {
  max-width: 620px;
  margin: 0 auto;
  padding: 12px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card h2 {
  margin: 0 0 12px;
  font-size: 1.15rem;
}
.diary-sub {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 14px 0 6px;
}

/* ---- Day nav ---- */
.day-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px 12px;
}
.day-label {
  text-align: center;
  line-height: 1.2;
}
.day-date {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
}
#day-title:not(:empty) {
  font-weight: 700;
  color: var(--brand-ink);
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 1.3rem;
  cursor: pointer;
}
.icon-btn .fa-ic { vertical-align: 0; }

/* ---- Summary ---- */
.summary-figure {
  text-align: center;
  padding: 6px 0 12px;
}
.summary-big {
  display: block;
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--brand-ink);
  line-height: 1;
}
.summary-caption {
  color: var(--muted);
  font-size: 0.9rem;
}
.summary-breakdown,
.macros {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}
.summary-breakdown {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.macros {
  margin-top: 12px;
}
.bd-label,
.macro-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
}
.bd-value {
  display: block;
  font-weight: 700;
  font-size: 1.2rem;
}
.macro-value {
  display: block;
  font-weight: 600;
}

/* ---- Forms ---- */
input,
select,
button {
  font-family: inherit;
  font-size: 1rem;
}
input:not([type="checkbox"]):not([type="radio"]),
select {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
  color: var(--ink);
  width: 100%;
}
button {
  cursor: pointer;
  border-radius: 9px;
  padding: 10px 16px;
  border: 1px solid transparent;
  font-weight: 600;
  white-space: nowrap;
}
/* Inline Font Awesome icon — scales with the current font size, inherits text colour */
.fa-ic {
  height: 1em;
  width: auto;
  display: inline-block;
  vertical-align: -0.125em;
  fill: currentColor;
}
button.primary,
#consent-accept {
  background: var(--btn-primary-bg);
  color: #fff;
}
button.primary:disabled,
#consent-accept:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
button.secondary {
  background: var(--bg);
  color: var(--ink);
  border-color: var(--line);
}
button.danger {
  background: transparent;
  color: var(--bad);
  border-color: var(--bad);
}
#consent-accept {
  width: 100%;
  padding: 12px;
  font-size: 1.05rem;
}

.search-row,
.exercise-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.search-row input[type="search"] {
  flex: 1 1 200px;
}
/* Scan lives as an icon inside the search field */
.search-input-wrap {
  position: relative;
  flex: 1 1 200px;
  min-width: 0;
  display: flex;
}
.search-input-wrap input[type="search"] {
  flex: 1 1 auto;
  width: 100%;
  padding-right: 46px; /* room for the scan icon */
}
.scan-icon-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}
.scan-icon-btn:hover {
  color: var(--brand-ink);
  background: var(--line);
}
.scan-icon-btn svg {
  display: block;
}
.exercise-row select {
  flex: 1 1 180px;
}
.exercise-row input {
  flex: 0 0 110px;
}
.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.settings-grid select {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font-size: 0.95rem;
}
/* Calorie-calculator result */
.calc-result {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  text-align: center;
}
.calc-target {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}
.calc-target-num {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--brand-ink);
  letter-spacing: -0.02em;
}
.calc-target-unit {
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 600;
}
.calc-target-sub {
  margin: 2px 0 14px;
  font-size: 0.85rem;
  color: var(--muted);
}
.calc-stats {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.calc-stat {
  flex: 1 1 90px;
  min-width: 90px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 6px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--brand) 8%, var(--card));
}
.calc-stat-label {
  font-size: 0.72rem;
  color: var(--muted);
}
.calc-stat-val {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--brand-ink);
}
.calc-use {
  width: 100%;
}
.calc-disclaimer {
  margin-top: 10px;
  font-size: 0.72rem;
}
.settings-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
  color: var(--muted);
}
.settings-grid button {
  align-self: flex-start;
}
.data-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}

.status {
  color: var(--muted);
  font-size: 0.9rem;
  min-height: 1.2em;
  margin: 10px 0 0;
}
.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 8px 0 0;
}
.empty {
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
  margin: 4px 0;
}

/* ---- Scanner ---- */
/* Full-screen barcode scanner: a centred camera view with a rectangle viewfinder. */
.scanner-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  display: flex;
  flex-direction: column;
}
.scanner-stage {
  position: relative;
  flex: 1 1 auto;
  overflow: hidden;
}
.scanner-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.scanner-reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(82%, 340px);
  aspect-ratio: 2.6 / 1;
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  /* dims everything outside the rectangle, focusing the eye on the barcode window */
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.5);
}
.scanner-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18px;
  margin: 0;
  text-align: center;
  color: #fff;
  font-size: 0.9rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.scanner-stop {
  flex: 0 0 auto;
  margin: 14px auto calc(14px + env(safe-area-inset-bottom, 0px));
  background: #fff;
  color: #111;
  border: none;
  border-radius: 999px;
  padding: 12px 30px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}

/* ---- Results ---- */
.results {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.result-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  flex-wrap: wrap;
}
.ri-info {
  flex: 1 1 160px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.ri-name {
  font-weight: 600;
}
.ri-per {
  font-size: 0.82rem;
  color: var(--muted);
}
.ri-kcal {
  flex: 0 0 90px;
}
.ri-amount {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 5px;
}
.ri-grams {
  flex: 0 0 68px;
  width: 68px;
}
.ri-unit {
  font-size: 0.82rem;
  color: var(--muted);
}
.ri-name-input {
  flex: 1 1 140px;
}
.ri-add {
  flex: 0 0 auto;
}

/* ---- Diary list ---- */
.diary-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.diary-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
}
.di-name {
  flex: 1 1 auto;
  min-width: 0;
}
.di-value {
  font-weight: 600;
  color: var(--brand-ink);
}
.di-remove {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 10px;
  min-width: 40px;
  min-height: 40px;
  font-size: 1rem;
  cursor: pointer;
}

/* ---- Meal groups + expandable per-item nutrition ---- */
.meal-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.meal-header {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  color: var(--brand-ink);
}
.meal-icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--brand) 10%, var(--card));
  font-size: 1.2rem;
  line-height: 1;
}
.meal-add {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  transition: transform 0.06s ease, filter 0.12s ease;
}
.meal-add .fa-ic {
  height: 1.35rem;
}
.meal-add:hover {
  filter: brightness(1.06);
}
.meal-add:active {
  transform: scale(0.92);
}
.meal-mid {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.meal-name {
  font-weight: 700;
  font-size: 0.95rem;
}
.meal-sub {
  font-weight: 500;
  font-size: 0.74rem;
  color: var(--muted);
}
.meal-header .meal-kcal {
  flex: 0 0 auto;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
}
.diary-empty-row {
  list-style: none;
  color: var(--muted);
  font-style: italic;
  font-size: 0.85rem;
  padding: 2px 8px 6px 40px;
}
.diary-item.food {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0;
}
.di-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 6px 12px;
}
.di-main {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px; /* comfortable tap target */
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  padding: 4px 0;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
}
.di-name {
  font-size: 0.98rem;
}
.di-main::after {
  content: "›";
  color: var(--muted);
  font-size: 1rem;
  margin-left: 2px;
}
.nutrition-panel {
  padding: 8px 12px 10px 26px;
  border-top: 1px dashed var(--line);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 18px;
}
.np-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.82rem;
}
.np-row.np-sub .np-label {
  padding-left: 12px;
  opacity: 0.85;
}
.np-label {
  color: var(--muted);
}
.np-value {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.np-foot {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

/* Rating strip + Nutri-Score badge */
.ri-rating {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}
.ri-rating-text {
  font-size: 0.78rem;
  color: var(--muted);
}
.nutri-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 800;
  color: #fff;
}
.nutri-a { background: #038141; }
.nutri-b { background: #85bb2f; }
.nutri-c { background: #fecb02; color: #3a3320; }
.nutri-d { background: #ee8100; }
.nutri-e { background: #e63e11; }

/* Result-row controls (amount + meal + add) */
.ri-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ri-amount-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ri-mode {
  flex: 0 0 auto;
  padding: 6px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font-size: 0.82rem;
}
.ri-serving-hint {
  font-size: 0.76rem;
  color: var(--brand-ink);
  margin-top: 2px;
}
.ri-serving-hint:empty {
  display: none;
}
/* Diary search box acts as a launcher into the #search subpage */
.search-launcher {
  cursor: pointer;
}
/* "Add food" launcher button on a meal page */
.meal-add-food {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-bottom: 14px;
}
.meal-add-food .fa-ic {
  height: 1rem;
}
.ri-meal {
  flex: 0 0 auto;
}

/* ---- Comparison / SEO landing pages (myfitnesspal-alternative.html) ---- */
.compare {
  max-width: 760px;
}
.lede {
  font-size: 1.08rem;
}
.honest {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  color: var(--muted);
}
.cta-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
a.primary,
a.secondary {
  display: inline-block;
  text-decoration: none;
  cursor: pointer;
  border-radius: 9px;
  padding: 10px 16px;
  border: 1px solid transparent;
  font-weight: 600;
}
a.primary {
  background: var(--btn-primary-bg);
  color: #fff;
}
a.secondary {
  background: var(--bg);
  color: var(--ink);
  border-color: var(--line);
}
.wins {
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.table-scroll {
  overflow-x: auto;
  margin: 0 -18px;
  padding: 0 18px;
}
table.cmp {
  border-collapse: collapse;
  width: 100%;
  min-width: 560px;
  font-size: 0.92rem;
}
table.cmp th,
table.cmp td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
table.cmp thead th {
  background: var(--bg);
}
table.cmp td.yes {
  color: var(--good);
  font-weight: 600;
}
.fineprint {
  color: var(--muted);
  font-size: 0.82rem;
}
ol.sources {
  color: var(--muted);
  font-size: 0.85rem;
  padding-left: 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ---- Footer ---- */
.site-footer {
  max-width: 620px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}
.footer-links {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.back-link {
  margin-top: 20px;
}

/* ---- Daily-reminder nudge + controls ---- */
.nudge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: color-mix(in srgb, var(--brand) 14%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--brand) 40%, var(--line));
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 0.95rem;
}
.nudge span { flex: 1; }
.nudge-x {
  flex: 0 0 auto;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  padding: 0 4px;
}
.reminder-check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.reminder-check input {
  flex: 0 0 auto;
  width: 1.15rem;
  height: 1.15rem;
  padding: 0;
}
.reminder-time-row {
  margin-top: 10px;
}
.reminder-time-row input[type="time"] {
  width: auto;
}

/* ============================================================
   Single-viewport app layout + Lifesum-style goal ring
   ============================================================ */
#app.app-screen {
  position: relative; /* anchor for overlays */
  min-height: 100dvh; /* fill the screen but grow with content — the page scrolls normally */
  max-width: 520px;
  gap: 10px;
  /* leave room for the fixed bottom tab bar */
  padding: 10px 14px calc(74px + env(safe-area-inset-bottom, 0px));
}
/* the settings page has no tab bar */
.settings-screen.app-screen {
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}
/* leave extra room when the install-bar floats above the tab bar */
body.has-install-bar #app.app-screen {
  padding-bottom: calc(142px + env(safe-area-inset-bottom, 0px));
}

/* Subpage overlay (meal detail / food detail) — a viewport-fixed panel that scrolls on its
   own, independent of the page. Content is centred in the same column width as the app. */
.subview {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  overflow-y: auto;
  padding: 12px max(14px, calc((100% - 520px) / 2)) calc(24px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.subview-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.subview-back {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  color: var(--brand-ink);
  font-size: 1.4rem;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
}
.subview-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.subview-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--ink);
}
.subview-sub {
  font-size: 0.82rem;
  color: var(--muted);
}
.subview-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
}
.mealview-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mealview-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 14px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
}
.mealview-item .mvi-name {
  flex: 1 1 auto;
  min-width: 0;
}
.mealview-item .mvi-kcal {
  font-weight: 600;
  color: var(--brand-ink);
}
.foodview-amount {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: -4px;
}
.subview .nutrition-panel {
  padding: 4px 2px;
  border-top: none;
}
.foodview-remove {
  align-self: flex-start;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--bad);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
}

/* ===== Food-detail page ===== */
.food-headline {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.fh-icon { color: #f59e0b; font-size: 1.2rem; align-self: center; }
.fh-kcal { font-size: 2rem; font-weight: 800; color: var(--ink); }
.fh-unit { color: var(--muted); }
.fh-amount { margin-left: auto; color: var(--muted); font-size: 0.9rem; align-self: center; }

.macro-rings {
  display: flex;
  justify-content: space-around;
  gap: 8px;
  text-align: center;
}
.mring { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.ring-svg { width: 72px; height: 72px; }
.ring-pct { fill: var(--ink); font-size: 15px; font-weight: 700; }
.mring-label { font-weight: 600; color: var(--ink); font-size: 0.85rem; margin-top: 4px; }
.mring-g { color: var(--muted); font-size: 0.8rem; }

.rating-card { display: flex; flex-direction: column; gap: 8px; }
.rating-row { display: flex; align-items: center; gap: 10px; }
.rating-text { color: var(--muted); font-size: 0.9rem; }
.nutri-badge-lg {
  min-width: 34px;
  height: 34px;
  font-size: 1.1rem;
  border-radius: 8px;
}

.section-eyebrow { padding: 4px 2px 0; }
.nutri-info { padding: 4px 14px; }
.ni-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
}
.ni-label { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); min-width: 0; }
.ni-sub .ni-label { padding-left: 34px; color: var(--muted); }
.ni-value { color: var(--ink); font-variant-numeric: tabular-nums; }
.ni-sub .ni-value { color: var(--muted); }
.ni-divider { height: 1px; background: var(--line); }
.ni-badge {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
}
.ni-carbs { background: var(--macro-carbs); }
.ni-fiber { background: var(--macro-fiber); }
.ni-protein { background: var(--macro-protein); }
.ni-fat { background: var(--macro-fat); }
.ni-fire { flex: 0 0 auto; width: 24px; display: inline-flex; justify-content: center; color: #f59e0b; }

/* Meal page: search + daily-intake */
.meal-search { display: flex; gap: 8px; }
.meal-search-input { flex: 1 1 auto; width: 100%; padding-right: 46px; }
.intake-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.intake-val { font-weight: 700; color: var(--brand-ink); font-size: 0.95rem; }

/* Activity log subpage */
.activity-controls {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.activity-search {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
}
.activity-min {
  flex: 0 0 92px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.72rem;
  color: var(--muted);
}
.activity-min input {
  width: 100%;
  padding: 10px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
}
.activity-note {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}
.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.activity-add-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}
.ai-info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.ai-name {
  font-weight: 600;
}
.ai-sub {
  font-size: 0.8rem;
  color: var(--muted);
}
.ai-add {
  flex: 0 0 auto;
  background: var(--brand);
  color: #fff;
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 700;
  font-size: 0.85rem;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}
.topbar .day-nav {
  flex: 1;
  border: none;
  box-shadow: none;
  background: transparent;
  padding: 0;
}
.settings-link { text-decoration: none; font-size: 1.2rem; display: inline-flex; align-items: center; justify-content: center; }

/* Ring card */
.ring-card {
  flex: 0 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
/* small uppercase section eyebrow (matches the reference cards) */
.card-eyebrow {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
/* Macronutrient-balance radar */
.radar-wrap { position: relative; width: 250px; max-width: 100%; aspect-ratio: 240 / 208; margin: 4px auto 0; }
.radar { width: 100%; height: 100%; overflow: visible; display: block; }
.radar-grid polygon { fill: none; stroke: var(--line); stroke-width: 1; }
.radar-axes line { stroke: var(--line); stroke-width: 1; }
.radar-poly {
  fill: var(--brand);
  fill-opacity: 0.25;
  stroke: var(--brand);
  stroke-width: 2.5;
  stroke-linejoin: round;
  transition: all 0.5s ease;
}
.radar-labels text { fill: var(--ink); font-size: 9.5px; font-weight: 700; }
.radar-labels .radar-val { fill: var(--muted); font-size: 8.5px; font-weight: 600; }
.radar-legend {
  display: flex;
  justify-content: center;
  gap: 16px;
  font-size: 0.72rem;
  color: var(--muted);
}
.radar-legend .lg {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.radar-legend .lg::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.radar-legend .lg-intake::before { background: var(--brand); }
.radar-legend .lg-goal::before { background: transparent; border: 1.5px solid var(--line); }

/* Calories remaining block */
.cal-remaining {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--brand) 9%, var(--card));
  border-radius: 12px;
}
.cr-eyebrow {
  margin: 0 0 2px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
}
.cr-value {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--brand-ink);
}
.cr-value.over { color: var(--bad); }
.cr-sub { margin: 3px 0 0; font-size: 0.78rem; color: var(--muted); }
.cr-flame {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--brand) 16%, var(--card));
  color: var(--brand);
  font-size: 1.25rem;
}

/* Colored macronutrient bars */
.macro-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mbar-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  margin-bottom: 4px;
}
.mbar-label { color: var(--ink); font-weight: 600; }
.mbar-val { color: var(--muted); font-variant-numeric: tabular-nums; }
.mbar-track {
  height: 7px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.mbar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s ease;
  min-width: 0;
}
.mbar-protein { background: var(--macro-protein); }
.mbar-carbs { background: var(--macro-carbs); }
.mbar-fat { background: var(--macro-fat); }
.mbar-fiber { background: var(--macro-fiber); }

/* ===== Tabbed views (Diary / Progress / Me) ===== */
.view {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.view-header {
  padding: 4px 2px 2px;
}
.view-header h1 {
  margin: 0;
  font-size: 1.4rem;
  color: var(--ink);
}

/* small standalone cards (water, insights) */
.mini-card {
  flex: 0 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mini-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

/* Water */
.water-count { font-size: 0.9rem; color: var(--muted); }
.water-count strong { color: var(--brand-ink); font-size: 1.05rem; }
.water-cups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.wcup {
  color: var(--line);
  font-size: 1.15rem;
  line-height: 1;
}
.wcup.full { color: var(--macro-carbs); }
.water-actions { display: flex; gap: 8px; }
.water-add {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.water-minus {
  flex: 0 0 auto;
  width: 44px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 9px;
}

/* Insights / streak */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #b45309;
  background: #fef3c7;
  padding: 3px 9px;
  border-radius: 999px;
}
.insights-msg { margin: 0; font-weight: 600; color: var(--ink); }
.insights-tip { margin: 0; font-size: 0.85rem; color: var(--muted); }

/* Progress */
.progress-ranges {
  display: flex;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
}
.range-btn {
  flex: 1 1 auto;
  padding: 7px 4px;
  border: none;
  background: transparent;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}
.range-btn.active {
  background: var(--brand);
  color: #fff;
}
.progress-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.progress-sub { font-size: 0.8rem; color: var(--muted); }
.chart-box { width: 100%; }
.chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 9px; }

/* Progress sub-tabs (Overview / Nutrition / Workouts) */
.progress-subtabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
}
.progress-subtabs .subtab {
  flex: 1 1 0;
  padding: 10px 4px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
.progress-subtabs .subtab.active {
  color: var(--brand-ink);
  border-bottom-color: var(--brand);
}

/* Big stat + delta header on progress cards */
.stat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin: 2px 0 8px;
}
.stat-num { font-size: 1.9rem; font-weight: 800; color: var(--ink); line-height: 1; }
.stat-unit { font-size: 0.9rem; color: var(--muted); }
.delta-badge {
  flex: 0 0 auto;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}
.delta-badge.good { color: var(--brand-ink); background: color-mix(in srgb, var(--brand) 12%, var(--card)); }
.delta-badge.up { color: var(--muted); background: var(--bg); }
.delta-note { font-weight: 500; font-size: 0.68rem; opacity: 0.8; }

/* Language select in Me */
.me-lang { max-width: 240px; }

/* ===== Bottom tab bar ===== */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  z-index: 40;
  width: 100%;
  max-width: 520px;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
}
.tab {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: transparent;
  border: none;
  padding: 6px 4px;
  color: var(--muted);
  font-weight: 600;
}
.tab .tab-ic { font-size: 1.15rem; line-height: 1; }
.tab-label { font-size: 0.72rem; }
.tab.active { color: var(--brand-ink); }

/* Workouts tab */
.log-workout-btn {
  width: 100%;
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  background: transparent;
  border: 1px solid var(--brand);
  color: var(--brand-ink);
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}
.ws-stats {
  display: flex;
  gap: 10px;
}
.ws-stat {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 6px;
  background: var(--bg);
  border-radius: 12px;
}
.ws-ic {
  font-size: 1.2rem;
  margin-bottom: 2px;
}
.ws-fire { color: #f59e0b; }
.ws-clock { color: var(--macro-carbs); }
.ws-stat strong { font-size: 1.35rem; color: var(--ink); line-height: 1; }
.ws-unit { font-size: 0.72rem; color: var(--muted); }

/* Week-day selector */
.week-days {
  display: flex;
  gap: 6px;
  overflow-x: auto;
}
.wday {
  flex: 1 1 0;
  min-width: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 2px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  color: var(--muted);
}
.wday-name { font-size: 0.66rem; }
.wday-num { font-size: 1rem; font-weight: 700; color: var(--ink); }
.wday.active {
  background: var(--brand);
  border-color: var(--brand);
}
.wday.active .wday-name,
.wday.active .wday-num { color: #fff; }

/* Workout log buttons */
.workout-actions { display: flex; gap: 8px; margin-top: 10px; }
.log-workout-btn,
.log-cardio-btn {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 0;
}
.log-workout-btn {
  background: var(--brand);
  color: #fff;
  border: none;
}
.log-cardio-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

/* Strength workout cards */
.strength-list { display: flex; flex-direction: column; gap: 10px; }
.strength-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.sc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.sc-info { display: flex; flex-direction: column; min-width: 0; }
.sc-name { font-weight: 700; color: var(--ink); }
.sc-meta { font-size: 0.8rem; color: var(--muted); }
.sc-exercises {
  list-style: none;
  margin: 8px 0 0;
  padding: 8px 0 0;
  border-top: 1px dashed var(--line);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.sc-exercises li { display: flex; justify-content: space-between; gap: 8px; font-size: 0.85rem; }
.sce-name { color: var(--ink); }
.sce-sets { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Workout builder */
.wb-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-size: 0.85rem; color: var(--muted); }
.wb-exlist { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.wb-ex { display: flex; align-items: center; gap: 8px; }
.wb-ex input.wb-name { flex: 1 1 auto; min-width: 0; width: auto; }
.wb-ex-grid { display: flex; gap: 6px; flex: 0 0 auto; }
.wb-ex .wb-ex-grid input { width: 52px; flex: 0 0 52px; padding: 8px 4px; text-align: center; }
.wb-addex {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--brand-ink);
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}
.wb-save { width: 100%; padding: 14px; }

/* Add-to-home-screen prompt bar */
.install-bar {
  position: fixed;
  left: 50%;
  bottom: calc(68px + env(safe-area-inset-bottom, 0px)); /* float just above the tab bar */
  transform: translateX(-50%);
  z-index: 50;
  width: calc(100% - 24px);
  max-width: 496px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}
.install-icon { font-size: 1.6rem; flex: 0 0 auto; }
.install-text { display: flex; flex-direction: column; gap: 1px; flex: 1 1 auto; min-width: 0; }
.install-text strong { font-size: 0.9rem; color: var(--brand-ink); }
.install-text span { font-size: 0.78rem; color: var(--muted); }
.install-action {
  flex: 0 0 auto;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 700;
  cursor: pointer;
}
.install-dismiss {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  padding: 6px;
  cursor: pointer;
}

.ring-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  text-align: center;
}
.ring-card .macros { width: 100%; padding-top: 8px; border-top: 1px solid var(--line); }

/* Add card (compact) */
.add-card {
  flex: 0 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.add-card .status:empty { display: none; }
.add-card .results:empty { display: none; }

/* Diary — the single scrollable region */
.diary-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
}

/* Settings page */
.settings-screen { overflow: hidden; }
.settings-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topbar-spacer { width: 40px; flex: 0 0 auto; }
.settings-screen .topbar .day-label { flex: 1; text-align: center; font-weight: 700; color: var(--brand-ink); }
