:root {
  --bg: #fdf6f0;
  --card: #ffffff;
  --text: #4a3f35;
  --muted: #a89a8c;
  --primary: #ff8f6b;
  --primary-strong: #f2703f;
  --primary-soft: #ffe6db;
  --accent: #f7c873;
  --green: #6fbf8f;
  --danger: #e06c5f;
  --shadow: 0 6px 20px rgba(180, 140, 110, 0.12);
  --radius: 18px;
  --cell-empty: #f1e7dc;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 86px;
  line-height: 1.5;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  background: linear-gradient(180deg, var(--bg) 70%, rgba(253, 246, 240, 0));
}

.brand {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.icon-btn {
  border: none;
  background: var(--card);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 17px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

/* ---------- 页面与标签 ---------- */
.tab {
  display: none;
  padding: 4px 16px 20px;
  animation: fadeIn 0.25s ease;
}

.tab.active {
  display: block;
}

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

.hidden {
  display: none !important;
}

h2 {
  font-size: 18px;
  margin: 8px 0 12px;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

.card-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 10px;
}

/* ---------- 首页 ---------- */
.greeting {
  margin: 6px 4px 14px;
}

.greet-line {
  font-size: 24px;
  font-weight: 700;
}

.date-line {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.miss-card {
  background: #fff7e8;
  border: 1px solid #f3dfb4;
  color: #9a7b3f;
  font-size: 14px;
  padding: 12px 16px;
}

.note-card {
  background: linear-gradient(135deg, #fff5f1, #ffede4);
  border: 1px solid #ffd9c8;
}

.note-label {
  font-size: 13px;
  color: var(--primary-strong);
  font-weight: 700;
  margin-bottom: 4px;
}

.note-text {
  font-size: 15px;
  white-space: pre-wrap;
}

.goal-card {
  display: flex;
  align-items: center;
  gap: 18px;
  background: linear-gradient(135deg, #ffb199, #ff8f6b);
  border-radius: 22px;
  padding: 18px;
  color: #fff;
  box-shadow: 0 10px 24px rgba(242, 112, 63, 0.28);
  margin-bottom: 14px;
}

.goal-ring-wrap {
  position: relative;
  width: 104px;
  height: 104px;
  flex-shrink: 0;
}

.goal-ring {
  width: 104px;
  height: 104px;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.3);
  stroke-width: 9;
}

.ring-fg {
  fill: none;
  stroke: #fff;
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 0.6s ease;
}

.goal-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.goal-ring-center span {
  font-size: 21px;
  font-weight: 800;
}

.goal-ring-center small {
  font-size: 11px;
  opacity: 0.85;
}

.goal-nums {
  font-size: 20px;
  font-weight: 800;
}

.goal-sub {
  font-size: 13px;
  opacity: 0.9;
  margin-top: 4px;
}

/* ---------- 苹果日历 ---------- */
.cal-card {
  background: linear-gradient(135deg, #f2f7ff, #e8f0fd);
  border: 1px solid #d9e8ff;
}

.cal-title {
  font-weight: 700;
  color: #3d6fb4;
  margin-bottom: 4px;
}

.cal-desc {
  font-size: 13px;
  color: #5f7ba3;
  margin-bottom: 10px;
}

.cal-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
  line-height: 1.7;
}

/* ---------- 打卡表单 ---------- */
.form-card label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 12px;
}

.form-card input,
.form-card select,
.form-card textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 11px 12px;
  border: 1.5px solid #f0e3d8;
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: #fffdfb;
  outline: none;
  transition: border-color 0.15s;
}

.form-card input:focus,
.form-card select:focus,
.form-card textarea:focus {
  border-color: var(--primary);
}

.form-card textarea {
  resize: vertical;
}

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.primary-btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 13px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  background: linear-gradient(135deg, #ff9a76, var(--primary-strong));
  box-shadow: 0 6px 16px rgba(242, 112, 63, 0.32);
  cursor: pointer;
}

.primary-btn:active {
  transform: scale(0.98);
}

.ghost-btn,
.danger-btn,
.small-btn {
  border: 1.5px solid #f0e3d8;
  background: #fff;
  border-radius: 12px;
  padding: 9px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
}

.danger-btn {
  border-color: #f6d4cf;
  color: var(--danger);
  background: #fff7f5;
}

.small-btn {
  border-color: var(--primary);
  color: var(--primary-strong);
  background: var(--primary-soft);
  font-weight: 700;
  padding: 7px 12px;
  font-size: 13px;
}

/* ---------- 打卡完成 ---------- */
.done-card {
  text-align: center;
  padding: 24px 16px;
}

.done-emoji {
  font-size: 42px;
}

.done-title {
  font-size: 18px;
  font-weight: 800;
  margin: 6px 0;
}

.done-detail {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 14px;
  white-space: pre-wrap;
}

.praise-card {
  background: linear-gradient(135deg, #fff9ef, #fff1d6);
  border: 1px solid #f5e0ae;
  text-align: center;
  animation: popIn 0.4s ease;
}

.praise-emoji {
  font-size: 28px;
  margin-bottom: 4px;
}

.praise-text {
  font-size: 15px;
  font-weight: 600;
  color: #9a7b3f;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

/* ---------- 统计 ---------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 8px;
  text-align: center;
}

.stat-num {
  font-size: 24px;
  font-weight: 800;
  color: var(--primary-strong);
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* ---------- 书单 ---------- */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 12px;
}

.section-head h2 {
  margin: 0;
}

.book-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.book-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  cursor: pointer;
}

.book-cover {
  width: 52px;
  height: 68px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.book-info {
  flex: 1;
  min-width: 0;
}

.book-title {
  font-weight: 700;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-meta {
  font-size: 12px;
  color: var(--muted);
  margin: 2px 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-track {
  height: 8px;
  border-radius: 6px;
  background: #f3ebe2;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #ffb199, var(--primary));
  transition: width 0.4s ease;
}

.book-progress-text {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.book-finished {
  font-size: 12px;
  color: var(--green);
  font-weight: 700;
}

.empty-tip {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 36px 0;
}

/* ---------- 记录 ---------- */
.heatmap-card {
  padding: 16px;
  overflow-x: auto;
}

.heatmap {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 12px);
  gap: 4px;
  min-width: 340px;
}

.cell {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--cell-empty);
}

.cell-1 { background: #ffe2d2; }
.cell-2 { background: #ffb199; }
.cell-3 { background: var(--primary-strong); }
.cell.today { outline: 2px solid var(--accent); outline-offset: 1px; }

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  font-size: 11px;
  color: var(--muted);
  justify-content: flex-end;
}

.record-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.record-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px 16px;
}

.record-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.record-date {
  font-weight: 700;
  font-size: 14px;
}

.record-date small {
  color: var(--muted);
  font-weight: 400;
  margin-left: 6px;
}

.record-nums {
  font-size: 12px;
  color: var(--primary-strong);
  background: var(--primary-soft);
  padding: 3px 9px;
  border-radius: 20px;
  font-weight: 700;
}

.record-book {
  font-size: 12px;
  color: var(--muted);
}

.record-note {
  font-size: 13px;
  margin-top: 4px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- 设置 ---------- */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
}

.switch-row input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--primary-strong);
}

.hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: -6px;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.about {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
  padding: 10px 0 20px;
}

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border-top: 1px solid #f3e9df;
  padding: 8px 6px max(8px, env(safe-area-inset-bottom));
  z-index: 30;
}

.tab-btn {
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 0;
}

.tab-btn.active {
  color: var(--primary-strong);
  font-weight: 700;
}

.tab-emoji {
  font-size: 20px;
  filter: grayscale(1);
  opacity: 0.6;
  transition: all 0.2s;
}

.tab-btn.active .tab-emoji {
  filter: none;
  opacity: 1;
}

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(74, 63, 53, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  background: #fff;
  width: 100%;
  max-width: 480px;
  border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.12);
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0.6; }
  to { transform: none; opacity: 1; }
}

