* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; background: #FAF8F5; color: #2D2A26; overflow-x: hidden; }
body { max-width: 430px; margin: 0 auto; position: relative; }

:root {
  --bg: #FAF8F5; --bg2: #F0EDE8; --ink: #2D2A26; --muted: #7A756D; --light: #A8A49C;
  --accent: #E07A5F; --accent-light: #FCEAE5; --accent-dark: #C45A3F;
  --green: #81B29A; --green-light: #E0F2ED; --green-dark: #5A8F76;
  --yellow: #F2CC8F; --yellow-light: #FDF5E6;
  --purple: #9B8AA5; --purple-light: #E8E4F3;
  --shadow: 0 2px 12px rgba(45,42,38,0.08); --shadow-lg: 0 8px 32px rgba(45,42,38,0.12);
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-12px); } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes pop { 0% { transform: scale(0.8); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%,60%{transform:translateX(-6px)} 40%,80%{transform:translateX(6px)} }
@keyframes celebrate { 0%{transform:scale(0)rotate(-20deg)} 50%{transform:scale(1.2)rotate(5deg)} 100%{transform:scale(1)rotate(0)} }
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-6px)} }
@keyframes confetti { 0%{transform:translateY(-10vh)rotate(0)} 100%{transform:translateY(110vh)rotate(720deg)} }

.page { display: none; min-height: 100vh; padding-bottom: 80px; animation: fadeIn 0.35s ease; }
.page.active { display: block; }

