/* ============ 变量与基础 ============ */
:root {
  --cream: #fffaf6;
  --cream-2: #fff3ec;
  --rose: #e8607a;
  --rose-light: #ffb4c6;
  --coral: #ff8a65;
  --plum: #4a2c3d;
  --plum-soft: #7a5a68;
  --sage: #7fb685;
  --sage-light: #d7ecd9;
  --gold: #f0a868;
  --line: #f1e2e0;
  --shadow: 0 8px 24px rgba(200, 100, 120, 0.12);
  --shadow-sm: 0 2px 10px rgba(200, 100, 120, 0.08);
  --radius: 20px;
  --radius-sm: 14px;
  --ease: cubic-bezier(.34, 1.56, .64, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(160deg, var(--cream) 0%, var(--cream-2) 100%);
  color: var(--plum);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: Georgia, "Noto Serif SC", serif; margin: 0; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select {
  font-family: inherit; font-size: 15px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; background: #fff; color: var(--plum);
  width: 100%; transition: border-color .2s, box-shadow .2s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--rose-light);
  box-shadow: 0 0 0 3px rgba(232, 96, 122, 0.12);
}
textarea { resize: vertical; }

/* ============ 鉴权界面 ============ */
.auth-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 20% 20%, #ffe3ea 0%, transparent 45%),
              radial-gradient(circle at 80% 80%, #ffe9d6 0%, transparent 45%),
              var(--cream);
}
.auth-card {
  width: 100%; max-width: 380px; background: #fff;
  border-radius: 28px; padding: 36px 30px; box-shadow: var(--shadow);
  animation: rise .5s var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.brand { text-align: center; margin-bottom: 28px; }
.brand-bloom { font-size: 44px; animation: bloom 2.4s ease-in-out infinite; }
@keyframes bloom { 0%, 100% { transform: scale(1) rotate(0deg); } 50% { transform: scale(1.08) rotate(-4deg); } }
.brand h1 { font-size: 28px; color: var(--rose); margin-top: 6px; }
.brand-sub { color: var(--plum-soft); font-size: 13px; margin-top: 4px; }
.auth-form { display: none; flex-direction: column; gap: 12px; }
.auth-form.active { display: flex; }
.auth-form h2 { font-size: 18px; text-align: center; margin-bottom: 4px; }
.auth-hint { font-size: 12px; color: var(--plum-soft); text-align: center; margin: 0 0 6px; }
.auth-error { color: #d92d4c; font-size: 13px; min-height: 16px; display: none; }
.auth-error.show { display: block; }
.auth-success { color: var(--sage); font-size: 13px; min-height: 16px; display: none; }
.auth-success.show { display: block; }
.btn-link {
  background: none; border: none; color: var(--rose); font-size: 13px;
  text-decoration: underline; padding: 4px; align-self: center;
}
.btn-link:hover { color: var(--coral); }

/* ============ 按钮 ============ */
.btn-primary {
  background: linear-gradient(135deg, var(--rose) 0%, var(--coral) 100%);
  color: #fff; border: none; border-radius: var(--radius-sm);
  padding: 13px 20px; font-size: 15px; font-weight: 600;
  box-shadow: 0 6px 16px rgba(232, 96, 122, 0.32);
  transition: transform .15s var(--ease), box-shadow .15s;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(232, 96, 122, 0.4); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn-ghost {
  background: transparent; border: 1px solid var(--line); color: var(--plum-soft);
  border-radius: var(--radius-sm); padding: 10px 16px; font-size: 14px;
  transition: background .15s, border-color .15s;
}
.btn-ghost:hover { background: var(--cream-2); border-color: var(--rose-light); }
.btn-small {
  background: var(--sage-light); color: #2f5c38; border: none;
  border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 600;
  transition: background .15s, transform .15s;
}
.btn-small:hover { background: #c4e4c9; transform: translateY(-1px); }
.btn-danger {
  background: #fde4e8; color: #c62842; border: none;
  border-radius: var(--radius-sm); padding: 10px 16px; font-size: 14px;
}
.btn-danger:hover { background: #fbc9d1; }

/* ============ 应用外壳 ============ */
.app { min-height: 100vh; padding-bottom: 76px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; background: rgba(255, 250, 246, 0.9);
  backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 10;
  border-bottom: 1px solid var(--line);
}
.brand-mini { font-family: Georgia, serif; font-size: 20px; color: var(--rose); font-weight: 700; }
.nav-desktop { display: none; gap: 6px; }
.nav-desktop .nav-btn {
  background: transparent; border: none; padding: 9px 16px; border-radius: 999px;
  font-size: 14px; color: var(--plum-soft); transition: background .15s, color .15s;
}
.nav-desktop .nav-btn.active { background: var(--rose); color: #fff; }
.nav-desktop .nav-btn:hover:not(.active) { background: var(--cream-2); }

.main { max-width: 760px; margin: 0 auto; padding: 20px 16px 40px; }
.section { display: none; animation: fadeIn .35s var(--ease); }
.section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.section-title { font-size: 22px; margin-bottom: 16px; color: var(--plum); display: flex; align-items: baseline; gap: 10px; }
.section-date { font-size: 13px; color: var(--plum-soft); font-family: -apple-system, sans-serif; }

/* ============ 卡片 ============ */
.card {
  background: #fff; border-radius: var(--radius); padding: 18px 20px;
  margin-bottom: 16px; box-shadow: var(--shadow-sm);
  transition: box-shadow .2s;
}
.card:hover { box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-head h3 { font-size: 16px; color: var(--plum); }

.list { display: flex; flex-direction: column; gap: 8px; }
.empty-hint { color: #c3b2b8; font-size: 13px; padding: 12px 0; text-align: center; }

/* ============ 列表项（计划 / 待办） ============ */
.item-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: var(--radius-sm); background: var(--cream-2);
  transition: background .15s, transform .15s;
}
.item-row:hover { background: #ffe9ec; transform: translateX(2px); }
.item-row.done { opacity: .55; }
.item-row.overdue { background: #ffe1e6; }
.item-title { flex: 1; font-size: 14px; }
.item-title.done { text-decoration: line-through; }
.item-meta { font-size: 12px; color: var(--plum-soft); }
.item-check {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--rose-light);
  background: #fff; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #fff; transition: background .2s, border-color .2s;
}
.item-check.checked { background: var(--sage); border-color: var(--sage); }
.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--sage-light); color: #2f5c38;
}
.badge.status-doing { background: #ffe6c2; color: #8a5a00; }
.badge.status-undone { background: #ffd6dc; color: #b0293f; }
.badge.status-done { background: var(--sage-light); color: #2f5c38; }
.badge.status-pending { background: #eee0f0; color: #6a3d80; }

/* ============ Tabs / 周期导航 ============ */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 2px; }
.tab {
  background: #fff; border: 1px solid var(--line); color: var(--plum-soft);
  padding: 8px 16px; border-radius: 999px; font-size: 13px; white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.tab.active { background: var(--rose); color: #fff; border-color: var(--rose); }
.period-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 8px;
}
.period-label { font-size: 14px; font-weight: 600; color: var(--plum); }

/* ============ 日记花园 ============ */
.garden-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 16px;
}
.garden-cell {
  aspect-ratio: 1; border-radius: 10px; background: #fff; border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  cursor: pointer; transition: transform .15s var(--ease), box-shadow .15s;
  position: relative;
}
.garden-cell:hover { transform: scale(1.08); box-shadow: var(--shadow-sm); z-index: 2; }
.garden-cell.has-diary { background: linear-gradient(135deg, #ffe3ea, #ffe9d6); }
.garden-cell.today { border: 2px solid var(--rose); }
.garden-cell.empty-day { visibility: hidden; }
.garden-cell .day-num { position: absolute; top: 3px; left: 5px; font-size: 9px; color: var(--plum-soft); }

/* ============ 目标网格 / 进度环 ============ */
.goal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.goal-card {
  background: var(--cream-2); border-radius: var(--radius-sm); padding: 16px;
  text-align: center; cursor: pointer; transition: transform .15s var(--ease), box-shadow .15s;
}
.goal-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-sm); }
.goal-card .goal-title { font-size: 13px; margin-top: 8px; color: var(--plum); font-weight: 600; }
.goal-card .goal-period { font-size: 11px; color: var(--plum-soft); }
.progress-ring circle { transition: stroke-dashoffset 1s var(--ease); }

/* ============ 表单/弹窗 ============ */
.stack-form { display: flex; flex-direction: column; gap: 12px; }
.field-label { font-size: 13px; color: var(--plum-soft); margin-top: 4px; }
.modal-overlay {
  position: fixed; inset: 0; background: rgba(74, 44, 61, 0.35); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal {
  display: none; background: #fff; border-radius: 24px; padding: 24px;
  width: 100%; max-width: 420px; max-height: 88vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(74, 44, 61, 0.3);
  animation: popIn .3s var(--ease);
}
.modal.modal-wide { max-width: 520px; }
.modal.active { display: block; }
@keyframes popIn { from { opacity: 0; transform: scale(.92) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal h3 { font-size: 18px; margin-bottom: 16px; color: var(--rose); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

.mood-picker { display: flex; gap: 8px; justify-content: center; }
.mood-picker button {
  background: var(--cream-2); border: 2px solid transparent; border-radius: 50%;
  width: 44px; height: 44px; font-size: 20px; transition: transform .15s var(--ease), border-color .15s;
}
.mood-picker button.selected { border-color: var(--rose); transform: scale(1.15); }

.tag-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip {
  background: var(--cream-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; font-size: 12px; color: var(--plum-soft); transition: all .15s;
}
.tag-chip.selected { background: var(--sage); color: #fff; border-color: var(--sage); }

.todo-editor-list { display: flex; flex-direction: column; gap: 8px; }
.todo-editor-row { display: flex; gap: 6px; align-items: center; }
.todo-editor-row input[type=text] { flex: 2; }
.todo-editor-row input[type=date] { flex: 1; }
.todo-editor-row .remove-row { background: none; border: none; color: #c62842; font-size: 18px; padding: 4px 8px; }

.goal-timeline { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.goal-timeline-item { font-size: 13px; color: var(--plum-soft); padding: 6px 0; border-bottom: 1px dashed var(--line); }

/* ============ 移动端底部导航 ============ */
.nav-mobile {
  display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: rgba(255, 250, 246, 0.95); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.nav-mobile .nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: none; color: var(--plum-soft); font-size: 11px; padding: 6px 0;
  border-radius: 12px; transition: color .15s, background .15s;
}
.nav-mobile .nav-btn span { font-size: 19px; }
.nav-mobile .nav-btn.active { color: var(--rose); background: var(--cream-2); }

.hint-text { font-size: 12px; color: var(--plum-soft); line-height: 1.7; }

/* ============ Toast ============ */
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--plum); color: #fff; padding: 10px 20px; border-radius: 999px;
  font-size: 13px; z-index: 200; opacity: 0; transition: opacity .25s, transform .25s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ 响应式 ============ */
@media (min-width: 860px) {
  .nav-desktop { display: flex; }
  .nav-mobile { display: none; }
  .app { padding-bottom: 0; }
  .main { max-width: 820px; }
}
