/* ===== 设计系统 - 温馨简约风 ===== */
:root {
  /* 主色调 - 温暖的奶油色系 */
  --primary: #FF9A8B;
  --primary-light: #FFE5E0;
  --primary-dark: #E87A6B;

  /* 辅助色 */
  --success: #7DD3C0;
  --success-light: #E0F5F0;
  --danger: #FF8B94;
  --danger-light: #FFE5E7;
  --warning: #FFD89C;
  --warning-light: #FFF5E0;

  /* 中性色 */
  --bg: #FFF9F5;
  --card: #FFFFFF;
  --surface: #FEF6F0;
  --text: #4A4A4A;
  --text-secondary: #8B8680;
  --text-light: #B5B0AA;
  --border: #F0E8E0;

  /* 阴影 */
  --shadow-sm: 0 2px 8px rgba(139, 134, 128, 0.08);
  --shadow-md: 0 4px 16px rgba(139, 134, 128, 0.12);
  --shadow-lg: 0 8px 32px rgba(139, 134, 128, 0.16);

  /* 圆角 */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  /* 间距 */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
}

/* 深色模式 */
[data-theme="dark"] {
  --primary: #FF9A8B;
  --primary-light: rgba(255, 154, 139, 0.15);
  --primary-dark: #FFB0A4;

  --success: #7DD3C0;
  --success-light: rgba(125, 211, 192, 0.15);
  --danger: #FF8B94;
  --danger-light: rgba(255, 139, 148, 0.15);
  --warning: #FFD89C;
  --warning-light: rgba(255, 216, 156, 0.15);

  --bg: #1A1A2E;
  --card: #252540;
  --surface: #2A2A45;
  --text: #E8E6E3;
  --text-secondary: #A0A0B8;
  --text-light: #6E6E85;
  --border: #3A3A55;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
}

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== 登录页 ===== */
.login-page {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--bg) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  z-index: 1000;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.login-page.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.95);
}

.login-logo {
  width: 120px;
  height: 120px;
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 32px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.login-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.login-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 48px;
  text-align: center;
  line-height: 1.6;
}

.login-btn {
  width: 100%;
  max-width: 280px;
  padding: 16px 32px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all 0.3s ease;
}

.login-btn:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-sm);
}

.login-features {
  display: flex;
  gap: 32px;
  margin-top: 48px;
}

.login-feature {
  text-align: center;
}

.login-feature-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.login-feature-text {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ===== 主容器 - 手机尺寸 ===== */
.app-container {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  background: var(--bg);
}

/* ===== 头部 ===== */
.header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 44px 20px 20px;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  position: relative;
  overflow: hidden;
}

.header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 200px;
  height: 200px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.header-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.2);
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.header-user:active {
  background: rgba(255,255,255,0.3);
}

.header-user-icon {
  font-size: 18px;
}

.points-display {
  display: flex;
  justify-content: space-around;
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-lg);
  padding: 14px 12px;
  backdrop-filter: blur(10px);
}

.points-item { 
  text-align: center; 
}

.points-item .num { 
  font-size: 26px; 
  font-weight: 700;
  margin-bottom: 2px;
}

.points-item .label { 
  font-size: 11px; 
  opacity: 0.9;
  font-weight: 500;
}

/* ===== Tab 导航 ===== */
.tab-nav {
  display: flex;
  background: var(--card);
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 398px;
  z-index: 100;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
}

/* iOS 安全区域适配 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .tab-nav {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

.tab-btn {
  flex: 1;
  padding: 12px 0;
  text-align: center;
  border: none;
  background: none;
  color: var(--text-light);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-lg);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.tab-btn-icon {
  font-size: 20px;
}

.tab-btn.active {
  color: var(--primary);
  background: var(--primary-light);
}

.tab-btn-center {
  width: 48px;
  height: 48px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  transition: transform 0.2s ease;
  margin-top: 12px;
}

.tab-btn-center:active {
  transform: scale(0.95);
}

.tab-btn-center-inner {
  font-size: 28px;
  font-weight: 300;
  color: white;
}

/* ===== Tab 内容 ===== */
.tab-content { 
  display: none; 
  padding: 20px 16px 120px;
}

.tab-content.active { 
  display: block; 
}

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

.card-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title-icon {
  font-size: 20px;
}

