:root {
  /* ===== 史迪仔蓝（品牌主色，真实 HEX） ===== */
  --stitch: #5078A7;        /* 毛蓝 body fur */
  --stitch-d: #3E60A4;      /* 深皇家蓝 耳朵/暗部 */
  --stitch-l: #A8C6E1;      /* 浅肚蓝 肚皮/眼罩 */
  --ear: #B684A2;           /* 耳朵内粉 lavender-pink */
  --nose: #2C3A4A;          /* 鼻/近黑靛 */
  --stitch-night: #0D2953;  /* logo 深夜蓝 */
  /* 兼容旧 class 引用 */
  --blue: var(--stitch);
  --blue-l: var(--stitch-l);
  --blue-d: var(--stitch-d);
  --green: #7BC47F;
  --yellow: #FFD966;
  /* ===== 夏威夷 & 母婴柔彩 ===== */
  --hibiscus: #DF4D72;      /* 木槿珊瑚 */
  --coral: #FF8FA3;         /* 柔珊瑚 */
  --teal: #46B1C9;          /* 考艾岛青 */
  --mint: #C7F0DB;          /* 薄荷 */
  --lavender: #E6E6FA;      /* 薰衣草 */
  --butter: #FFF3B0;        /* 奶油黄 */
  --sunset: #FD7A5E;        /* 落日橙 */
  /* ===== 中性 ===== */
  --cream: #FFF9F0;
  --cloud: #FBFDFF;
  --ink: #2C3A4A;
  --muted: #8AA0B4;
  --line: #E3EDF7;
  /* ===== 表面 ===== */
  --surface: #FFFFFF;
  --surface-2: #F4F9FF;
  /* ===== 语义 ===== */
  --success: #5BBF6A;
  --warn: #E8A33D;
  --danger: #E5547A;
  --info: #6FB1E6;
  /* ===== 阴影（软棉花糖） ===== */
  --sh-sm: 0 4px 12px rgba(80,120,167,.10);
  --sh: 0 10px 28px rgba(80,120,167,.16);
  --sh-lg: 0 18px 44px rgba(80,120,167,.22);
  --shadow: var(--sh);
  /* ===== 字体（圆体优先） ===== */
  --font: "PingFang SC", "Microsoft YaHei", "Quicksand", "ZCOOL KuaiLe", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(160deg, #EAF4FF 0%, #FDF0F6 46%, #FFF9F0 100%);
  min-height: 100vh;
}
.hidden { display: none !important; }

/* 漂浮星星背景 */
.stars {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .55;
  background-image:
    radial-gradient(circle, rgba(255, 217, 102, .55) 2px, transparent 3px),
    radial-gradient(circle, rgba(123, 196, 127, .45) 2px, transparent 3px);
  background-size: 150px 150px, 220px 220px;
  background-position: 25px 35px, 130px 100px;
}

/* ===== 登录页 ===== */
.login-wrap {
  position: relative; z-index: 1;
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  background: #fff; border-radius: 28px; box-shadow: var(--shadow);
  padding: 38px 30px; width: 100%; max-width: 360px; text-align: center;
  animation: pop .5s ease;
}
.login-card h1 { font-size: 22px; margin: 4px 0 2px; color: var(--blue-d); }
.login-card .sub { color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.login-card input {
  width: 100%; padding: 14px 16px; border: 2px solid #e3eefb; border-radius: 16px;
  font-size: 16px; outline: none; transition: .2s; text-align: center;
}
.login-card input:focus { border-color: var(--blue); }
.login-card button {
  width: 100%; margin-top: 14px; padding: 14px; border: none; border-radius: 16px;
  background: linear-gradient(135deg, var(--blue-l), var(--blue)); color: #fff;
  font-size: 17px; font-weight: 700; cursor: pointer; transition: .2s; box-shadow: var(--shadow);
}
.login-card button:hover { transform: translateY(-2px); }
.err { color: #e26a6a; font-size: 13px; min-height: 18px; margin: 10px 0 0; }

/* ===== 主界面 ===== */
.main-wrap { position: relative; z-index: 1; max-width: 760px; margin: 0 auto; padding: 16px 16px 60px; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 8px 4px 16px; }
.brand { font-size: 20px; font-weight: 800; color: var(--blue-d); display: flex; align-items: center; gap: 6px; }
.ghost { background: none; border: 2px solid #e3eefb; color: var(--muted); border-radius: 14px; padding: 8px 16px; cursor: pointer; font-size: 14px; }
.ghost:hover { border-color: var(--blue); color: var(--blue); }

.dashboard { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.card { background: #fff; border-radius: 22px; box-shadow: var(--shadow); padding: 18px; }
.ring-card { position: relative; display: flex; align-items: center; justify-content: center; }
.ring { width: 130px; height: 130px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: #eef4fb; stroke-width: 12; }
.ring-fg { fill: none; stroke: url(#g); stroke: var(--blue); stroke-width: 12; stroke-linecap: round;
  stroke-dasharray: 326.7; stroke-dashoffset: 326.7; transition: stroke-dashoffset .8s ease; }
.ring-center { position: absolute; text-align: center; }
.ring-center span { font-size: 34px; font-weight: 800; color: var(--blue-d); }
.ring-center i { font-size: 16px; font-style: normal; color: var(--blue); }
.ring-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.stat-card { display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.stat { display: flex; align-items: baseline; gap: 8px; }
.stat-num { font-size: 26px; font-weight: 800; color: var(--ink); }
.stat-cap { font-size: 13px; color: var(--muted); }

button.primary { background: linear-gradient(135deg, var(--blue-l), var(--blue)); color: #fff; border: none;
  border-radius: 16px; padding: 12px 18px; font-size: 15px; font-weight: 700; cursor: pointer; box-shadow: var(--shadow); transition: .2s; }
button.primary:hover { transform: translateY(-2px); }
button.primary.sm { padding: 10px; font-size: 14px; }

/* ===== 分类清单 ===== */
.cat { background: #fff; border-radius: 22px; box-shadow: var(--shadow); padding: 16px 16px 8px; margin-bottom: 14px; }
.cat-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cat-name { font-size: 17px; font-weight: 800; color: var(--blue-d); }
.cat-prog { font-size: 13px; color: var(--muted); }
.cat-bar { height: 8px; background: #eef4fb; border-radius: 6px; overflow: hidden; margin: 8px 0 12px; }
.cat-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue-l), var(--blue)); border-radius: 6px; transition: width .6s; }
.sub-title { font-size: 13px; color: var(--muted); font-weight: 700; margin: 6px 2px; }

.item { display: flex; align-items: center; gap: 10px; padding: 9px 6px; border-bottom: 1px dashed #f0f3f7; }
.item:last-child { border-bottom: none; }
.item .cb { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--blue-l); flex: none;
  display: flex; align-items: center; justify-content: center; cursor: pointer; transition: .2s; background: #fff; }
.item.done .cb { background: var(--blue); border-color: var(--blue); }
.item.done .cb::after { content: "✓"; color: #fff; font-size: 14px; font-weight: 800; }
.item .nm { flex: 1; font-size: 14px; line-height: 1.4; }
.item.done .nm { color: var(--muted); text-decoration: line-through; }
.item .sp { font-size: 12px; color: #2fae6a; font-weight: 700; white-space: nowrap; }
.item .rec { font-size: 11px; color: var(--muted); display: block; }
.spend-btn { border: none; background: #fff3d6; color: #b8860b; border-radius: 10px; padding: 5px 10px;
  font-size: 12px; cursor: pointer; white-space: nowrap; }
.spend-btn:hover { background: #ffe9b0; }
.photo-btn { border: none; background: #e8f1fc; color: var(--blue-d); border-radius: 10px; padding: 5px 9px;
  font-size: 13px; cursor: pointer; white-space: nowrap; }
.photo-btn:hover { background: #d6e7fb; }
.thumbs { flex-basis: 100%; display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; border: 2px solid #eef4fb; }

/* ===== 弹窗 ===== */
.modal { position: fixed; inset: 0; background: rgba(40,60,80,.4); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 18px; }
.modal-box { background: #fff; border-radius: 22px; padding: 20px; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
.modal-box h3 { margin: 0 0 12px; color: var(--blue-d); }
.modal-box pre { background: #f7fbff; border-radius: 14px; padding: 14px; font-size: 13px; line-height: 1.6; white-space: pre-wrap; max-height: 50vh; overflow: auto; font-family: inherit; }
.modal-actions { display: flex; gap: 10px; margin-top: 14px; }
.modal-actions .ghost { flex: 1; }
.modal-actions .primary { flex: 1; }

@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ===== 顶部 Tab ===== */
.tabs { display: flex; gap: 8px; padding: 4px 4px 14px; }
.tab { flex: 1; padding: 11px; border: 2px solid #e3eefb; background: #fff; border-radius: 16px;
  font-size: 15px; font-weight: 700; color: var(--muted); cursor: pointer; transition: .2s; }
.tab.active { border-color: var(--blue); color: var(--blue-d); background: #f3f9ff; }

/* ===== 缺漏检测 ===== */
.check-summary { background: #fff; border-radius: 18px; box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 14px; font-size: 15px; position: relative; overflow: hidden; }
.check-summary b { color: var(--blue-d); }
.check-summary .miss { color: #e8a33d; }
.check-summary .miss b { color: #e8a33d; }
.ck-tip { font-size: 12px; color: var(--muted); margin-top: 8px; }

.ck-cat { background: #fff; border-radius: 22px; box-shadow: var(--shadow); padding: 16px 16px 10px; margin-bottom: 14px; }
.ck-cat-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.ck-cat-name { font-size: 17px; font-weight: 800; color: var(--blue-d); }
.ck-cat-prog { font-size: 12px; color: var(--muted); }
.ck-cat-prog .m { color: #e8a33d; font-weight: 700; }
.ck-item { display: flex; align-items: center; gap: 8px; padding: 8px 4px; border-bottom: 1px dashed #f0f3f7; }
.ck-item:last-child { border-bottom: none; }
.ck-item .nm { flex: 1; font-size: 14px; line-height: 1.4; }
.ck-item .sub { font-size: 11px; color: var(--muted); margin-right: 4px; }
.badge { font-size: 11px; font-weight: 700; border-radius: 9px; padding: 3px 8px; white-space: nowrap; }
.badge.b-bought { background: #e6f6e7; color: #3a9a45; }
.badge.b-unbought { background: #e8f1fc; color: var(--blue-d); }
.badge.b-missing { background: #fdeccd; color: #c9842a; }
.add-btn { border: none; background: #fff3d6; color: #b8860b; border-radius: 10px; padding: 5px 10px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.add-btn:hover { background: #ffe9b0; }

@media (max-width: 520px) {
  .dashboard { grid-template-columns: 1fr; }
  .ring { width: 110px; height: 110px; }
}

/* ===== 分类 / 子组折叠卡片 ===== */
.cat-head { cursor: pointer; user-select: none; }
.cat-head .arrow { color: var(--muted); font-size: 13px; transition: transform .2s; margin-left: 6px; }
.cat.collapsed .cat-head .arrow { transform: rotate(-90deg); }
.cat.collapsed .cat-body { display: none; }

.sub-card { background: #f7fbff; border-radius: 16px; padding: 4px 10px; margin: 10px 0; }
.sub-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px;
  font-weight: 700; color: var(--blue); padding: 8px 2px; cursor: pointer; user-select: none; }
.sub-head .arrow { color: var(--muted); font-size: 12px; transition: transform .2s; }
.sub-card.collapsed .sub-head .arrow { transform: rotate(-90deg); }
.sub-card.collapsed .sub-body { display: none; }

/* ===== 已花明细可折叠框 ===== */
.spent-box { margin-bottom: 14px; padding: 0; overflow: hidden; }
.spent-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px;
  cursor: pointer; user-select: none; font-size: 15px; font-weight: 700; color: var(--blue-d); }
.spent-head .arrow { color: var(--muted); transition: transform .2s; }
.spent-body { padding: 0 16px 14px; }
.sp-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed #f0f3f7; }
.sp-row:last-child { border-bottom: none; }
.sp-name { flex: 1; font-size: 14px; }
.sp-note { font-size: 12px; color: var(--muted); }
.sp-amt { font-size: 14px; font-weight: 800; color: #2fae6a; white-space: nowrap; }
.spent-body .empty { font-size: 13px; color: var(--muted); padding: 4px 0; text-align: center; }

/* ===== 新增按钮 ===== */
button.ghost.sm { padding: 10px; font-size: 14px; }

/* ===== 宝宝时间轴卡 ===== */
.timeline-card { background: linear-gradient(135deg, #EAF4FF 0%, #FDEFF6 100%); border: 2px solid #e3eefb; }
.tl-top { display: flex; align-items: center; gap: 12px; }
.tl-info { flex: 1; }
.tl-big { font-size: 38px; line-height: 1.1; }
.tl-big i { font-size: 15px; font-style: normal; color: var(--blue); margin-left: 2px; }
.tl-cap { font-size: 14px; color: var(--ink); margin-top: 4px; line-height: 1.4; }
.tl-cap b { color: var(--blue-d); font-weight: 800; }
.tl-due { font-size: 13px; color: var(--muted); margin: 10px 0 6px; }
.tl-due b { color: var(--blue-d); }
.tl-bar { height: 10px; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,.06); }
.tl-bar > i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, #7BC47F, var(--blue)); border-radius: 8px; transition: width .8s ease; }
.tl-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ===== 史迪仔真实素材图（大量融入各环节） ===== */
.stitch-img { display: block; }
.login-stitch {
  width: 152px; height: auto; margin: 0 auto 8px;
  animation: float 3s ease-in-out infinite;
  filter: drop-shadow(0 10px 18px rgba(80,120,167,.28));
}
.tab-stitch { width: 26px; height: 26px; object-fit: contain; }
.tl-stitch { width: 48px; height: 48px; object-fit: contain; flex: none; animation: float 4s ease-in-out infinite; }
.ring-stitch {
  position: absolute; right: -8px; bottom: -10px; width: 50px; height: 50px;
  object-fit: contain; filter: drop-shadow(0 4px 8px rgba(80,120,167,.28));
  animation: float 3.6s ease-in-out infinite; pointer-events: none;
}
.cat-stitch { width: 32px; height: 32px; object-fit: contain; margin-right: 8px; flex: none; animation: float 3s ease-in-out infinite; }
.ck-stitch { width: 40px; height: 40px; object-fit: contain; float: right; margin: 0 0 4px 10px; animation: float 3.4s ease-in-out infinite; }
.modal-stitch { width: 44px; height: 44px; object-fit: contain; margin: 0 auto 6px; animation: float 3s ease-in-out infinite; }

/* 记账成功随机感谢词 toast（史迪仔蓝紫主题、屏幕正中、3.5s 自动消失、可爱 pop） */
.toast {
  position: fixed; left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(.82);
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(135deg, #8E7CF7, #6B5BD6);
  color: #fff; padding: 14px 22px; border-radius: 22px;
  font-size: 15px; font-weight: 600;
  box-shadow: 0 14px 40px rgba(107, 91, 214, .4);
  opacity: 0; pointer-events: none; z-index: 60;
  transition: opacity .28s ease, transform .32s cubic-bezier(.34, 1.56, .64, 1);
  max-width: 88vw; text-align: center; line-height: 1.4;
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.toast-stitch {
  width: 36px; height: 36px; object-fit: contain; flex: 0 0 auto;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .2));
  animation: toastBob 1.2s ease-in-out infinite;
}
@keyframes toastBob {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50%      { transform: translateY(-4px) rotate(5deg); }
}
.spent-empty-stitch { width: 66px; height: 66px; object-fit: contain; margin: 8px auto 6px; animation: float 3.2s ease-in-out infinite; }

/* 史迪仔素材改为自绘 SVG（蓝紫经典、真透明、零水印），无需 multiply 混合 */
img[class*="stitch"] { mix-blend-mode: normal; }

/* 已花明细行可点击 → 打开修改/删除弹窗 */
.sp-row { cursor: pointer; transition: background .15s; border-radius: 8px;
  padding-left: 8px; padding-right: 8px; margin: 0 -8px; }
.sp-row:hover { background: #f3f8ff; }
.sp-row:hover .sp-edit { color: var(--blue); opacity: 1; }
.sp-edit { font-size: 14px; color: var(--muted); opacity: .55; padding-left: 6px; user-select: none; transition: all .15s; }

/* 新增分类输入 */
.ad-newcat { width: 100%; padding: 12px; border: 2px solid #e3eefb; border-radius: 14px; font-size: 15px; outline: none; margin-bottom: 10px; }
.ad-newcat:focus { border-color: var(--blue); }
.ad-cat { width: 100%; padding: 12px; border: 2px solid #e3eefb; border-radius: 14px; font-size: 15px; outline: none; margin-bottom: 10px; background: #fff; }
