:root {
  --cream: #FAF6EC;
  --card: #FFFFFF;
  --ink: #26332F;
  --soft: #74807B;
  --line: #ECE5D5;
  --mint: #2FA98C;
  --mint-deep: #1F8870;
  --mint-wash: #E3F4EE;
  --amber: #A9690A;
  --amber-wash: #FCEFD2;
  --coral: #C9472F;
  --coral-wash: #FBE2DB;
  --paper: #FFF3B5;
  --bar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font: 16px/1.5 var(--font);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 3px solid var(--mint); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
.sprite { position: absolute; width: 0; height: 0; }
.icon { width: 32px; height: 32px; flex: none; overflow: visible; }
.icon.tiny { width: 22px; height: 22px; }
.icon.large { width: 38px; height: 38px; }
.icon.huge { width: 76px; height: 76px; }
.hint { color: var(--soft); font-size: 14px; }

#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; padding: 0 16px calc(var(--bar-h) + var(--safe-b) + 28px); }

.mascot.small { width: 34px; height: 42px; flex: none; }
.mascot.big { width: 84px; height: 105px; animation: bob 3.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-5px); } }

/* 顶部 */
.top { display: flex; align-items: center; gap: 12px; padding: calc(env(safe-area-inset-top, 0px) + 18px) 2px 14px; }
.top > div { flex: 1; min-width: 0; }
.top h1 { font-size: 21px; line-height: 1.25; letter-spacing: .02em; }
.top p { color: var(--soft); font-size: 14px; }
.top time { color: var(--soft); font-size: 13px; line-height: 1.35; text-align: right; }

