:root {
  --bg: #f7efe7;
  --paper: #fffaf5;
  --ink: #3d2c29;
  --muted: #8a726b;
  --line: rgba(61, 44, 41, 0.08);
  --accent: #c96b4a;
  --accent-soft: #f4d7cb;
  --sage: #6f9e86;
  --shadow: 0 10px 30px rgba(80, 48, 36, 0.08);
  --radius: 20px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
}

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at top right, #f8d9c8 0, transparent 28%),
    linear-gradient(180deg, #fbeee4 0%, var(--bg) 40%);
  color: var(--ink);
}

button,
input,
textarea,
label {
  font: inherit;
}

button,
.file-btn {
  cursor: pointer;
}

button:disabled {
  opacity: 0.35;
  cursor: default;
}

.app {
  width: min(480px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 18px 16px calc(120px + var(--safe-bottom));
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 4px;
}

h1 {
  font-size: 28px;
  letter-spacing: 0.04em;
}

.date-picker {
  border: 0;
  background: var(--paper);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
}

.page {
  display: none;
}

.page.is-active {
  display: block;
}

.meal-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.meal-tab {
  border: 0;
  background: rgba(255, 250, 245, 0.7);
  color: var(--muted);
  border-radius: 16px;
  padding: 10px 0;
  box-shadow: inset 0 0 0 1px var(--line);
}

.meal-tab.is-active {
  background: var(--ink);
  color: #fff;
  box-shadow: none;
}

.dish-list {
  display: grid;
  gap: 10px;
}

.dish-card {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--paper);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}

.dish-emoji {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: #f4ebe3;
  font-size: 24px;
}

.dish-name {
  font-size: 16px;
  font-weight: 700;
}

.dish-desc {
  color: var(--muted);
  font-size: 12px;
  margin: 3px 0 8px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-size: 11px;
  color: var(--sage);
  background: rgba(111, 158, 134, 0.12);
  border-radius: 999px;
  padding: 2px 8px;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stepper button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

.qty {
  min-width: 16px;
  text-align: center;
  font-weight: 700;
}

.today-card,
.history-item,
.note-box {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.today-card h2,
.history-item h3 {
  font-size: 18px;
}

.meal-block {
  margin-top: 14px;
}

.meal-block h3,
.meal-block .label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.pick-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.empty {
  color: var(--muted);
  font-size: 14px;
  padding: 18px 0 8px;
}

.order-hint {
  color: var(--muted);
  font-size: 13px;
  padding: 0 4px 2px;
}

.note-readonly {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
}

.note-box {
  width: 100%;
  min-height: 88px;
  border: 0;
  resize: vertical;
  margin-top: 12px;
  outline: none;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 22px 4px 12px;
}

.head-actions,
.history-actions {
  display: flex;
  gap: 8px;
}

.text-btn,
.file-btn {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 14px;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  text-align: left;
  width: 100%;
  border: 0;
}

.history-item.is-current {
  box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow);
}

.history-meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(480px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(255, 250, 245, 0.92);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding: 8px 12px calc(8px + var(--safe-bottom));
}

.tab-btn {
  position: relative;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 0 8px;
}

.tab-btn.is-active {
  color: var(--ink);
  font-weight: 700;
}

.badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 38px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 13px;
  z-index: 20;
}

.clear-btn {
  margin-top: 12px;
  width: 100%;
  border: 0;
  background: #f4ebe3;
  color: var(--muted);
  border-radius: 14px;
  padding: 10px;
}

.add-dish-btn {
  width: 100%;
  border: 1px dashed rgba(201, 107, 74, 0.45);
  background: rgba(255, 250, 245, 0.7);
  color: var(--accent);
  border-radius: var(--radius);
  padding: 14px;
  font-weight: 700;
}

.stepper-col {
  display: grid;
  justify-items: center;
  gap: 4px;
}

.dish-delete {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(61, 44, 41, 0.28);
}

.sheet-panel {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(480px, 100%);
  transform: translateX(-50%);
  background: var(--paper);
  border-radius: 24px 24px 0 0;
  padding: 20px 16px calc(20px + var(--safe-bottom));
  box-shadow: var(--shadow);
}

.sheet-panel h2 {
  font-size: 20px;
  margin-bottom: 14px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field span {
  font-size: 13px;
  color: var(--muted);
}

.field input {
  border: 0;
  background: #f4ebe3;
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
}

.meal-checks,
.emoji-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meal-checks label {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f4ebe3;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
}

.emoji-pick {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: #f4ebe3;
  font-size: 20px;
}

.emoji-pick.is-active {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.primary-btn,
.ghost-btn {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 12px;
}

.primary-btn {
  background: var(--ink);
  color: #fff;
  font-weight: 700;
}

.ghost-btn {
  margin-top: 8px;
  background: transparent;
  color: var(--muted);
}
