:root {
  --bg: #FBF6EF;
  --card: #FFFFFF;
  --primary: #E86A33;
  --primary-soft: #FDEBDD;
  --ink: #2E2A26;
  --muted: #8A7F73;
  --line: #EFE6DA;
  --green: #4E8A5A;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
  font-size: 15px;
  line-height: 1.5;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 14px 96px;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(var(--bg) 80%, rgba(251, 246, 239, 0));
  padding: 14px 2px 10px;
}

header h1 {
  margin: 0;
  font-size: 22px;
}

header p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 2px 10px rgba(60, 40, 20, 0.06);
  margin-bottom: 12px;
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.card-title .sub {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

.card-title .actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dish-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px dashed var(--line);
}

.dish-row:last-child { border-bottom: none; }

.dish-name {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  cursor: pointer;
}

.dish-name .meta {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

.pill {
  flex: none;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: #A65E2E;
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn.ghost {
  background: transparent;
  border: none;
  color: var(--primary);
  padding: 6px 8px;
}

.btn.ghost.danger {
  color: #B34A3A;
  padding-left: 4px;
  padding-right: 4px;
}

.btn.small {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 8px;
}

.btn:disabled {
  opacity: 0.5;
}

.row-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.section-title {
  font-size: 13px;
  color: var(--muted);
  margin: 18px 4px 8px;
}

.chip {
  display: inline-block;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13px;
  margin: 0 8px 8px 0;
  cursor: pointer;
  color: var(--ink);
}

.chip.on {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.searchbar input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-size: 15px;
  background: #fff;
  color: var(--ink);
}

.filter-row {
  margin: 10px 0 4px;
}

.recipe-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.recipe-item:last-child { border-bottom: none; }

.recipe-item .info { flex: 1; min-width: 0; }

.recipe-item .name { font-size: 15px; font-weight: 500; }

.recipe-item .meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.fav-mark { color: var(--primary); font-size: 13px; flex: none; }

.day-card .day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.day-card .day-head .d-title { font-size: 16px; font-weight: 600; }

.day-card .day-head .d-date { font-size: 12px; color: var(--muted); margin-left: 8px; }

.sumrow {
  display: flex;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  padding: 5px 0;
}

.sumrow .meal-label {
  flex: none;
  color: var(--ink);
  font-weight: 500;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px dashed var(--line);
}

.settings-row:last-child { border-bottom: none; }

.stepper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stepper button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 18px;
  color: var(--primary);
  cursor: pointer;
}

.stepper .num { font-size: 17px; font-weight: 600; min-width: 20px; text-align: center; }

.inline-input {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.inline-input input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}

.shop-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}

.shop-item:last-child { border-bottom: none; }

.shop-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  flex: none;
}

.shop-item .shop-name { flex: 1; font-size: 15px; min-width: 0; }

.shop-item.done .shop-name { text-decoration: line-through; color: var(--muted); }

.shop-item .qty { font-size: 13px; color: var(--muted); flex: none; }

.mini-btn {
  flex: none;
  border: none;
  background: none;
  color: var(--primary);
  font-size: 11px;
  padding: 3px 4px;
  cursor: pointer;
}

.shop-cat { font-size: 13px; color: var(--muted); margin: 16px 4px 6px; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  font-size: 14px;
}

#tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  background: #fff;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

#tabbar .inner {
  display: flex;
  width: 100%;
  max-width: 560px;
}

#tabbar button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 7px;
  border: none;
  background: none;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
}

#tabbar button.on { color: var(--primary); }

#tabbar svg { width: 22px; height: 22px; }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-mask {
  position: absolute;
  inset: 0;
  background: rgba(30, 20, 10, 0.42);
}

.sheet-body {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 84vh;
  overflow: auto;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(22px + env(safe-area-inset-bottom));
  animation: rise 0.18s ease-out;
}

@keyframes rise {
  from { transform: translateY(30px); opacity: 0.5; }
  to { transform: translateY(0); opacity: 1; }
}