.modal-card h3 {
  margin-bottom: 14px;
  font-size: 18px;
}

.modal-card label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 12px;
}

.modal-card input {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 11px 12px;
  border: 1.5px solid #f0e3d8;
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: #fffdfb;
  outline: none;
}

.modal-card input:focus {
  border-color: var(--primary);
}

.emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 5px 0 14px;
}

.emoji-picker button {
  width: 42px;
  height: 42px;
  font-size: 22px;
  border: 1.5px solid #f0e3d8;
  border-radius: 12px;
  background: #fffdfb;
  cursor: pointer;
}

.emoji-picker button.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.modal-actions .spacer {
  flex: 1;
}

.modal-actions .primary-btn {
  width: auto;
  padding: 10px 22px;
}

/* ---------- Toast / 彩纸 ---------- */
.toast {
  position: fixed;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(74, 63, 53, 0.92);
  color: #fff;
  font-size: 13px;
  padding: 9px 18px;
  border-radius: 30px;
  z-index: 80;
  animation: popIn 0.3s ease;
  max-width: 86%;
  text-align: center;
}

.confetti {
  position: fixed;
  top: -16px;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  z-index: 90;
  animation: confetti-fall linear forwards;
  pointer-events: none;
}

@keyframes confetti-fall {
  to {
    transform: translateY(108vh) rotate(720deg);
    opacity: 0;
  }
}

@media (min-width: 481px) {
  .modal {
    align-items: center;
  }

  .modal-card {
    border-radius: 22px;
  }
}
