:root {
  --bg: #faf6f0;
  --card: #ffffff;
  --text: #3d3226;
  --muted: #8a7d6d;
  --line: #ece4d8;
  --accent: #f28c28;
  --accent-dark: #d97706;
  --accent-soft: #fdeedd;
  --danger: #d64545;
  --danger-soft: #fdeaea;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(80, 60, 30, 0.08), 0 4px 16px rgba(80, 60, 30, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 680px; margin: 0 auto; padding: 20px 16px 72px; }

.hidden { display: none !important; }

h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--danger); font-size: 13px; margin: 10px 0 0; }

/* ---------- 卡片与行 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
}
.row-main { min-width: 0; }
.row-main .name { font-weight: 600; display: block; }
.row-actions { display: flex; gap: 6px; flex-shrink: 0; }

.group { margin-bottom: 18px; }
.group h3 { color: var(--muted); letter-spacing: 0.02em; }

.badge {
  display: inline-block;
  font-size: 11px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 1px 8px;
  margin-left: 6px;
  vertical-align: 2px;
}

/* ---------- 登录 ---------- */
.login-view {
  display: flex;
  justify-content: center;
  padding-top: 12vh;
}
.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
  padding: 28px 24px;
}
.login-card h1 { margin-bottom: 4px; }

/* ---------- 顶栏与标签 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.tabs {
  display: flex;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 16px;
}
.tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tab.active {
  background: var(--accent);
  color: #fff;
}

/* ---------- 日期条 ---------- */
.date-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 12px;
  scrollbar-width: thin;
}
.chip {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 58px;
  padding: 8px 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  position: relative;
}
.chip .chip-date { font-weight: 700; font-size: 13px; color: var(--text); }
.chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.chip.planned .chip-dot {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #35a86b;
  color: #fff;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- 表单 ---------- */
label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 10px; }

input, select {
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

select.wide { margin-top: 4px; }

.grid-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: end;
}
.grid-form > *:first-child, .grid-form > *:nth-child(2) { grid-column: span 1; }
.grid-form .btn { grid-column: 1 / -1; }

.row-form { display: flex; gap: 10px; }
.row-form input { flex: 1; }

.plan-actions { display: flex; gap: 10px; margin: 4px 0 16px; }

.yesterday {
  background: var(--accent-soft);
  border: 1px dashed var(--accent);
  color: #9a6a2a;
  border-radius: 10px;
  font-size: 13px;
  padding: 8px 12px;
  margin-bottom: 14px;
}

/* ---------- 按钮 ---------- */
.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 16px;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s;
}
.btn:hover { filter: brightness(0.96); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: #fff; color: var(--text); border-color: var(--line); }
.btn.danger { background: var(--danger-soft); color: var(--danger); border-color: #f3c8c8; }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.block { display: block; width: 100%; margin-top: 6px; }

/* ---------- 排敏状态 ---------- */
.allergen-bar {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.allergen-bucket {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  font-size: 12.5px;
  color: var(--muted);
  transition: border-color 0.15s, background 0.15s;
}
.allergen-bucket .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.dot.none { background: #c9bfb2; }
.dot.testing { background: #f2a51b; }
.dot.passed { background: #35a86b; }
.allergen-bucket .count {
  font-size: 12px;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 0 8px;
  min-width: 20px;
  text-align: center;
}
.allergen-bucket.drag-over {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-soft);
}

.badge.allergen { cursor: pointer; margin-left: 6px; user-select: none; }
.badge.allergen.none { background: #efe9e0; color: #8a7d6d; }
.badge.allergen.testing { background: #fdf0d5; color: #b0710a; }
.badge.allergen.passed { background: #e2f4ea; color: #1f7a4d; }

.food-card { cursor: grab; }
.food-card:active { cursor: grabbing; }
.food-card.dragging { opacity: 0.5; }

.group-head {
  border-radius: 8px;
  padding: 4px 6px;
  transition: background 0.15s;
}
.group-head.drag-over {
  background: var(--accent-soft);
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #2f2a24;
  color: #fff;
  font-size: 14px;
  border-radius: 999px;
  padding: 10px 20px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  z-index: 50;
  max-width: 90vw;
  text-align: center;
}
.toast.error { background: var(--danger); }

@media (max-width: 480px) {
  .grid-form { grid-template-columns: 1fr; }
}
