/* ============ 家庭采购 · 绿粉白设计系统 ============ */
:root {
  --green: #2FA36B;
  --green-deep: #14724B;
  --green-mid: #1F8A58;
  --green-soft: #E3F4EB;
  --pink: #F471A8;
  --pink-deep: #D94F87;
  --pink-soft: #FDE8F2;
  --ink: #22452F;
  --ink-2: #6E8A7B;
  --card: #FFFFFF;
  --line: #E4EFE8;
  --shadow: 0 4px 18px rgba(31, 138, 88, 0.10);
  --shadow-pink: 0 4px 18px rgba(244, 113, 168, 0.16);
  --radius: 20px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 17px; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: linear-gradient(165deg, #E8F6EE 0%, #F5FBF7 45%, #FDEFF5 100%) fixed;
  min-height: 100vh;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input { font-family: inherit; outline: none; }

/* ============ 进入页 ============ */
.gate {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.gate-card {
  width: 100%; max-width: 400px;
  background: var(--card);
  border-radius: 28px;
  box-shadow: var(--shadow), var(--shadow-pink);
  padding: 40px 28px 32px;
  text-align: center;
  animation: rise .5s ease both;
}
.gate-logo {
  width: 84px; height: 84px; margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--green-soft), var(--pink-soft));
  border-radius: 26px;
  display: flex; align-items: center; justify-content: center;
  font-size: 44px;
  box-shadow: inset 0 0 0 2px rgba(47,163,107,.12);
}
.gate-title { font-size: 28px; color: var(--green-deep); letter-spacing: 2px; }
.gate-sub { color: var(--ink-2); margin: 8px 0 26px; font-size: 15px; }
.gate-label {
  display: block; text-align: left; font-size: 14px; font-weight: 600;
  color: var(--green-mid); margin: 14px 4px 6px;
}
.gate-input {
  width: 100%; height: 54px;
  border: 2px solid var(--line); border-radius: 16px;
  padding: 0 16px; font-size: 19px; color: var(--ink);
  background: #FBFDFC;
  transition: border-color .2s, box-shadow .2s;
}
.gate-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(47,163,107,.12);
}
.gate-btn {
  width: 100%; height: 56px; margin-top: 24px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-mid) 100%);
  color: #fff; font-size: 20px; font-weight: 700; letter-spacing: 4px;
  box-shadow: 0 6px 16px rgba(47,163,107,.35);
  transition: transform .12s, box-shadow .2s;
}
.gate-btn:active { transform: scale(.97); box-shadow: 0 3px 8px rgba(47,163,107,.3); }
.gate-err { color: var(--pink-deep); font-size: 14px; margin-top: 12px; min-height: 20px; }

/* 成员选择卡片 */
.gate-members {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 6px;
}
.member-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 18px 6px 14px;
  background: linear-gradient(160deg, #F2FAF5, var(--pink-soft));
  border: 2px solid transparent;
  border-radius: 18px;
  transition: transform .12s, border-color .2s, box-shadow .2s;
}
.member-card:active { transform: scale(.94); border-color: var(--green); box-shadow: 0 4px 14px rgba(47,163,107,.25); }
.member-avatar { font-size: 42px; }
.member-name { font-size: 16px; font-weight: 700; color: var(--green-deep); }

/* PIN 屏 */
.gate-who {
  display: flex; align-items: center; gap: 10px;
  margin: 4px 0 4px;
}
.gate-who-avatar { font-size: 38px; }
.gate-who-name { font-size: 21px; font-weight: 700; color: var(--green-deep); flex: 1; text-align: left; }
.gate-back {
  color: var(--pink-deep); font-size: 14.5px; font-weight: 600;
  padding: 8px 12px; border-radius: 999px; background: var(--pink-soft);
}
.gate-back:active { transform: scale(.95); }
.gate-pin {
  text-align: center; font-size: 26px !important; letter-spacing: 12px;
  padding-left: 28px !important;
}

/* ============ 顶栏 ============ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(120deg, var(--green) 0%, #3DB87E 55%, #F48FB8 130%);
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 0 14px;
  box-shadow: 0 4px 20px rgba(31,138,88,.25);
  border-radius: 0 0 26px 26px;
}
.topbar-inner {
  max-width: 560px; margin: 0 auto; padding: 0 18px;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar-title { display: flex; align-items: center; gap: 12px; }
.topbar-basket {
  font-size: 30px;
  background: rgba(255,255,255,.22);
  border-radius: 14px; width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
}
.topbar-name { color: #fff; font-size: 21px; font-weight: 700; letter-spacing: 1px; }
.topbar-sync { color: rgba(255,255,255,.85); font-size: 12px; margin-top: 2px; }
.topbar-user {
  background: rgba(255,255,255,.25);
  color: #fff; font-size: 15px; font-weight: 600;
  padding: 8px 16px; border-radius: 999px;
  box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.35);
}

/* ============ 主区 ============ */
.main {
  max-width: 560px; margin: 0 auto;
  padding: 18px 14px 180px;
}
.page-hint { color: var(--ink-2); font-size: 14px; margin: 2px 6px 14px; }

