:root {
  --bg: #fbf4ea;
  --bg-deep: #f3e6d4;
  --paper: #fffdf8;
  --ink: #2c2416;
  --muted: #8a7d6c;
  --line: #eadccb;
  --tomato: #d4654a;
  --tomato-dark: #b8523a;
  --sage: #4f8a6b;
  --gold: #e0a84a;
  --cream: #fff1de;
  --shadow: 0 10px 30px rgba(80, 48, 24, 0.08);
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --tab-h: calc(64px + var(--safe-b));
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-padding-top: 88px;
  scroll-padding-bottom: var(--tab-h);
}

html, body {
  min-height: 100%;
  background:
    radial-gradient(1200px 500px at 10% -10%, #ffe7c8 0%, transparent 55%),
    radial-gradient(900px 420px at 100% 0%, #f7d7c8 0%, transparent 50%),
    var(--bg);
  color: var(--ink);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select {
  font-family: inherit;
  color: inherit;
}

button { cursor: pointer; }

#app {
  max-width: 920px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(var(--tab-h) + 28px);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + var(--safe-t)) 20px 10px;
  background: linear-gradient(180deg, rgba(251,244,234,0.96), rgba(251,244,234,0.86) 70%, transparent);
  backdrop-filter: blur(10px);
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.brand {
  font-family: "ZCOOL XiaoWei", serif;
  font-size: 30px;
  font-weight: 400;
  line-height: 1.15;
  margin-top: 2px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.pages { padding: 4px 16px 0; }

.page { display: none; }
.page.active { display: block; animation: fadeUp 0.28s ease; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.hero {
  background: linear-gradient(135deg, #fffaf3, #ffe8d4 55%, #f7d3c3);
  border: 1px solid #f0d8c2;
  border-radius: 24px;
  padding: 20px 20px 18px;
  box-shadow: var(--shadow);
}

.hero h2 {
  font-family: "ZCOOL XiaoWei", serif;
  font-size: 28px;
  margin-bottom: 6px;
}

.hero p { color: #6e6254; font-size: 14px; line-height: 1.6; }

.lucky-btn {
  margin-top: 16px;
  width: 100%;
  border: 0;
  background: var(--tomato);
  color: #fff;
  height: 50px;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 18px rgba(212, 101, 74, 0.28);
}

.lucky-btn:active { transform: scale(0.985); }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin: 22px 4px 10px;
}

.section-head h3 {
  font-size: 16px;
  flex: 0 0 auto;
}

.section-head span, .quiet { color: var(--muted); font-size: 13px; }

.section-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
}

.meal-row, .day-card, .dish-card, .stat-card, .panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.today-meals, .list-stack, .stats-grid, .dish-grid { display: grid; gap: 10px; }

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 14px;
}

.list-main {
  min-width: 0;
  flex: 1;
}

.list-main .meal-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-btn {
  flex: 0 0 auto;
  white-space: nowrap;
  min-height: 36px;
  padding: 8px 14px;
}

.meal-row {
  display: grid;
  grid-template-columns: 62px 1fr;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 14px;
}

.meal-label {
  font-size: 13px;
  color: var(--muted);
}

.meal-name {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.35;
}

.slot-dish .meal-name,
.meal-row .meal-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meal-name.empty { color: #b6a895; font-weight: 500; }

.chip, .ghost-btn, .primary-btn, .danger-btn {
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
}

.ghost-btn {
  background: var(--cream);
  color: var(--ink);
  border: 1px solid var(--line);
}

.primary-btn {
  background: var(--tomato);
  color: #fff;
  font-weight: 600;
}

.danger-btn {
  background: #f8e4de;
  color: #a03b2a;
}

.chip {
  background: #f4ece1;
  color: #6a5d4d;
}

.chip.on {
  background: #f8d7c8;
  color: var(--tomato-dark);
}

.stats-grid {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 8px;
}

.stat-card { padding: 14px 10px; text-align: center; }
.stat-card b { display: block; font-size: 22px; font-family: "ZCOOL XiaoWei", serif; }
.stat-card span { font-size: 12px; color: var(--muted); }

.list-row .date {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 2px;
}

.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.week-title { font-weight: 600; text-align: center; }

.plan-actions, .filters, .emoji-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.day-card { padding: 14px; }
.day-card + .day-card { margin-top: 10px; }

.day-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.day-head strong { font-size: 15px; }
.today-mark {
  font-size: 11px;
  background: #f8d7c8;
  color: var(--tomato-dark);
  border-radius: 999px;
  padding: 3px 8px;
}

.slot {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px dashed var(--line);
}

.slot-dish {
  min-height: 38px;
  border: 1px dashed #e4d4c2;
  background: #fffaf3;
  border-radius: 12px;
  padding: 8px 10px;
  text-align: left;
}

.slot-dish.has {
  border-style: solid;
  background: #fff;
}

.slot-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

@media (max-width: 560px) {
  .meal-row {
    grid-template-columns: 52px 1fr;
  }
}
.mini {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}

.search-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 12px;
}

.search-bar input, .field input, .field textarea, .field select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
}

.search-bar input:focus, .field input:focus, .field textarea:focus {
  border-color: #e2b39f;
  box-shadow: 0 0 0 4px rgba(212,101,74,0.08);
}

.dish-grid {
  grid-template-columns: 1fr;
}

.dish-card {
  padding: 14px;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: start;
}

.dish-emoji {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: var(--cream);
  display: grid;
  place-items: center;
  font-size: 26px;
}

.dish-card h4 { font-size: 16px; margin-bottom: 4px; }
.meta { font-size: 12px; color: var(--muted); line-height: 1.5; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag {
  font-size: 11px;
  background: #f3ebe0;
  border-radius: 999px;
  padding: 3px 8px;
  color: #74685a;
}

.card-actions { display: flex; flex-direction: column; gap: 6px; }

.want-banner {
  background: #fff6e8;
  border: 1px solid #f0ddb8;
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #7a6240;
}

.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(255,253,248,0.94);
  border-top: 1px solid var(--line);
  padding: 8px 8px calc(8px + var(--safe-b));
  backdrop-filter: blur(12px);
  z-index: 30;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  display: grid;
  gap: 2px;
  place-items: center;
  padding: 6px 0;
}

.tab.active { color: var(--tomato-dark); font-weight: 600; }
.tab-icon { font-size: 18px; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 36, 22, 0.42);
  z-index: 50;
  display: grid;
  place-items: end center;
  padding: 12px;
}

.overlay.hidden { display: none; }

.sheet {
  width: min(640px, 100%);
  max-height: min(92vh, 860px);
  overflow: auto;
  background: var(--paper);
  border-radius: 24px 24px 18px 18px;
  padding: 18px 16px 22px;
  animation: sheetIn 0.24s ease;
}

@keyframes sheetIn {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.sheet h3 {
  font-family: "ZCOOL XiaoWei", serif;
  font-size: 24px;
  margin-bottom: 6px;
}

.sheet-sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

.fields { display: grid; gap: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field textarea { min-height: 80px; resize: vertical; }

.sheet-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.sheet-actions > * { flex: 1; min-width: 110px; height: 44px; border-radius: 14px; }

.pick-list { display: grid; gap: 8px; max-height: 46vh; overflow: auto; }
.pick-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  text-align: left;
}

/* 外卖点单式选菜 */
.takeout-sheet {
  display: flex;
  flex-direction: column;
  height: min(92vh, 860px);
  max-height: min(92vh, 860px);
  padding: 0;
  overflow: hidden;
}

.takeout-head {
  flex: 0 0 auto;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fffaf3, #fffdf8);
}

.takeout-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.takeout-head h3 { margin-bottom: 2px; }
.takeout-head .sheet-sub { margin-bottom: 0; }

.takeout-close {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  font-size: 16px;
  box-shadow: none;
}

.takeout-tools {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
}

.takeout-search {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 14px;
  outline: none;
}

.takeout-search:focus {
  border-color: #e2b39f;
  box-shadow: 0 0 0 4px rgba(212,101,74,0.08);
}

.takeout-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 76px 1fr;
  background: #f7efe4;
}

.takeout-empty {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
}

.takeout-cats {
  overflow-y: auto;
  background: #f3e8da;
  border-right: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
}

.takeout-cat {
  width: 100%;
  border: 0;
  background: transparent;
  color: #7a6d5c;
  padding: 14px 8px;
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
  position: relative;
  display: grid;
  gap: 4px;
  place-items: center;
}

.takeout-cat span {
  font-size: 10px;
  color: #a89784;
}

.takeout-cat.on {
  background: var(--paper);
  color: var(--tomato-dark);
  font-weight: 600;
}

.takeout-cat.on::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--tomato);
}

