:root {
  --bg: #f7f5f2;
  --card: #ffffff;
  --text: #2d2a26;
  --muted: #8a8580;
  --border: #e8e4df;
  --primary: #c9a96e;
  --c1: #e86a56;
  --c2: #f4b23a;
  --c3: #5a9fd4;
  --c4: #d478aa;
  --radius: 18px;
  --shadow: 0 1px 6px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 480px;
  margin: 0 auto;
}

/* 顶部 */
.topbar {
  flex-shrink: 0;
  padding: 14px 16px 10px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.logo { font-size: 15px; font-weight: 700; letter-spacing: 1px; }
.subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }
.map-trigger {
  position: absolute;
  right: 16px;
  top: 14px;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
}

/* 对话区 */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 消息 */
.msg {
  display: flex;
  flex-direction: column;
  max-width: 92%;
  animation: fadeIn .25s ease;
}
.msg.ai { align-self: flex-start; }
.msg.user { align-self: flex-end; align-items: flex-end; }

.bubble {
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.75;
  box-shadow: var(--shadow);
}
.msg.ai .bubble {
  background: var(--card);
  border-bottom-left-radius: 4px;
}
.msg.user .bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* AI 分析卡片 */
.insight-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  font-size: 14px;
  line-height: 1.8;
}
.insight-card .title {
  font-weight: 800;
  font-size: 15px;
  margin-bottom: 10px;
}
.insight-card .soft-label {
  display: inline-flex;
  align-items: center;
  margin: 4px 0 8px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #faf8f5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}
.insight-card .insight-copy {
  color: var(--text);
}
.insight-card .confirmation-box {
  margin-top: 14px;
  padding: 12px 13px;
  border-radius: 14px;
  background: #fffaf0;
  border: 1px solid #ead8b5;
}
.insight-card .confirmation-box .soft-label {
  margin: 0 0 7px;
  background: rgba(201,169,110,.12);
  color: #9a7a3b;
}
.insight-card .confirmation-text {
  font-weight: 800;
  color: var(--text);
  line-height: 1.65;
}
.insight-card .status {
  margin-top: 10px;
  font-size: 12px;
  font-weight: 600;
  color: #4caf50;
}

/* 日记卡片 */
.diary-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  font-size: 14px;
  line-height: 1.9;
}
.diary-card h3 {
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--primary);
}
.diary-card .section {
  margin-bottom: 14px;
}
.diary-card .section-label {
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}
.diary-card .diary-subheading,
.diary-export .diary-subheading {
  display: inline-flex;
  margin: 14px 0 8px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #faf8f5;
  color: #9a7a3b;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.4;
}

/* 完成页 */
.finish-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px 18px;
  box-shadow: var(--shadow);
  text-align: center;
}
.finish-card h2 {
  font-size: 20px;
  margin-bottom: 12px;
}
.finish-card p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.8;
  margin-bottom: 20px;
}

/* 按钮 */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: 24px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}
.btn:active { transform: scale(0.98); }

/* Loading */
.loading {
  text-align: center;
  padding: 16px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--muted);
}
.loading .icon { font-size: 24px; margin-bottom: 8px; }

/* 错误 */
.error {
  padding: 12px;
  background: #fff0f0;
  border-radius: var(--radius);
  color: #c62828;
  font-size: 13px;
}

/* 输入区 */
.inputbar {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 10px 12px 14px;
  background: var(--card);
  border-top: 1px solid var(--border);
}
#input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 15px;
  resize: none;
  outline: none;
  max-height: 120px;
  font-family: inherit;
}
#input:focus { border-color: var(--primary); }
#send {
  padding: 0 18px;
  border: none;
  border-radius: 20px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
#send:disabled {
  background: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}

/* 建档卡片 */
.profile-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  text-align: center;
}
.profile-card h2 {
  font-size: 18px;
  margin-bottom: 8px;
}
.profile-card p {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}
.profile-card input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 15px;
  text-align: center;
  outline: none;
  margin-bottom: 12px;
}
.profile-card input:focus { border-color: var(--primary); }

/* 双按钮组 */
.btn-group {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 12px;
}
.btn-group .btn {
  flex: 1;
  max-width: 160px;
}
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
}

/* 截图用日记卡片 */
.diary-export {
  background: #fff9f0;
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  font-size: 14px;
  line-height: 1.9;
  color: var(--text);
}
.diary-export .export-header {
  text-align: center;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--border);
}
.diary-export .export-header h2 {
  font-size: 18px;
  color: var(--primary);
  margin-bottom: 4px;
}
.diary-export .export-header .export-meta {
  font-size: 11px;
  color: var(--muted);
}
.diary-export .export-section {
  margin-bottom: 14px;
}
.diary-export .export-label {
  font-weight: 700;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.diary-export .export-footer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}