/* 欢迎页 */
.welcome-page { background: linear-gradient(160deg, #FAF8F5 0%, #F0EDE8 100%); text-align: center; padding: 60px 32px 40px; }
.page.active.welcome-page { display: flex; flex-direction: column; justify-content: center; min-height: 100vh; }
.welcome-page .logo { width: 80px; height: 80px; background: var(--accent); border-radius: 24px; display: flex; align-items: center; justify-content: center; margin: 0 auto 28px; font-size: 40px; animation: float 3s ease-in-out infinite; }
.welcome-page h1 { font-size: 32px; font-weight: 700; margin-bottom: 8px; letter-spacing: -0.5px; }
.welcome-page .subtitle { font-size: 18px; color: var(--muted); margin-bottom: 12px; }
.welcome-page .formula { background: var(--ink); color: #fff; padding: 14px 24px; border-radius: 16px; font-size: 20px; font-weight: 700; margin: 24px auto; display: inline-block; letter-spacing: 1px; }
.welcome-page .formula .m { color: #F2CC8F; } .welcome-page .formula .a { color: var(--green); } .welcome-page .formula .p { color: #A8DADC; }
.welcome-page .desc { font-size: 15px; color: var(--muted); line-height: 1.8; max-width: 300px; margin: 0 auto 40px; }
.welcome-page .btn-primary { width: 100%; padding: 16px; background: var(--accent); color: #fff; border: none; border-radius: 16px; font-size: 17px; font-weight: 700; cursor: pointer; box-shadow: var(--shadow); transition: transform 0.2s; }
.welcome-page .btn-primary:active { transform: scale(0.97); }
.welcome-page .hint { font-size: 13px; color: var(--light); margin-top: 16px; }

/* 按钮系统 */
.btn-primary { width: 100%; padding: 16px; background: var(--accent); color: #fff; border: none; border-radius: 16px; font-size: 17px; font-weight: 700; cursor: pointer; box-shadow: var(--shadow); transition: all 0.2s; }
.btn-primary:active { transform: scale(0.97); background: var(--accent-dark); }
.btn-secondary { width: 100%; padding: 14px; background: var(--bg2); color: var(--ink); border: none; border-radius: 14px; font-size: 15px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.btn-secondary:active { background: var(--light); }
.btn-ghost { padding: 10px 20px; background: transparent; color: var(--muted); border: 1px solid var(--light); border-radius: 12px; font-size: 14px; cursor: pointer; }

/* 导航栏 */
.top-nav { position: sticky; top: 0; z-index: 100; background: rgba(250,248,245,0.92); backdrop-filter: blur(12px); padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(0,0,0,0.04); }
.top-nav .back-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--bg2); display: flex; align-items: center; justify-content: center; font-size: 18px; cursor: pointer; border: none; }
.top-nav h2 { font-size: 17px; font-weight: 700; position: absolute; left: 50%; transform: translateX(-50%); }
.top-nav .right-action { font-size: 14px; color: var(--accent); font-weight: 600; cursor: pointer; background: none; border: none; }

/* 底部导航 */
.bottom-nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 430px; background: rgba(255,255,255,0.95); backdrop-filter: blur(16px); border-top: 1px solid rgba(0,0,0,0.05); display: flex; justify-content: space-around; padding: 8px 0 24px; z-index: 100; }
.bottom-nav .nav-item { flex: 1; text-align: center; padding: 6px; cursor: pointer; border: none; background: none; color: var(--light); font-size: 11px; transition: color 0.2s; }
.bottom-nav .nav-item .icon { font-size: 22px; display: block; margin-bottom: 2px; }
.bottom-nav .nav-item.active { color: var(--accent); }
.bottom-nav .nav-item.active .icon { transform: scale(1.1); transition: transform 0.2s; }

/* 首页 */
.home-header { padding: 16px 20px 8px; }
.home-header .greeting { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.home-header .date { font-size: 13px; color: var(--muted); }

.today-card { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%); border-radius: 20px; padding: 24px 20px; margin: 12px 20px 20px; color: #fff; position: relative; overflow: hidden; }
.today-card::before { content: ''; position: absolute; top: -30px; right: -30px; width: 120px; height: 120px; background: rgba(255,255,255,0.08); border-radius: 50%; }
.today-card .label { font-size: 13px; opacity: 0.85; margin-bottom: 6px; }
.today-card .count { font-size: 36px; font-weight: 700; margin-bottom: 4px; }
.today-card .sub { font-size: 14px; opacity: 0.85; }
.today-card .check-all { position: absolute; right: 20px; top: 50%; transform: translateY(-50%); width: 52px; height: 52px; background: rgba(255,255,255,0.2); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; cursor: pointer; border: 2px solid rgba(255,255,255,0.3); transition: all 0.3s; }
.today-card .check-all:active { transform: translateY(-50%) scale(0.9); }
.today-card .check-all.done { background: var(--green); border-color: var(--green); }

.section-title { font-size: 15px; font-weight: 700; color: var(--muted); padding: 0 20px; margin: 20px 0 10px; display: flex; align-items: center; justify-content: space-between; }
.section-title .add-btn { font-size: 13px; color: var(--accent); background: var(--accent-light); padding: 4px 12px; border-radius: 20px; cursor: pointer; border: none; font-weight: 600; }

/* 习惯卡片 */
.habit-card { background: #fff; border-radius: 16px; padding: 16px 18px; margin: 0 20px 10px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 14px; transition: transform 0.2s; }
.habit-card:active { transform: scale(0.98); }
.habit-card .check-circle { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--light); display: flex; align-items: center; justify-content: center; font-size: 20px; cursor: pointer; flex-shrink: 0; transition: all 0.3s; background: #fff; }
.habit-card .check-circle.checked { background: var(--green); border-color: var(--green); color: #fff; animation: celebrate 0.5s ease; }
.habit-card .habit-info { flex: 1; min-width: 0; }
.habit-card .habit-title { font-size: 15px; font-weight: 600; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.habit-card .habit-meta { font-size: 12px; color: var(--light); }
.habit-card .streak-badge { background: var(--yellow-light); color: var(--accent-dark); padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.habit-card .streak-badge .fire { margin-right: 2px; }

.empty-state { text-align: center; padding: 40px 20px; }
.empty-state .empty-icon { font-size: 64px; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { color: var(--muted); font-size: 14px; margin-bottom: 20px; }

/* 新建习惯向导 */
.wizard-page { padding: 0; background: var(--bg); }
.wizard-progress { padding: 20px 20px 0; display: flex; gap: 6px; }
.wizard-progress .dot { flex: 1; height: 4px; background: var(--bg2); border-radius: 2px; transition: background 0.3s; }
.wizard-progress .dot.active { background: var(--accent); }
.wizard-content { padding: 32px 24px; }
.wizard-content .step-title { font-size: 24px; font-weight: 700; margin-bottom: 8px; line-height: 1.3; }
.wizard-content .step-desc { font-size: 15px; color: var(--muted); margin-bottom: 28px; line-height: 1.6; }

.input-group { margin-bottom: 20px; }
.input-group label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; color: var(--muted); }
.input-group input, .input-group textarea { width: 100%; padding: 14px 16px; border: 2px solid var(--bg2); border-radius: 14px; font-size: 16px; background: #fff; transition: border-color 0.2s; font-family: inherit; }
.input-group input:focus, .input-group textarea:focus { outline: none; border-color: var(--accent); }
.input-group textarea { resize: none; height: 80px; }

/* 选项卡片 */
.option-card { background: #fff; border: 2px solid var(--bg2); border-radius: 16px; padding: 16px; margin-bottom: 10px; cursor: pointer; transition: all 0.2s; display: flex; align-items: flex-start; gap: 12px; }
.option-card:hover { border-color: var(--light); }
.option-card.selected { border-color: var(--accent); background: var(--accent-light); }
.option-card .option-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--bg2); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.option-card.selected .option-icon { background: var(--accent); }
.option-card .option-text { flex: 1; }
.option-card .option-text h4 { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.option-card .option-text p { font-size: 13px; color: var(--muted); line-height: 1.4; }
.option-card .check-mark { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--light); display: flex; align-items: center; justify-content: center; font-size: 12px; color: transparent; flex-shrink: 0; margin-top: 4px; }
.option-card.selected .check-mark { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 诊断页 */
.diagnosis-page .question-card { background: #fff; border-radius: 20px; padding: 28px 24px; margin: 20px; box-shadow: var(--shadow); text-align: center; }
.diagnosis-page .question-card .q-icon { font-size: 48px; margin-bottom: 16px; }
.diagnosis-page .question-card .q-text { font-size: 18px; font-weight: 700; margin-bottom: 24px; line-height: 1.5; }
.diagnosis-page .q-options { display: flex; flex-direction: column; gap: 10px; }
.diagnosis-page .q-option { padding: 14px 20px; border: 2px solid var(--bg2); border-radius: 14px; background: #fff; font-size: 15px; font-weight: 500; cursor: pointer; transition: all 0.2s; text-align: left; }
.diagnosis-page .q-option:hover { border-color: var(--light); }
.diagnosis-page .q-option.selected { border-color: var(--accent); background: var(--accent-light); }

/* 报告 */
.report-card { background: #fff; border-radius: 20px; padding: 28px 24px; margin: 20px; box-shadow: var(--shadow); }
.report-card .report-header { text-align: center; margin-bottom: 24px; }
.report-card .report-header .report-icon { font-size: 56px; margin-bottom: 12px; }
.report-card .report-header h3 { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.report-card .report-header p { font-size: 14px; color: var(--muted); }

.bar-chart { display: flex; align-items: flex-end; justify-content: center; gap: 24px; height: 140px; margin: 24px 0; padding: 0 20px; }
.bar-item { display: flex; flex-direction: column; align-items: center; flex: 1; }
.bar-item .bar { width: 40px; border-radius: 8px 8px 0 0; transition: height 1s ease; min-height: 8px; }
.bar-item .bar-label { font-size: 12px; font-weight: 600; margin-top: 8px; }
.bar-item .bar-val { font-size: 11px; color: var(--muted); margin-top: 2px; }
.bar-m .bar { background: linear-gradient(to top, #F2CC8F, #E8B96A); }
.bar-a .bar { background: linear-gradient(to top, #81B29A, #5A8F76); }
.bar-p .bar { background: linear-gradient(to top, #9B8AA5, #7A6A84); }

.report-insight { background: var(--bg2); border-radius: 14px; padding: 16px; margin-top: 20px; }
.report-insight h4 { font-size: 14px; font-weight: 700; margin-bottom: 8px; color: var(--accent); }
.report-insight p { font-size: 14px; line-height: 1.7; color: var(--ink); }

/* 庆祝弹窗 */
.celebrate-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200; display: none; align-items: center; justify-content: center; padding: 20px; }
.celebrate-overlay.active { display: flex; animation: fadeIn 0.3s; }
.celebrate-card { background: #fff; border-radius: 24px; padding: 40px 28px; text-align: center; max-width: 320px; width: 100%; animation: pop 0.5s ease; position: relative; overflow: hidden; }
.celebrate-card .celebrate-emoji { font-size: 72px; margin-bottom: 16px; animation: float 2s ease-in-out infinite; }
.celebrate-card h3 { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.celebrate-card p { font-size: 15px; color: var(--muted); margin-bottom: 24px; }

.confetti-piece { position: absolute; width: 8px; height: 8px; border-radius: 50%; animation: confetti 3s linear forwards; }

/* 习惯详情 */
.detail-hero { background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%); border-radius: 0 0 24px 24px; padding: 60px 24px 32px; color: #fff; text-align: center; position: relative; }
.detail-hero .detail-icon { font-size: 48px; margin-bottom: 12px; }
.detail-hero h2 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.detail-hero .detail-sub { font-size: 14px; opacity: 0.85; }
.detail-hero .detail-streak { font-size: 48px; font-weight: 700; margin: 16px 0 4px; }
.detail-hero .detail-streak-label { font-size: 13px; opacity: 0.8; }

.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; padding: 20px; }
.calendar-grid .cal-header { text-align: center; font-size: 12px; color: var(--light); font-weight: 600; padding: 4px; }
.calendar-grid .cal-day { aspect-ratio: 1; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; background: var(--bg2); color: var(--muted); }
.calendar-grid .cal-day.done { background: var(--green); color: #fff; }
.calendar-grid .cal-day.today { border: 2px solid var(--accent); }
.calendar-grid .cal-day.empty { background: transparent; }

/* 我的页面 */
.profile-header { background: linear-gradient(135deg, var(--ink) 0%, #3D405B 100%); border-radius: 0 0 24px 24px; padding: 48px 24px 28px; color: #fff; text-align: center; }
.profile-header .avatar { width: 72px; height: 72px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 32px; margin: 0 auto 12px; }
.profile-header h2 { font-size: 20px; font-weight: 700; }
.profile-header p { font-size: 13px; opacity: 0.7; margin-top: 4px; }

.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 20px; }
.stats-row .stat-card { background: #fff; border-radius: 16px; padding: 16px; text-align: center; box-shadow: var(--shadow); }
.stats-row .stat-card .stat-num { font-size: 24px; font-weight: 700; color: var(--accent); }
.stats-row .stat-card .stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }

.achievement-list { padding: 0 20px 20px; }
.achievement-item { background: #fff; border-radius: 14px; padding: 14px 16px; margin-bottom: 8px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow); }
.achievement-item .ach-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; background: var(--bg2); }
.achievement-item.unlocked .ach-icon { background: var(--yellow-light); }
.achievement-item .ach-info { flex: 1; }
.achievement-item .ach-info h4 { font-size: 14px; font-weight: 600; }
.achievement-item .ach-info p { font-size: 12px; color: var(--muted); }
.achievement-item .ach-status { font-size: 12px; font-weight: 700; color: var(--light); }
.achievement-item.unlocked .ach-status { color: var(--accent); }

/* 方案展示卡片 */
.plan-card { background: #fff; border-radius: 16px; padding: 20px; margin: 0 20px 12px; box-shadow: var(--shadow); }
.plan-card .plan-tag { display: inline-block; background: var(--accent-light); color: var(--accent-dark); padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 700; margin-bottom: 12px; }
.plan-card .plan-behavior { font-size: 18px; font-weight: 700; margin-bottom: 12px; color: var(--ink); }
.plan-card .plan-detail { font-size: 14px; color: var(--muted); line-height: 1.7; }
.plan-card .plan-detail strong { color: var(--accent); }

@media (max-width: 360px) {
  .welcome-page { padding: 40px 24px 32px; }
  .welcome-page h1 { font-size: 28px; }
  .bar-chart { gap: 16px; }
  .bar-item .bar { width: 32px; }
}

/* ===== 原理介绍页 ===== */
.theory-entry { background: #fff; border-radius: 16px; padding: 16px 18px; margin: 0 20px 20px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 14px; cursor: pointer; transition: transform 0.2s; }
.theory-entry:active { transform: scale(0.98); }
.theory-entry .theory-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--accent-light); display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.theory-entry .theory-text { flex: 1; }
.theory-entry .theory-text h4 { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.theory-entry .theory-text p { font-size: 13px; color: var(--muted); }
.theory-entry .theory-arrow { font-size: 20px; color: var(--light); }

.theory-page { background: var(--bg); }
.theory-content { padding: 24px 20px 40px; }
.theory-hero { text-align: center; margin-bottom: 32px; }
.theory-hero .theory-formula { background: var(--ink); color: #fff; padding: 14px 28px; border-radius: 16px; font-size: 22px; font-weight: 700; display: inline-block; letter-spacing: 2px; margin-bottom: 10px; }
.theory-hero .theory-formula .m { color: #F2CC8F; } .theory-hero .theory-formula .a { color: var(--green); } .theory-hero .theory-formula .p { color: #A8DADC; }
.theory-hero .theory-sub { font-size: 14px; color: var(--muted); }

.theory-section { background: #fff; border-radius: 16px; padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.theory-section h3 { font-size: 17px; font-weight: 700; margin-bottom: 12px; color: var(--ink); }
.theory-section p { font-size: 14px; color: var(--muted); line-height: 1.8; margin-bottom: 10px; }
.theory-section p:last-child { margin-bottom: 0; }
.theory-highlight { background: var(--accent-light); border-radius: 12px; padding: 16px; margin-top: 12px; text-align: center; font-size: 16px; color: var(--accent-dark); }

/* 成就 toast */
.achievement-toast { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%) scale(0); background: var(--ink); color: #fff; padding: 16px 28px; border-radius: 16px; font-size: 15px; text-align: center; z-index: 999; pointer-events: none; transition: transform 0.3s ease; box-shadow: 0 8px 32px rgba(0,0,0,0.2); }
.achievement-toast.active { transform: translate(-50%,-50%) scale(1); }

/* 四象限 */
.theory-quadrant { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.quad-row { display: flex; gap: 10px; }
.quad-cell { flex: 1; background: #fff; border-radius: 12px; padding: 14px; border: 2px solid var(--bg2); }
.quad-cell .quad-tag { font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.quad-cell .quad-title { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.quad-cell p { font-size: 13px; color: var(--muted); line-height: 1.6; margin: 0; }
.quad-good { border-color: var(--green); background: var(--green-light); }
.quad-good .quad-tag { color: var(--green-dark); }
.quad-bad { border-color: var(--accent); background: var(--accent-light); }
.quad-bad .quad-tag { color: var(--accent-dark); }
.quad-neutral { border-color: var(--yellow); background: var(--yellow-light); }
.quad-neutral .quad-tag { color: #B8860B; }
.quad-waste { border-color: var(--light); background: var(--bg2); opacity: 0.7; }
.quad-waste .quad-tag { color: var(--muted); }

/* 自定义微行为 & 编辑页 */
.custom-micro-content, .edit-habit-content { padding: 24px 20px 40px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.form-group input { width: 100%; padding: 12px 14px; border: 2px solid var(--bg2); border-radius: 12px; font-size: 15px; background: #fff; outline: none; transition: border-color 0.2s; box-sizing: border-box; }
.form-group input:focus { border-color: var(--accent); }

/* 按钮次级样式 */
.btn-secondary { display: block; width: 100%; padding: 14px; border: 2px solid var(--bg2); border-radius: 14px; background: #fff; font-size: 15px; font-weight: 600; color: var(--ink); cursor: pointer; transition: all 0.2s; }
.btn-secondary:hover { background: var(--bg2); }

/* 反馈卡片 */
.feedback-card { margin: 0 20px 16px; background: #FFF8E1; border: 1px solid #FFD54F; border-radius: 16px; padding: 16px; }
.feedback-inner { display: flex; gap: 12px; align-items: flex-start; }
.feedback-icon { font-size: 24px; flex-shrink: 0; }
.feedback-body h4 { font-size: 15px; font-weight: 700; margin-bottom: 4px; color: var(--ink); }
.feedback-body p { font-size: 13px; color: var(--muted); line-height: 1.6; margin: 0; }

/* 自定义选项卡片 */
.custom-option { border: 2px dashed var(--light); }
.custom-option .check-mark { color: var(--light); }