.takeout-menu {
  overflow-y: auto;
  background: var(--paper);
  padding: 0 0 12px;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.takeout-section { scroll-margin-top: 8px; }

.takeout-sec-title {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0;
  padding: 10px 14px 8px;
  font-size: 13px;
  color: var(--muted);
  background: linear-gradient(180deg, #fffdf8 70%, rgba(255,253,248,0));
}

.takeout-item {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid #f3ebe0;
  cursor: pointer;
}

.takeout-item.selected {
  background: #fff6f1;
}

.takeout-thumb {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  background: linear-gradient(145deg, #ffe8d4, #f7d7c8);
  display: grid;
  place-items: center;
  font-size: 34px;
  box-shadow: inset 0 -6px 12px rgba(180, 90, 50, 0.06);
}

.takeout-info { min-width: 0; display: flex; flex-direction: column; }

.takeout-name {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 4px;
}

.takeout-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: var(--tomato-dark);
  background: #fde4da;
  border-radius: 999px;
  padding: 1px 6px;
  vertical-align: middle;
}

.takeout-price-row {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.takeout-mins {
  font-family: "ZCOOL XiaoWei", serif;
  font-size: 22px;
  color: var(--tomato-dark);
  line-height: 1;
}

.takeout-mins small {
  font-family: "Noto Sans SC", sans-serif;
  font-size: 11px;
  margin-left: 2px;
  color: var(--muted);
}

.takeout-plus {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 0;
  background: var(--tomato);
  color: #fff;
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 10px rgba(212, 101, 74, 0.28);
}

.takeout-plus:active { transform: scale(0.92); }

.takeout-plus.on {
  background: var(--sage);
  box-shadow: 0 4px 10px rgba(79, 138, 107, 0.28);
  font-size: 14px;
}

.takeout-plus:disabled {
  opacity: 1;
  cursor: default;
}

.takeout-stepper {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff4ee;
  border-radius: 999px;
  padding: 2px 4px 2px 2px;
}

.takeout-stepper span {
  min-width: 14px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.takeout-minus {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--tomato);
  background: #fff;
  color: var(--tomato);
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.takeout-footer {
  position: relative;
  flex: 0 0 auto;
  z-index: 5;
}

.takeout-cart-mask {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: min(70vh, 520px);
  border: 0;
  background: rgba(44, 36, 22, 0.28);
  z-index: 1;
}

.takeout-cart-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  z-index: 2;
  max-height: min(42vh, 360px);
  display: flex;
  flex-direction: column;
  background: #fffdf8;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -12px 28px rgba(44, 36, 22, 0.16);
  animation: cartPanelIn 0.2s ease;
  overflow: hidden;
  color: var(--ink);
}

@keyframes cartPanelIn {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.takeout-cart-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.takeout-cart-panel-head strong {
  font-size: 14px;
}

.takeout-clear-all {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 4px 2px;
}

.takeout-cart-panel-list {
  overflow-y: auto;
  padding: 4px 8px 10px;
  -webkit-overflow-scrolling: touch;
}

.takeout-cart-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 8px;
  border-bottom: 1px solid #f3ebe0;
}

.takeout-cart-row:last-child { border-bottom: 0; }

.takeout-cart-row-emoji {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--cream);
  display: grid;
  place-items: center;
  font-size: 22px;
}

.takeout-cart-row-info {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.takeout-cart-row-info b {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.takeout-cart-row-info span {
  font-size: 11px;
  color: var(--muted);
}

.takeout-bar {
  position: relative;
  z-index: 3;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px calc(12px + var(--safe-b));
  background: #2c2416;
  color: #fff;
  border-radius: 0 0 18px 18px;
}

.takeout-cart {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 0;
  cursor: pointer;
}

.takeout-cart.open .takeout-cart-icon {
  box-shadow: 0 0 0 2px rgba(212, 101, 74, 0.55);
}

.takeout-cart-caret {
  font-size: 11px;
  opacity: 0.75;
  margin-left: 2px;
}

.takeout-cart.empty-cart { opacity: 0.72; }

.takeout-cart-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255,255,255,0.1);
  display: grid;
  place-items: center;
  font-size: 22px;
  flex: 0 0 auto;
}

.takeout-cart-icon.has {
  background: #fff;
}

.takeout-cart-stack {
  font-size: 15px;
  letter-spacing: -2px;
  line-height: 1;
}

.takeout-cart-text {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.takeout-cart-text b {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.takeout-cart-text span {
  font-size: 11px;
  color: rgba(255,255,255,0.62);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.takeout-checkout {
  border: 0;
  background: var(--tomato);
  color: #fff;
  height: 44px;
  padding: 0 18px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

.takeout-checkout.disabled,
.takeout-checkout:disabled {
  background: #5a5043;
  color: rgba(255,255,255,0.45);
  cursor: not-allowed;
}

@media (min-width: 760px) {
  .takeout-sheet { border-radius: 24px; }
  .takeout-bar { border-radius: 0 0 24px 24px; }
  .takeout-body { grid-template-columns: 96px 1fr; }
  .takeout-cat { font-size: 13px; padding: 16px 10px; }
}

.lucky-stage {
  min-height: 180px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #fff6ea, #ffe3cf);
  border-radius: 20px;
  margin: 8px 0 16px;
  padding: 20px;
  text-align: center;
}

.lucky-emoji { font-size: 54px; }
.lucky-name {
  font-family: "ZCOOL XiaoWei", serif;
  font-size: 34px;
  margin-top: 8px;
}

.spinning .lucky-name { animation: flash 0.08s linear infinite; }
@keyframes flash {
  50% { opacity: 0.35; }
}

.emoji-row button {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 20px;
}

.emoji-row button.on { border-color: var(--tomato); background: #fde8e0; }

.empty {
  text-align: center;
  padding: 28px 10px;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + 12px);
  transform: translateX(-50%);
  background: #2c2416;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 80;
  animation: fadeUp 0.2s ease;
}

@media (min-width: 760px) {
  .dish-grid { grid-template-columns: 1fr 1fr; }
  .pages { padding-left: 22px; padding-right: 22px; }
  .overlay { place-items: center; }
  .sheet { border-radius: 24px; }
}