/* 成长地图 */
.map-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.map-panel {
  background: var(--card);
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  border-radius: 24px 24px 0 0;
  padding: 24px 16px 32px;
  overflow-y: auto;
  animation: slideUp .3s ease;
}
.map-panel h2 {
  font-size: 18px;
  margin-bottom: 16px;
  text-align: center;
}
.map-close {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 20px;
  background: none;
  border: none;
  color: var(--muted);
}
.map-item {
  background: var(--bg);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  font-size: 13px;
}
.map-item .map-date {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}
.map-item .map-preview {
  color: var(--text);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.map-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 14px;
}

/* 底部导航 */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 6px 0 20px;
  z-index: 100;
}
.tab-item {
  flex: 1;
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  font-size: 10px;
  padding: 4px 0;
  transition: color .2s;
}
.tab-item.active { color: var(--text); font-weight: 700; position: relative; }
.tab-item.active::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
}
.tab-item .tab-icon { font-size: 22px; margin-bottom: 2px; }
.tab-item .tab-label { font-size: 10px; }

/* 下载提示 */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #2d2a26;
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 13px;
  z-index: 200;
  animation: fadeIn .2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* ===== 课程页共享样式 ===== */
#app.lesson-page {
  display: block;
  height: auto;
  min-height: 100vh;
  padding: 16px 16px 120px;
}

.breadcrumb {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px;
}
.breadcrumb a {
  color: var(--muted);
  text-decoration: none;
}
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { margin: 0 6px; color: var(--border); }

.lesson-hero { margin-bottom: 24px; }
.lesson-hero h1 {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 12px;
  color: var(--text);
}
.lesson-hero .meta { font-size: 13px; color: var(--muted); }
.lesson-hero .meta .tag {
  display: inline-block;
  background: var(--bg);
  border-radius: 10px;
  padding: 4px 10px;
  font-size: 12px;
  margin-right: 6px;
}

.lesson-video {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border-radius: var(--radius);
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  margin-bottom: 28px;
}

.lesson-content {
  font-size: 14px;
  line-height: 1.85;
  color: var(--text);
  margin-bottom: 48px;
}
.lesson-content h3 {
  font-size: 17px;
  font-weight: 700;
  margin: 24px 0 12px;
  color: var(--text);
}
.lesson-content p { margin-bottom: 16px; }
.lesson-content ul { padding-left: 20px; margin-bottom: 16px; }
.lesson-content li { margin-bottom: 10px; }

.lesson-content .type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}
.lesson-content .type-cell {
  padding: 18px 14px;
  border-radius: 12px;
  text-align: center;
  background: var(--bg);
}
.lesson-content .type-cell .num { font-size: 20px; font-weight: 800; margin-bottom: 6px; }
.lesson-content .type-cell .name { font-size: 13px; font-weight: 600; }
.lesson-content .type-cell .desc { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.6; }

.lesson-content .energy-card,
.lesson-content .nourish-card,
.lesson-content .wither-card {
  background: var(--bg);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 14px;
  border-left: 3px solid var(--primary);
}
.lesson-content .nourish-card { border-left-color: #27ae60; background: #f0f9f4; }
.lesson-content .wither-card { border-left-color: #e74c3c; background: #fff5f5; }
.lesson-content .energy-card h4,
.lesson-content .nourish-card h4,
.lesson-content .wither-card h4 { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.lesson-content .nourish-card h4 { color: #27ae60; }
.lesson-content .wither-card h4 { color: #e74c3c; }
.lesson-content .energy-card p,
.lesson-content .nourish-card p,
.lesson-content .wither-card p { font-size: 13px; line-height: 1.8; color: var(--muted); margin-bottom: 4px; }

.lesson-nav-static {
  display: flex;
  gap: 10px;
  padding: 24px 0 0;
  margin-top: 64px;
  border-top: 1px solid var(--border);
}
.lesson-nav-static a,
.lesson-nav-static .nav-placeholder {
  flex: 1;
  text-align: center;
  padding: 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.lesson-nav-static .btn-primary { background: var(--text); color: #fff; }
.lesson-nav-static .btn-secondary { background: var(--bg); color: var(--text); border: 1.5px solid var(--border); }


@media (min-width: 768px) {
  #app { max-width: 1200px; width: 100%; }
  .tab-bar { max-width: 1200px; }
}