/* 分类分组标题 */
.cat-head {
  display: flex; align-items: center; gap: 8px;
  margin: 20px 6px 10px;
  font-size: 15px; font-weight: 700; color: var(--green-deep);
}
.cat-head .cat-emoji {
  width: 34px; height: 34px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  background: var(--green-soft);
}
.cat-head .cat-line { flex: 1; height: 2px; border-radius: 2px; background: linear-gradient(90deg, var(--line), transparent); }

/* 物品卡片 */
.item {
  display: flex; align-items: center; gap: 13px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 15px 16px;
  margin-bottom: 11px;
  animation: rise .35s ease both;
  transition: opacity .3s, transform .3s;
}
.item.bought { opacity: .62; }
.item.bought .item-name { text-decoration: line-through; color: var(--ink-2); }

.check {
  flex: none;
  width: 46px; height: 46px; border-radius: 50%;
  border: 2.5px solid var(--green);
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: transparent;
  transition: background .2s, transform .15s, border-color .2s;
}
.check:active { transform: scale(.88); }
.check.on {
  background: linear-gradient(135deg, var(--green), var(--green-mid));
  color: #fff; border-color: transparent;
  animation: pop .3s ease;
}
.check-pink { border-color: var(--pink); }
.check-pink.on { background: linear-gradient(135deg, var(--pink), var(--pink-deep)); }

.item-body { flex: 1; min-width: 0; }
.item-name { font-size: 19px; font-weight: 700; word-break: break-all; }
.item-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 5px; font-size: 13px; color: var(--ink-2);
}
.qty-tag {
  background: var(--green-soft); color: var(--green-deep);
  font-weight: 700; padding: 3px 10px; border-radius: 999px; font-size: 14px;
}
.note-tag {
  background: #FFF6E9; color: #A8772A;
  padding: 3px 10px; border-radius: 999px; font-size: 12.5px;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.who-tag { color: var(--ink-2); font-size: 12.5px; }
.who-tag.pink { color: var(--pink-deep); font-weight: 600; }
.item-edit {
  flex: none; width: 40px; height: 40px; border-radius: 12px;
  color: #B7CCC2; font-size: 17px;
  display: flex; align-items: center; justify-content: center;
}
.item-edit:active { background: var(--green-soft); color: var(--green-deep); }

/* 已买到页 */
.bought-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin: 2px 4px 14px;
}
.bought-count { color: var(--ink-2); font-size: 14.5px; }
.clear-btn {
  background: var(--pink-soft); color: var(--pink-deep);
  font-size: 14.5px; font-weight: 700;
  padding: 10px 16px; border-radius: 999px;
  transition: transform .12s;
}
.clear-btn:active { transform: scale(.95); }

/* 常购物品页 */
.staple-add-btn {
  background: linear-gradient(135deg, var(--green), var(--green-mid));
  color: #fff; font-size: 14.5px; font-weight: 700;
  padding: 10px 15px; border-radius: 999px; white-space: nowrap;
  box-shadow: 0 3px 10px rgba(47,163,107,.3);
  transition: transform .12s;
}
.staple-add-btn:active { transform: scale(.93); }
.staple-del {
  flex: none; width: 38px; height: 38px; border-radius: 12px;
  color: #D9B8C8; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.staple-del:active { background: var(--pink-soft); color: var(--pink-deep); }

/* 空状态 */
.empty {
  text-align: center; padding: 64px 20px;
  animation: rise .4s ease both;
}
.empty-emoji { font-size: 64px; }
.empty-text { color: var(--ink-2); font-size: 16px; margin-top: 14px; line-height: 1.7; }

/* ============ 快捷添加条 ============ */
.quick-add {
  position: fixed; z-index: 25;
  left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 84px);
  width: min(560px, 100%);
  padding: 0 14px;
  display: flex; gap: 10px;
  pointer-events: none;
}
.quick-add > * { pointer-events: auto; }
.qa-input {
  flex: 1; height: 58px;
  border: none; border-radius: 20px;
  padding: 0 20px; font-size: 18px; color: var(--ink);
  background: #fff;
  box-shadow: 0 6px 24px rgba(31,138,88,.18), inset 0 0 0 2px var(--line);
  transition: box-shadow .2s;
}
.qa-input:focus { box-shadow: 0 6px 24px rgba(31,138,88,.22), inset 0 0 0 2.5px var(--green); }
.qa-btn {
  flex: none; width: 58px; height: 58px; border-radius: 20px;
  background: linear-gradient(135deg, var(--pink), var(--pink-deep));
  color: #fff; font-size: 30px; font-weight: 300; line-height: 1;
  box-shadow: 0 6px 18px rgba(244,113,168,.4);
  transition: transform .12s;
}
.qa-btn:active { transform: scale(.9); }