.hidden { display: none !important; }

.sheet-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 4px;
}

.sheet-sub {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 12px;
}

.ing-list {
  list-style: none;
  padding: 0;
  margin: 0 0 6px;
}

.ing-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
}

.ing-list li:last-child { border-bottom: none; }

.ing-list .ing-qty { color: var(--muted); flex: none; }

.steps {
  margin: 0;
  padding-left: 20px;
}

.steps li {
  padding: 6px 0;
  font-size: 14px;
}

.newbie-tip {
  margin-top: 12px;
  padding: 11px 12px;
  border-radius: 10px;
  background: #FBF3E8;
  color: #6B4B2E;
  font-size: 12px;
  line-height: 1.7;
}

.newbie-tip strong {
  display: block;
  margin-bottom: 3px;
  color: var(--ink);
  font-size: 13px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  background: rgba(40, 30, 20, 0.85);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
  z-index: 60;
  max-width: 80vw;
}

.toast.show { opacity: 1; }

.cand-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--line);
  cursor: pointer;
}

.cand-item:last-child { border-bottom: none; }

.cand-item .c-name { font-size: 15px; }

.cand-item .c-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.cand-item .used-tag { font-size: 11px; color: var(--muted); flex: none; }

.cand-item .warn-tag { font-size: 11px; color: #A65E2E; flex: none; max-width: 45%; text-align: right; }

.share-img {
  display: block;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.share-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

.invite-code {
  margin: 10px 0;
  padding: 12px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: #A65E2E;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
  text-align: center;
}

.invite-text {
  margin-bottom: 12px;
  padding: 10px;
  border-radius: 10px;
  background: #FAF7F3;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  word-break: break-all;
}

.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px dashed var(--line);
  cursor: pointer;
}

.member-row:last-child { border-bottom: none; }

.member-main { flex: 1; min-width: 0; }

.member-name { font-size: 15px; font-weight: 500; }

.member-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.member-empty { font-size: 13px; color: var(--muted); line-height: 1.6; }

.sync-help { font-size: 12px; color: var(--muted); line-height: 1.6; }

#syncStatus.error { color: #B34A3A; }

.settings-row > .num { font-size: 16px; font-weight: 600; }

.fit-line {
  font-size: 12px;
  color: var(--green);
  background: #F1F6F2;
  border-radius: 10px;
  padding: 8px 10px;
  margin: 0 0 10px;
}

.fit-line.warn {
  color: #A65E2E;
  background: var(--primary-soft);
}

.form-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  margin: 16px 4px 8px;
}

.form-label span { font-size: 11px; }

.form-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-size: 15px;
  background: #fff;
  color: var(--ink);
}

.stat-line {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.shop-range {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shop-range-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.shop-range .filter-row {
  margin: 0;
}

.shop-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.5;
}

.my-recipe-help {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  margin: 2px 0 8px;
}

.my-recipe-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}

.my-recipe-row + .my-recipe-row {
  border-top: 1px dashed var(--line);
}

.my-recipe-row .btn {
  flex: none;
}

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

.form-row > div {
  flex: 1;
  min-width: 0;
}

.import-box {
  margin-bottom: 16px;
  padding: 12px;
  border: 1px dashed #E8C9AF;
  border-radius: 12px;
  background: #FFF9F2;
}

.import-box .card-title {
  margin-bottom: 8px;
}

.import-text {
  min-height: 88px;
  font-size: 14px;
  background: #fff;
}

.import-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.import-actions .sync-help {
  flex: 1;
  min-width: 180px;
}

.custom-ing-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(52px, 0.8fr) minmax(50px, 0.7fr) 34px;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.custom-ing-row .form-input {
  padding: 9px 8px;
  font-size: 13px;
  border-radius: 9px;
  min-width: 0;
}

.custom-ing-row .btn {
  width: 34px;
  height: 34px;
  padding: 0;
}

textarea.form-input {
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 4px 4px;
  font-size: 14px;
  color: var(--ink);
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex: none;
}
