:root {
  color-scheme: light;
  --page: #eef0f3;
  --background: var(--tg-theme-bg-color, #ffffff);
  --surface: var(--tg-theme-section-bg-color, #ffffff);
  --surface-soft: var(--tg-theme-secondary-bg-color, #f3f4f6);
  --text: var(--tg-theme-text-color, #17191d);
  --muted: var(--tg-theme-subtitle-text-color, #5f6570);
  --line: var(--tg-theme-section-separator-color, #e2e5e9);
  --accent: var(--tg-theme-button-color, #2468d8);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --warning: #fff7df;
  --warning-text: #5b4615;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background: var(--page);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button,
a,
label {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible + span {
  outline: 3px solid rgb(36 104 216 / 32%);
  outline-offset: 3px;
}

.screen h1[tabindex="-1"]:focus,
.meal-card h2[tabindex="-1"]:focus,
.success-message[tabindex="-1"]:focus {
  outline: none;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(100%, 460px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(28px, env(safe-area-inset-bottom));
  overflow: hidden;
  background: var(--background);
}

.app-header {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.brand {
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.step-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
}

.prototype-banner {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: 7px;
  margin: 0 0 38px;
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 550;
  line-height: 1.25;
}

.prototype-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.hero-copy {
  max-width: 410px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

h1 {
  max-width: 410px;
  margin: 0;
  color: var(--text);
  font-size: clamp(29px, 8vw, 36px);
  font-weight: 720;
  hyphens: none;
  letter-spacing: -0.035em;
  line-height: 1.08;
  overflow-wrap: normal;
}

.screen-welcome h1 {
  font-size: clamp(27px, 7.8vw, 34px);
}

.keep-word {
  white-space: nowrap;
}

.lead,
.section-heading > p:not(.eyebrow) {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.screen-welcome .button {
  margin-top: 34px;
}

.button {
  display: flex;
  width: 100%;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border: 0;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 650;
  cursor: pointer;
  transition: opacity 120ms ease, transform 120ms ease;
}

.button:active {
  transform: scale(0.99);
}

.button-primary {
  color: var(--accent-text);
  background: var(--accent);
}

.button-primary:hover {
  opacity: 0.94;
}

.button-secondary {
  color: var(--text);
  background: var(--surface-soft);
}

.fine-print,
.field-note,
.notice,
.prototype-stage-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.fine-print {
  margin: 22px 2px 0;
}

.back-button {
  min-height: 42px;
  margin: -6px 0 10px -9px;
  padding: 8px 9px;
  border: 0;
  color: var(--accent);
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.section-heading {
  margin-bottom: 30px;
}

.section-heading h1 {
  font-size: clamp(28px, 7.5vw, 34px);
}

.choice-group {
  margin: 0 0 26px;
  padding: 0;
  border: 0;
}

.choice-group legend {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
  padding: 0;
  font-size: 15px;
  font-weight: 650;
}

.choice-group legend span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.choice-grid-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.choice-card {
  position: relative;
  display: block;
  min-width: 0;
  cursor: pointer;
}

.choice-card input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.choice-card span {
  display: grid;
  min-height: 48px;
  padding: 9px 7px;
  place-items: center;
  border-radius: 11px;
  color: var(--text);
  font-size: 13px;
  font-weight: 560;
  line-height: 1.2;
  text-align: center;
}

.choice-card input:checked + span {
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--accent);
  color: var(--text);
  font-weight: 650;
}

.field-note {
  margin: 9px 2px 0;
}

.selection-summary {
  margin: 12px 0 0 !important;
  color: var(--muted) !important;
  font-size: 14px !important;
}

.prototype-stage-note {
  margin: -14px 0 18px;
  padding: 11px 12px;
  border-radius: 11px;
  background: var(--surface-soft);
}

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

.meal-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.meal-card-top,
.meal-card-bottom,
.totals-card > div,
.totals-macros,
.shopping-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.meal-tag {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.demo-tag {
  padding: 4px 7px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 11px;
  font-weight: 600;
}

.meal-card h2 {
  margin: 12px 0;
  font-size: 17px;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.015em;
}

.nutrition-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
}

.nutrition-row span {
  white-space: nowrap;
}

.nutrition-row b {
  color: var(--text);
  font-weight: 650;
}

.meal-card-bottom {
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.meal-card-bottom button {
  min-height: 40px;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 600;
}

.meal-card-bottom button:disabled {
  cursor: not-allowed;
  opacity: 0.75;
}

.totals-card {
  margin: 12px 0;
  padding: 17px;
  border-radius: var(--radius);
  color: #ffffff;
  background: #1b1d21;
}

.totals-card > div:first-child span { color: #c5c9d0; font-size: 13px; }
.totals-card > div:first-child strong { font-size: 20px; }
.totals-macros { margin-top: 13px; padding-top: 13px; border-top: 1px solid #3d4148; color: #d9dde3; font-size: 12px; }
.totals-macros b { color: #ffffff; font-size: 15px; }

.notice {
  margin: 14px 0 18px;
  padding: 12px 13px;
  border-radius: 11px;
  color: var(--warning-text);
  background: var(--warning);
}

.shopping-items {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  list-style: none;
}

.shopping-items li {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.shopping-items li:last-child { border-bottom: 0; }
.shopping-items span { display: flex; gap: 8px; align-items: flex-start; }
.shopping-items b { color: var(--accent); }
.shopping-items strong { white-space: nowrap; }

.shopping-total {
  margin: 14px 0;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.shopping-total span { color: var(--muted); font-size: 13px; }
.shopping-total strong { font-size: 21px; }

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

.success-message {
  margin: 14px 0 0;
  padding: 13px;
  border-radius: 11px;
  color: var(--text);
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.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;
}

@media (max-width: 380px) {
  .app-shell { padding-inline: 15px; }
  .choice-grid-three { grid-template-columns: 1fr; }
  .choice-grid-three .choice-card span { min-height: 44px; }
}

@media (max-width: 340px) {
  .screen-welcome h1 { font-size: 25px; }
}

@media (min-width: 461px) {
  body { padding-block: 22px; }
  .app-shell { min-height: calc(100dvh - 44px); border-radius: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .button { transition: none; }
}