/* ===== 按钮 ===== */
.btn {
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  box-shadow: var(--shadow-sm);
}

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

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-success {
  background: linear-gradient(135deg, var(--success) 0%, #5BC0A8 100%);
  color: white;
}

.task-filter-btn {
  flex: 1;
  padding: 10px 8px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  background: var(--surface);
  color: var(--text-secondary);
}

.task-filter-btn.active {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, #E86B75 100%);
  color: white;
}

.btn-block {
  width: 100%;
}

/* ===== 表单 ===== */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 15px;
  background: var(--surface);
  color: var(--text);
  transition: all 0.3s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--card);
}

/* ===== 打卡区域 ===== */
.checkin-section {
  text-align: center;
}

.emoji-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 16px 0;
  flex-wrap: wrap;
}

.emoji-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  max-width: 70px;
}

.emoji-btn {
  width: 100%;
  max-width: 56px;
  height: 56px;
  font-size: 28px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.emoji-btn:hover, .emoji-btn.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: scale(1.05);
}

.emoji-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* 压力 */
.stress-section {
  margin: 20px 0;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius-md);
}

.stress-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: block;
  font-weight: 500;
}

.stress-slider-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stress-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, var(--success), var(--warning), var(--danger));
}

.stress-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--primary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.stress-value {
  min-width: 40px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

/* ===== 任务列表 ===== */
.task-item {
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--primary);
  cursor: pointer;
  transition: all 0.3s ease;
}

.task-item:active {
  transform: scale(0.98);
}

.task-item.completed {
  border-left-color: var(--success);
  opacity: 0.8;
}

.task-item.expired {
  border-left-color: var(--danger);
  opacity: 0.7;
}

.task-item.urgent {
  border-left-color: var(--warning);
  background: linear-gradient(135deg, var(--card) 0%, var(--warning-light) 100%);
}

.task-item.urgent .task-meta {
  color: #C4850A;
  font-weight: 500;
}

.task-item.urgent .deadline-badge {
  background: var(--warning);
  color: white;
  animation: urgentPulse 2s ease-in-out infinite;
}

@keyframes urgentPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.deadline-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.deadline-badge.urgent-badge {
  background: var(--warning);
  color: white;
}

.deadline-badge.normal-badge {
  background: var(--surface);
  color: var(--text-secondary);
}

.deadline-badge.expired-badge {
  background: var(--danger-light);
  color: #C45A62;
}

