:root {
  color-scheme: light;
  --ink: #20231f;
  --muted: #74776f;
  --line: #e8e8df;
  --paper: #fffdf8;
  --cream: #fff8e9;
  --green: #356859;
  --green-dark: #285145;
  --lime: #dff36d;
  --orange: #ff8f52;
  --shadow: 0 14px 42px rgba(45, 54, 38, 0.09);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html { background: #f4f2eb; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 3%, rgba(223, 243, 109, 0.22), transparent 24rem),
    var(--paper);
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; }
button { color: inherit; }

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 20px calc(118px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 750;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 12px 12px 12px 5px;
  color: white;
  background: var(--green);
  font-size: 16px;
  box-shadow: 0 6px 16px rgba(53, 104, 89, 0.2);
}

.icon-button, .close-button {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.72);
}

.icon-button svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin: 27px 2px 18px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(30px, 8vw, 40px); line-height: 1.05; letter-spacing: -0.04em; }
h2 { margin-bottom: 0; font-size: 17px; }

.balance-badge {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border-radius: 999px;
  color: var(--green-dark);
  background: #edf4e8;
  font-size: 11px;
  font-weight: 700;
}

.balance-dot { width: 7px; height: 7px; border-radius: 50%; background: #69a177; box-shadow: 0 0 0 4px rgba(105, 161, 119, 0.13); }

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

.meal-card {
  position: relative;
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  min-height: 98px;
  padding: 15px 13px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 5px 22px rgba(39, 46, 35, 0.045);
  animation: cardIn 300ms ease both;
}

@keyframes cardIn { from { opacity: 0; transform: translateY(5px) scale(0.99); } }

.meal-card:nth-child(2) { animation-delay: 45ms; }
.meal-card:nth-child(3) { animation-delay: 90ms; }

.food-icon {
  display: grid;
  width: 62px;
  height: 62px;
  place-items: center;
  border-radius: 20px;
  background: var(--cream);
  font-size: 31px;
}

.meal-card[data-slot="vegetable"] .food-icon { background: #edf5df; }
.meal-card[data-slot="soup"] .food-icon { background: #e9f4f3; }
.meal-card[data-slot="main"] .food-icon { background: #f8eadf; }

.role-label { margin: 0 0 5px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; }
.dish-name { margin: 0; overflow: hidden; font-size: 20px; font-weight: 760; line-height: 1.25; text-overflow: ellipsis; }
.dish-meta { margin: 5px 0 0; color: var(--muted); font-size: 12px; }

.card-actions { display: grid; justify-items: center; gap: 7px; }

.swap-one {
  display: grid;
  width: 43px;
  height: 43px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 15px;
  color: var(--green-dark);
  background: #eef2e9;
}

.swap-one svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.reject-one { padding: 2px; border: 0; color: #999b93; background: none; font-size: 10px; }

.confirm-meal-button {
  display: flex;
  width: 100%;
  min-height: 68px;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 11px 15px;
  border: 0;
  border-radius: 20px;
  color: white;
  background: var(--green);
  text-align: left;
  box-shadow: 0 10px 26px rgba(53, 104, 89, 0.2);
}

.confirm-meal-button:active { background: var(--green-dark); transform: scale(.995); }
.confirm-meal-button.is-confirmed { color: var(--green-dark); background: #e8f0e6; box-shadow: none; }
.confirm-check { display: grid; flex: 0 0 auto; width: 39px; height: 39px; place-items: center; border-radius: 50%; color: var(--green-dark); background: var(--lime); font-size: 20px; font-weight: 900; }
.confirm-meal-button span:last-child { display: grid; gap: 3px; }
.confirm-meal-button strong { font-size: 15px; }
.confirm-meal-button small { color: rgba(255,255,255,.72); font-size: 11px; font-weight: 500; }
.confirm-meal-button.is-confirmed small { color: var(--muted); }

.view-menu-button {
  display: grid;
  width: 100%;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 9px;
  margin-top: 10px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255,255,255,.72);
  text-align: left;
  font-size: 13px;
  font-weight: 720;
}

.view-menu-button > span:last-child { color: var(--muted); font-size: 22px; font-weight: 400; }
.menu-count { padding: 4px 8px; border-radius: 999px; color: var(--green-dark); background: #edf4e8; font-size: 10px; }

.reject-meal-button {
  display: flex;
  width: 100%;
  min-height: 54px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  margin-top: 10px;
  padding: 10px 15px;
  border: 1px solid #eedfd9;
  border-radius: 17px;
  color: #85594d;
  background: #fbf3ef;
  text-align: left;
  font-size: 12px;
  font-weight: 720;
}

.reject-meal-button small { color: #9b827a; font-size: 10px; font-weight: 500; }

.portion-card, .why-card {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-top: 14px;
  padding: 15px;
  border-radius: 20px;
  background: var(--cream);
}

.portion-icon {
  display: grid;
  flex: 0 0 auto;
  width: 43px;
  height: 43px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--orange);
  font-size: 19px;
  font-weight: 800;
  box-shadow: 0 5px 15px rgba(255, 143, 82, 0.22);
}

.portion-card h2 { margin-bottom: 4px; font-size: 14px; }
.portion-card p { margin-bottom: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.why-card { display: block; margin-top: 10px; background: #f1f4ee; }
.why-card p:not(.eyebrow) { margin-bottom: 12px; color: #5e625b; font-size: 13px; line-height: 1.55; }
.macro-row { display: flex; gap: 7px; }
.macro-row span { padding: 6px 9px; border: 1px solid #dce2d8; border-radius: 999px; color: var(--green-dark); background: rgba(255,255,255,.55); font-size: 10px; font-weight: 700; }

.recent-section { margin: 30px 2px 0; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.text-button { border: 0; color: var(--muted); background: none; font-size: 12px; }
.recent-list { display: grid; gap: 8px; }
.recent-item { padding: 12px 14px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.62); }
.recent-item p { margin: 0; font-size: 13px; line-height: 1.5; }
.recent-item small { display: block; margin-top: 3px; color: var(--muted); }

.action-dock {
  position: fixed;
  z-index: 10;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: 104px minmax(0, 360px);
  justify-content: center;
  gap: 10px;
  padding: 13px 20px calc(13px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(227, 227, 218, 0.8);
  background: rgba(255, 253, 248, 0.9);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.primary-button, .secondary-button, .save-button, .reset-button {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 18px;
  font-weight: 760;
}

.primary-button { border: 0; color: white; background: var(--green); box-shadow: 0 10px 26px rgba(53, 104, 89, 0.24); }
.primary-button:active { background: var(--green-dark); transform: scale(.99); }
.primary-button svg, .secondary-button svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.secondary-button { border: 1px solid var(--line); background: white; }
.secondary-button:disabled { opacity: .38; }

.settings-sheet, .menu-sheet {
  width: min(100%, 520px);
  max-height: 90dvh;
  margin: auto auto 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 28px 28px 0 0;
  color: var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.settings-sheet::backdrop, .menu-sheet::backdrop { background: rgba(23, 28, 24, .46); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.settings-sheet[open], .menu-sheet[open] { animation: sheetUp 230ms ease-out; }
@keyframes sheetUp { from { transform: translateY(30px); opacity: .7; } }

.sheet-content { max-height: 90dvh; padding: 9px 20px calc(26px + env(safe-area-inset-bottom)); overflow-y: auto; }
.sheet-handle { width: 42px; height: 5px; margin: 0 auto 18px; border-radius: 5px; background: #deded7; }
.sheet-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 25px; }
.sheet-header h2 { font-size: 27px; letter-spacing: -.03em; }
.close-button { border: 0; background: #f0f0ea; font-size: 27px; font-weight: 300; }

fieldset { margin: 0 0 24px; padding: 0; border: 0; }
legend { margin-bottom: 11px; font-size: 14px; font-weight: 760; }
input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.segmented-control { display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px; border-radius: 15px; background: #efefe9; }
.segmented-control span { display: block; padding: 10px 5px; border-radius: 12px; text-align: center; color: var(--muted); font-size: 12px; }
.segmented-control input:checked + span { color: var(--ink); background: white; box-shadow: 0 2px 9px rgba(40, 45, 38, .08); font-weight: 700; }

.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-grid span { display: block; padding: 9px 13px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 12px; }
.chip-grid input:checked + span { border-color: var(--green); color: white; background: var(--green); }

.toggle-list { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: white; }
.toggle-list label { display: flex; min-height: 49px; align-items: center; justify-content: space-between; padding: 0 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.toggle-list label:last-child { border-bottom: 0; }
input[type="checkbox"] { width: 43px; height: 25px; appearance: none; border-radius: 99px; background: #d9dad5; transition: 180ms; }
input[type="checkbox"]::after { display: block; width: 21px; height: 21px; margin: 2px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.22); content: ""; transition: 180ms; }
input[type="checkbox"]:checked { background: var(--green); }
input[type="checkbox"]:checked::after { transform: translateX(18px); }

.light-toggle { display: flex; align-items: center; justify-content: space-between; margin-bottom: 19px; padding: 15px; border-radius: 18px; background: #edf4e8; }
.light-toggle strong, .light-toggle small { display: block; }
.light-toggle strong { font-size: 14px; }
.light-toggle small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.hidden-summary { color: var(--muted); font-size: 11px; }
.save-button, .reset-button { width: 100%; border: 0; }
.save-button { margin-top: 10px; color: white; background: var(--green); }
.reset-button { min-height: 42px; color: #8a5b51; background: #f7eeea; font-size: 12px; }

.menu-sheet-content { padding-bottom: calc(30px + env(safe-area-inset-bottom)); }
.all-menu-list { display: grid; gap: 27px; }
.all-menu-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 10px; }
.all-menu-heading h3 { margin: 0 0 3px; font-size: 18px; }
.all-menu-heading p { margin: 0; color: var(--muted); font-size: 11px; }
.all-menu-heading > span { color: var(--muted); font-size: 11px; }
.all-menu-grid { display: grid; gap: 7px; }
.all-menu-item { display: grid; grid-template-columns: 38px minmax(0,1fr) auto; align-items: center; gap: 10px; min-height: 58px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.all-menu-icon { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 12px; background: var(--cream); font-size: 20px; }
.all-menu-item strong, .all-menu-item small { display: block; }
.all-menu-item strong { font-size: 13px; }
.all-menu-item small { margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.all-menu-item em { color: #9b6a5d; font-size: 9px; font-style: normal; }
.all-menu-item.is-hidden { opacity: .55; background: #f6f4ef; }

.toast {
  position: fixed;
  z-index: 40;
  bottom: calc(94px + env(safe-area-inset-bottom));
  left: 50%;
  max-width: calc(100% - 40px);
  padding: 10px 15px;
  border-radius: 999px;
  color: white;
  background: rgba(32, 35, 31, .92);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: 200ms;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

button:focus-visible, input:focus-visible { outline: 3px solid rgba(53, 104, 89, .25); outline-offset: 2px; }

@media (min-width: 620px) {
  body { padding: 26px 0; }
  .app-shell { min-height: calc(100dvh - 52px); border-radius: 34px; background: rgba(255,253,248,.88); box-shadow: var(--shadow); }
  .action-dock { right: auto; bottom: 26px; left: 50%; width: 520px; border: 1px solid var(--line); border-radius: 0 0 34px 34px; transform: translateX(-50%); }
  .settings-sheet, .menu-sheet { border-radius: 28px; margin-bottom: 30px; }
}

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