/* ========================================
   base.css - 全局重置 + CSS 变量
   ======================================== */

:root {
  /* 浅绿色系 */
  --accent: #7CB98E;
  --accent-light: #A8D5B2;
  --accent-dark: #5A9E6C;

  /* 状态色 */
  --danger: #E87373;
  --warning: #E8B973;
  --success: #73C8A0;

  /* 中性色（浅色模式默认值，会被 light.css 覆盖） */
  --bg: #E8EDE9;
  --bg-secondary: #DDE3DD;
  --card-bg: #E8EDE9;
  --text-primary: #2C3E2D;
  --text-secondary: #6B7D6C;
  --text-muted: #9AAD9B;
  --shadow-light: #FFFFFF;
  --shadow-dark: #C5CC C5;
  --border: rgba(0,0,0,0.06);

  /* 尺寸 */
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --nav-height: 64px;
  --top-bar-height: 48px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* 过渡 */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg);
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* 顶部栏 */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--top-bar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  background: var(--bg);
  transition: background-color var(--transition-normal);
}

.top-bar-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background var(--transition-fast);
  color: var(--text-secondary);
}

.theme-toggle:active {
  background: var(--border);
}

.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* 页面容器 */
.page-container {
  position: fixed;
  top: var(--top-bar-height);
  left: 0;
  right: 0;
  bottom: calc(var(--nav-height) + var(--safe-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 16px;
  padding-bottom: 16px;
}

.page {
  display: none;
  height: 100%;
  animation: fadeIn 0.2s ease;
}

.page.active {
  display: block;
}

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

/* 底部导航 */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  background: var(--bg);
  border-top: 1px solid var(--border);
  z-index: 100;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 10px;
  cursor: pointer;
  padding: 6px 0;
  transition: color var(--transition-fast), transform var(--transition-fast);
}

.nav-item:active {
  transform: scale(0.92);
}

.nav-item.active {
  color: var(--accent);
}

.nav-item svg {
  width: 22px;
  height: 22px;
}

/* 添加按钮 */
.add-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 22px;
  line-height: 36px;
  text-align: center;
  cursor: pointer;
  margin: 12px auto;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

/* 浮动添加按钮 - 右下角 */
.float-add-btn {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 20px);
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 28px;
  line-height: 48px;
  text-align: center;
  cursor: grab;
  z-index: 90;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  user-select: none;
  touch-action: none;
  transition: transform 0.15s ease;
}

.float-add-btn:active {
  cursor: grabbing;
  transform: scale(0.92);
}

.add-btn:active {
  transform: scale(0.9);
}

/* 分类滚动条 */
.category-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 12px 0;
  scrollbar-width: none;
}

.category-scroll::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  border: none;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chip:active {
  transform: scale(0.95);
}

.chip-active {
  background: var(--accent);
  color: white;
}

/* 弹窗 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: overlayIn 0.2s ease;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 20px 16px calc(20px + var(--safe-bottom));
  animation: modalSlideUp 0.25s ease;
}

@keyframes modalSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-content h3 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 16px;
}

.modal-content label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  margin-top: 14px;
}

.modal-content input,
.modal-content textarea,
.modal-content select {
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: box-shadow var(--transition-fast);
}

.modal-content textarea {
  min-height: 120px;
  resize: vertical;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal-actions button {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.modal-actions button:active {
  opacity: 0.7;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* 加载状态 */
.loading {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
}

/* 日历 */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.cal-nav {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  border-radius: 50%;
}

.cal-nav:active {
  background: var(--border);
}

.cal-title {
  font-size: 15px;
  font-weight: 600;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 16px;
}

.cal-day-header {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 0;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 13px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-primary);
  transition: all var(--transition-fast);
  position: relative;
}

.cal-day:active {
  transform: scale(0.9);
}

.cal-day.today {
  font-weight: 600;
  border: 2px solid var(--accent);
}

.cal-day.has-record::after {
  content: '';
  position: absolute;
  bottom: 2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--danger);
}

.cal-day.selected {
  background: var(--accent);
  color: white;
}

.period-summary {
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
}
/* 日记页 tab 切换 */
.diary-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.diary-tab {
  flex: 1;
  padding: 6px 0;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.diary-tab:active {
  transform: scale(0.96);
}

.diary-tab.active {
  background: var(--accent);
  color: white;
}

.diary-list-container {
  min-height: 200px;
}
/* 顶部栏右侧 */
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 分类管理按钮 */
.category-manage {
  display: flex;
  justify-content: flex-end;
  padding: 4px 0 8px;
}

.manage-icon {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  border-radius: 50%;
}

/* 日记列表容器 */
.diary-list-container {
  margin-bottom: 8px;
}

/* 纪念卡片 */
.meme-card {
  text-align: center;
  padding: 20px 16px;
  margin-bottom: 12px;
}

.meme-card .meme-days {
  font-size: 42px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}

.meme-card .meme-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 500;
}

.meme-card .meme-detail {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* 个人中心 */
.profile-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 0;
  margin-bottom: 20px;
}

.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.profile-info {
  flex: 1;
}

.profile-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.profile-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.stat-card {
  text-align: center;
  padding: 12px 4px;
}

.stat-num {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.profile-menu {
  border-radius: var(--radius);
  overflow: hidden;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card-bg);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.menu-item:active {
  background: var(--bg-secondary);
}

.menu-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.menu-text {
  flex: 1;
  font-size: 14px;
  color: var(--text-primary);
}

.menu-arrow {
  color: var(--text-muted);
  font-size: 14px;
}

/* 分类管理弹窗 */
.cat-list {
  margin: 8px 0;
}

.cat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  background: var(--bg-secondary);
}

.cat-item .cat-name {
  flex: 1;
  font-size: 14px;
  color: var(--text-primary);
}

.cat-item .cat-delete {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font-size: 16px;
  border-radius: 50%;
}

.cat-add-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.cat-add-row input {
  flex: 1;
}

.cat-add-row button {
  padding: 8px 16px;
}
/* 纪念卡片基础 */
.meme-card {
  padding: 20px 16px;
  margin-bottom: 12px;
  background: var(--card-bg);
  border-radius: var(--radius);
  transition: transform var(--transition-fast);
}

.meme-card:active {
  transform: scale(0.98);
}

.meme-card .meme-days {
  font-size: 42px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}

.meme-card .meme-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 500;
}

.meme-card .meme-detail {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}