/* 任务日期分组标题 */
.task-date-group {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 12px 4px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.task-date-group::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.task-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.task-meta {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.task-points {
  float: right;
  font-size: 14px;
  font-weight: 700;
  color: var(--success);
}

.task-points.task-penalty {
  color: var(--danger);
}

/* 标签 */
.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.tag-primary {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.tag-success {
  background: var(--success-light);
  color: #2D8A6E;
}

.tag-danger {
  background: var(--danger-light);
  color: #C45A62;
}

/* ===== 任务筛选 Tab ===== */
.filter-tabs {
  display: flex;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 6px;
  gap: 4px;
}

.filter-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.3s ease;
  color: var(--text-secondary);
}

.filter-tab-icon {
  font-size: 20px;
  opacity: 0.7;
}

.filter-tab-text {
  font-size: 12px;
  font-weight: 500;
}

.filter-tab-count {
  font-size: 10px;
  background: var(--border);
  color: var(--text-secondary);
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.filter-tab.active {
  background: var(--card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.filter-tab.active .filter-tab-icon {
  opacity: 1;
}

.filter-tab.active .filter-tab-count {
  background: var(--primary);
  color: white;
}

/* ===== 日历 ===== */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(auto-fill, minmax(70px, 1fr));
  gap: 6px;
}

.calendar-weekday {
  text-align: center;
  font-size: 12px;
  color: var(--text-light);
  padding: 8px 0;
  font-weight: 500;
}

.calendar-day {
  min-height: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 6px 2px 4px;
  gap: 2px;
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.calendar-day.empty { 
  background: none; 
  cursor: default;
  min-height: 0;
}

.calendar-day.today { 
  background: var(--primary-light);
  font-weight: 700;
}

.calendar-day .day-number { 
  font-size: 14px;
  line-height: 1.2;
}

.calendar-day .emoji { 
  font-size: 18px;
  line-height: 1;
}

.calendar-day .day-points {
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  margin-top: auto;
}

.calendar-day.bg-earn { background: var(--success-light); }
.calendar-day.bg-deduct { background: var(--danger-light); }
.calendar-day.bg-mixed { background: #F0E8FF; }
.calendar-day.bg-checkin-only { background: var(--warning-light); }

.calendar-day.bg-earn .day-points { color: #2D8A6E; }
.calendar-day.bg-deduct .day-points { color: #C45A62; }
.calendar-day.bg-mixed .day-points { color: #7B68EE; }

/* ===== 弹窗 ===== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--card);
  width: 100%;
  max-width: 430px;
  max-height: 85vh;
  border-radius: var(--radius-xl);
  padding: 24px;
  overflow-y: auto;
  overflow-x: hidden;
  animation: fadeIn 0.25s ease;
  scrollbar-gutter: stable;
}

.modal-content::-webkit-scrollbar {
  width: 4px;
}
.modal-content::-webkit-scrollbar-track {
  background: transparent;
  margin: 4px;
}
.modal-content::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.15);
  border-radius: 4px;
}
.modal-content::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.25);
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  font-size: 24px;
  color: var(--text-light);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.modal-close:hover {
  background: var(--surface);
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-light);
}

.empty-state .icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 15px;
}

/* ===== 浮动按钮 ===== */
.fab {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 28px;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

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

/* ===== 已打卡状态 ===== */
.checked-in-card {
  background: linear-gradient(135deg, var(--success-light) 0%, var(--success) 20%);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  color: #2D8A6E;
}

.checked-in-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.checked-in-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
}

.checked-in-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px 24px;
  margin-bottom: 16px;
}

.checked-in-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
}

.checked-in-stat-value {
  font-size: 28px;
  font-weight: 700;
}

.checked-in-stat-label {
  font-size: 12px;
  opacity: 0.8;
  white-space: nowrap;
}

/* ===== 加载动画 ===== */
.loading {
  text-align: center;
  padding: 48px;
  color: var(--text-light);
}

.loading::after {
  content: '';
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== 响应式 ===== */
@media (min-width: 431px) {
  body {
    background: #E8E4E0;
  }
  
  .app-container {
    box-shadow: 0 0 40px rgba(0,0,0,0.1);
  }
}

/* ===== 新手引导 ===== */
.guide-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9999;
  pointer-events: auto;
}
.guide-backdrop {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.65);
}
.guide-highlight {
  position: absolute;
  z-index: 2;
  border-radius: 12px;
  box-shadow: 0 0 0 4px rgba(255,255,255,0.85), 0 0 20px rgba(255,255,255,0.3);
  transition: all 0.4s ease;
}
.guide-tooltip {
  position: absolute;
  z-index: 3;
  background: white;
  border-radius: 16px;
  padding: 20px;
  max-width: 260px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  text-align: center;
  transition: all 0.4s ease;
}
.guide-tooltip::after {
  content: '';
  position: absolute;
  width: 12px; height: 12px;
  background: white;
  transform: rotate(45deg);
  left: calc(50% + var(--arrow-offset, 0px));
  margin-left: -6px;
}
.guide-tooltip.arrow-top::after {
  top: -6px;
}
.guide-tooltip.arrow-bottom::after {
  bottom: -6px;
}
.guide-tooltip.arrow-left::after {
  left: auto;
  right: -6px;
  top: calc(50% + var(--arrow-offset, 0px));
  margin-left: 0;
  margin-top: -6px;
}
.guide-tooltip.arrow-right::after {
  left: -6px;
  top: calc(50% + var(--arrow-offset, 0px));
  margin-left: 0;
  margin-top: -6px;
}
.guide-title {
  font-size: 16px; font-weight: 700; color: #333; margin-bottom: 8px;
}
.guide-desc {
  font-size: 14px; color: #666; line-height: 1.6; margin-bottom: 16px;
}
.guide-actions {
  display: flex; align-items: center; justify-content: space-between;
}
.guide-skip {
  font-size: 13px; color: #999; cursor: pointer; background: none; border: none; padding: 4px 8px;
}
.guide-skip:hover { color: #666; }
.guide-dots {
  display: flex; gap: 6px;
}
.guide-dot {
  width: 6px; height: 6px; border-radius: 50%; background: #ddd; transition: all 0.3s;
}
.guide-dot.active {
  background: var(--primary); width: 18px; border-radius: 3px;
}
.guide-next {
  font-size: 14px; font-weight: 600; color: white; background: var(--primary);
  border: none; border-radius: 20px; padding: 8px 20px; cursor: pointer;
  transition: opacity 0.2s;
}
.guide-next:hover { opacity: 0.85; }