/* 便签 */
.notes { display: grid; gap: 14px; margin: 6px 4px 22px; }
.note {
  position: relative;
  background: var(--paper);
  padding: 22px 16px 10px;
  border-radius: 3px 3px 14px 3px;
  box-shadow: 0 1px 0 rgba(38, 51, 47, .06), 0 8px 18px -10px rgba(38, 51, 47, .35);
  transform: rotate(-1.1deg);
  animation: stick .35s cubic-bezier(.3, 1.4, .5, 1);
}
.note:nth-child(even) { transform: rotate(.9deg); }
.note p { white-space: pre-wrap; overflow-wrap: anywhere; }
.note footer { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 13px; color: #8A7A3C; }
.note footer button { padding: 8px 2px; text-decoration: underline; text-underline-offset: 3px; }
.magnet {
  position: absolute; top: -9px; left: 50%; width: 22px; height: 22px; margin-left: -11px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFB9A8, #E0664F 60%);
  box-shadow: 0 3px 4px rgba(38, 51, 47, .28);
}
.note:nth-child(2) .magnet { background: radial-gradient(circle at 35% 30%, #A6E6D4, var(--mint) 60%); }
.note:nth-child(3) .magnet { background: radial-gradient(circle at 35% 30%, #BBD3FF, #5B86D6 60%); }
@keyframes stick { from { opacity: 0; transform: translateY(-10px) rotate(-5deg); } }

/* 食材 */
.group { margin-bottom: 20px; }
.group h2 { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--soft); margin: 0 4px 8px; }
.group h2 span { font-size: 12px; font-weight: 500; background: var(--line); border-radius: 99px; padding: 0 8px; }
.group.urgent h2 { color: var(--coral); }
.group.urgent h2 span { background: var(--coral-wash); }
.items { background: var(--card); border-radius: 18px; box-shadow: 0 1px 0 var(--line); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 14px; text-align: left; }
.item + .item { border-top: 1px solid var(--line); }
.item:active { background: var(--cream); }
.item .name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.left { flex: none; font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 99px; }
.left.fine { color: var(--mint-deep); background: var(--mint-wash); }
.left.soon { color: var(--amber); background: var(--amber-wash); }
.left.late { color: var(--coral); background: var(--coral-wash); }

.empty { display: grid; justify-items: center; gap: 4px; padding: 56px 0 30px; text-align: center; }
.empty .mascot, .empty .icon { margin-bottom: 12px; }

.link { color: var(--soft); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; padding: 12px 4px; }
.link.lock { display: block; margin: 26px auto 0; }

/* 清单 */
.tip { margin: 2px 4px 12px; }
.wants { background: var(--card); border-radius: 18px; box-shadow: 0 1px 0 var(--line); overflow: hidden; }
.wants:empty { display: none; }
.want { display: flex; align-items: flex-start; gap: 6px; padding: 6px 6px 6px 8px; }
.want + .want { border-top: 1px solid var(--line); }
.tick { flex: none; width: 44px; height: 44px; display: grid; place-items: center; }
.tick::before { content: ""; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--mint); transition: background .15s; }
.tick:active::before { background: var(--mint); }
.want-main { flex: 1; min-width: 0; padding: 10px 0; }
.want-main .name { display: inline-flex; align-items: center; gap: 8px; vertical-align: middle; overflow-wrap: anywhere; }
.want-main p { color: var(--soft); font-size: 14px; overflow-wrap: anywhere; }
.badge { margin-left: 8px; font-size: 12px; font-weight: 600; color: var(--coral); background: var(--coral-wash); border-radius: 99px; padding: 2px 8px; white-space: nowrap; }
.x { flex: none; width: 44px; height: 44px; font-size: 22px; color: #B5B0A2; }

/* 底栏 */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: calc(var(--bar-h) + var(--safe-b)); padding: 0 12px var(--safe-b);
  background: rgba(250, 246, 236, .94); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.tab { position: relative; justify-self: center; min-width: 88px; height: 44px; font-size: 15px; color: var(--soft); }
.tab.on { color: var(--ink); font-weight: 700; }
.tab.on::after { content: ""; position: absolute; left: 50%; bottom: 2px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: var(--mint); }
.dot { margin-left: 5px; font-size: 12px; font-weight: 600; color: #fff; background: #E0664F; border-radius: 99px; padding: 1px 7px; }
.add {
  display: flex; align-items: center; gap: 6px; height: 50px; padding: 0 22px; margin-top: -22px;
  color: #fff; font-weight: 700; background: var(--mint-deep); border-radius: 99px;
  box-shadow: 0 8px 18px -8px rgba(31, 136, 112, .9); transition: transform .12s;
}
.add b { font-size: 20px; line-height: 1; }
.add:active { transform: scale(.95); }

/* 弹层 */
.overlay { position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: center; background: rgba(38, 51, 47, .38); animation: fade .18s; }
.sheet {
  width: 100%; max-width: 520px; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--cream); border-radius: 24px 24px 0 0; padding: 8px 18px calc(var(--safe-b) + 20px);
  animation: rise .22s cubic-bezier(.2, .9, .3, 1);
}
.sheet.tall { height: 88dvh; display: flex; flex-direction: column; }
.sheet.tall > .picker { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.overlay.leaving { opacity: 0; transition: opacity .18s; }
.overlay.leaving .sheet { transform: translateY(40px); transition: transform .18s; }
.grip { width: 40px; height: 4px; border-radius: 4px; background: #D9D2C0; margin: 0 auto 14px; }
.sheet h2 { font-size: 19px; display: flex; align-items: center; gap: 8px; }
.sheet h2 + .hint { margin-top: 2px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(60px); opacity: .4; } }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tags span { font-size: 13px; color: var(--soft); border: 1px solid #DCD5C3; border-radius: 99px; padding: 1px 10px; }

.btn { display: block; width: 100%; min-height: 48px; padding: 10px 16px; margin-top: 10px; border-radius: 14px; background: var(--card); box-shadow: 0 1px 0 var(--line); font-weight: 600; text-align: center; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--mint-deep); color: #fff; box-shadow: none; }
.btn.small { width: auto; min-height: 40px; margin: 0; padding: 6px 18px; border-radius: 99px; }
.btn.new { color: var(--mint-deep); border: 1.5px dashed var(--mint); background: transparent; box-shadow: none; overflow-wrap: anywhere; }
.sheet h2 ~ .btn.primary { margin-top: 18px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; font-size: 14px; color: var(--soft); }
.field input { min-height: 40px; padding: 4px 10px; border: 1px solid #DCD5C3; border-radius: 10px; background: var(--card); color: var(--ink); }
.sheet .link { display: block; margin: 6px auto 0; }

/* 挑食材 */
.picker-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.search, .login input { width: 100%; min-height: 48px; margin-top: 14px; padding: 10px 16px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--card); outline: none; }
.search:focus, .login input:focus { border-color: var(--mint); }
.picker-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: 12px -4px 0; padding: 0 4px 12px; }
.picker-body h3 { display: flex; align-items: center; justify-content: space-between; min-height: 32px; font-size: 14px; color: var(--soft); font-weight: 600; margin: 12px 2px 8px; }
.picker-body h3 .link { margin: 0; padding: 6px 4px; font-weight: 400; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.tile { position: relative; display: grid; justify-items: center; align-content: start; gap: 1px; min-height: 96px; padding: 10px 4px 8px; border-radius: 16px; background: var(--card); box-shadow: 0 1px 0 var(--line); border: 1.5px solid transparent; }
.tile .icon { margin-bottom: 4px; }
.tile .name { font-size: 15px; overflow-wrap: anywhere; text-align: center; }
.tile .sub { font-size: 12px; color: var(--soft); }
.tile:active { transform: scale(.95); }
.tile.picked { border-color: var(--mint); background: var(--mint-wash); }
.tile.wrong { border-style: dashed; border-color: #E3B3A6; }
.tile.wrong .count { background: #C96B55; animation: none; }
.count { position: absolute; top: -6px; right: -4px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 99px; background: var(--mint-deep); color: #fff; font-size: 13px; font-weight: 700; line-height: 24px; animation: pop .25s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { from { transform: scale(0); } }

.chips { display: flex; gap: 8px; }
.chips.wrap { flex-wrap: wrap; margin-top: 14px; }
.chips.scroll { overflow-x: auto; margin: 0 -4px 10px; padding: 2px 4px 6px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 40px; padding: 6px 14px; border-radius: 99px; background: var(--card); box-shadow: 0 1px 0 var(--line); font-size: 15px; white-space: nowrap; }
.chip.on { background: var(--ink); color: #fff; }

/* 提示条 */
#toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 14px); z-index: 20;
  display: flex; align-items: center; gap: 14px; width: max-content; max-width: calc(100vw - 32px);
  padding: 11px 18px; border-radius: 99px; background: var(--ink); color: #fff; font-size: 15px;
  transform: translate(-50%, -14px); opacity: 0; pointer-events: none; transition: transform .2s, opacity .2s;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
#toast button { color: #8FE3CC; font-weight: 700; padding: 4px 0; }

/* 登录 */
.login { display: grid; justify-items: center; gap: 6px; max-width: 300px; margin: 0 auto; padding-top: 18vh; text-align: center; }
.login h1 { font-size: 21px; margin-top: 12px; }
.login .btn { margin-top: 6px; }
.problem { min-height: 24px; color: var(--coral); font-size: 14px; }

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