/* ============ 底部 TabBar ============ */
.tabbar {
  position: fixed; z-index: 30;
  left: 50%; transform: translateX(-50%);
  bottom: 0;
  width: min(560px, 100%);
  display: flex;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(12px);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -4px 24px rgba(31,138,88,.12);
  padding: 8px 6px calc(env(safe-area-inset-bottom, 0px) + 10px);
}
.tab {
  flex: 1; padding: 7px 0 5px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  border-radius: 16px; position: relative;
  transition: color .2s, background .2s, transform .1s;
}
.tab:active { transform: scale(.95); }
.tab-ico { font-size: 23px; filter: grayscale(.55); transition: filter .2s, transform .2s; }
.tab.active { color: var(--green-deep); }
.tab.active .tab-ico { filter: none; transform: translateY(-1px) scale(1.12); }
.tab-badge {
  position: absolute; top: 0; right: 14%;
  min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px;
  background: var(--green); color: #fff;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(47,163,107,.4);
}
.tab-badge-pink { background: var(--pink); box-shadow: 0 2px 6px rgba(244,113,168,.4); }

/* ============ 我的页 ============ */
.me-card {
  background: var(--card); border-radius: 24px; box-shadow: var(--shadow);
  padding: 30px 22px; text-align: center; margin-bottom: 16px;
  animation: rise .35s ease both;
}
.me-avatar {
  width: 88px; height: 88px; margin: 0 auto 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green-soft), var(--pink-soft));
  display: flex; align-items: center; justify-content: center;
  font-size: 44px;
  box-shadow: inset 0 0 0 3px #fff, 0 4px 14px rgba(47,163,107,.15);
}
.me-name { font-size: 23px; font-weight: 700; color: var(--green-deep); margin-bottom: 18px; }
.me-btn {
  display: block; width: 100%; height: 52px; margin-top: 12px;
  border-radius: 16px;
  background: var(--green-soft); color: var(--green-deep);
  font-size: 16.5px; font-weight: 700;
  transition: transform .12s, filter .2s;
}
.me-btn:active { transform: scale(.97); filter: brightness(.96); }
.me-btn-pink { background: var(--pink-soft); color: var(--pink-deep); }
.me-about { text-align: left; }
.me-about-title { font-weight: 700; color: var(--green-deep); margin-bottom: 8px; }
.me-about p { color: var(--ink-2); font-size: 14.5px; line-height: 1.8; }
.me-sync-detail { margin-top: 6px; font-size: 13px !important; }

/* ============ 底部弹层 ============ */
.sheet-mask {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(34,69,47,.35);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .2s ease both;
}
.sheet {
  width: min(560px, 100%);
  background: #fff;
  border-radius: 28px 28px 0 0;
  padding: 22px 22px calc(env(safe-area-inset-bottom, 0px) + 26px);
  animation: slideup .28s cubic-bezier(.2,.9,.3,1.1) both;
}
.sheet-title { font-size: 20px; font-weight: 700; color: var(--green-deep); margin-bottom: 6px; text-align: center; }
.sheet-label { display: block; font-size: 14px; font-weight: 600; color: var(--green-mid); margin: 14px 4px 7px; }
.sheet-input {
  width: 100%; height: 52px;
  border: 2px solid var(--line); border-radius: 15px;
  padding: 0 15px; font-size: 17.5px; color: var(--ink);
  background: #FBFDFC;
}
.sheet-input:focus { border-color: var(--green); }
.sheet-cats { display: flex; flex-wrap: wrap; gap: 8px; }
.sheet-cat {
  padding: 9px 14px; border-radius: 999px;
  background: #F2F7F4; color: var(--ink-2);
  font-size: 14.5px; font-weight: 600;
  transition: all .15s;
}
.sheet-cat.on { background: var(--green); color: #fff; box-shadow: 0 3px 8px rgba(47,163,107,.3); }
.sheet-actions { display: flex; gap: 10px; margin-top: 24px; }
.sheet-btn {
  flex: 1; height: 54px; border-radius: 16px;
  background: #F2F7F4; color: var(--ink-2);
  font-size: 17px; font-weight: 700;
  transition: transform .12s;
}
.sheet-btn:active { transform: scale(.96); }
.sheet-btn-ok { background: linear-gradient(135deg, var(--green), var(--green-mid)); color: #fff; box-shadow: 0 4px 12px rgba(47,163,107,.3); }
.sheet-btn-del { flex: .7; background: var(--pink-soft); color: var(--pink-deep); }

/* ============ Toast ============ */
.toast {
  position: fixed; z-index: 99;
  left: 50%; bottom: 170px;
  transform: translateX(-50%);
  background: rgba(34,69,47,.92); color: #fff;
  padding: 12px 22px; border-radius: 999px;
  font-size: 15.5px; font-weight: 600;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
  animation: rise .25s ease both;
  pointer-events: none;
  max-width: 80%;
  text-align: center;
}

/* ============ 动效 ============ */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes slideup { from { transform: translateY(60px); opacity: 0; } to { transform: none; opacity: 1; } }

/* 桌面端稍微放宽 */
@media (min-width: 640px) {
  html { font-size: 17.5px; }
}

/* 大字模式：整体视觉放大（zoom 同时放大 px 与 rem，fixed 元素一并适配） */
body.bigfont { zoom: 1.22; }
