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

:root {
  --primary: #6C63FF;
  --primary-light: #8B85FF;
  --primary-dark: #5A52D5;
  --bg: #F5F5FA;
  --card: #FFFFFF;
  --text: #2D2D3A;
  --text-secondary: #8E8EA0;
  --border: #E8E8EF;
  --success: #4CAF50;
  --warning: #FF9800;
  --danger: #F44336;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 16px;
  --nav-height: 70px;
  --header-height: 60px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: var(--nav-height);
  display: none;
}
.login-screen {
  display: flex;
}

/* ===== 页面切换 ===== */
.page {
  display: none;
  padding: 0 16px 20px;
  animation: fadeIn 0.2s ease;
}
.page.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== 页面头部 ===== */
.page-header {
  padding: 16px 0 12px;
}
.page-header h1 {
  font-size: 24px;
  font-weight: 700;
}
.page-header .greeting {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ===== 统计卡片 ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}
.stat-value .unit {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: 2px;
}

/* ===== 番茄计时器 ===== */
.timer-section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px 16px;
  box-shadow: var(--shadow);
  text-align: center;
  margin-bottom: 16px;
}
.timer-ring {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto 20px;
}
.timer-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.timer-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 8;
}
.timer-progress {
  fill: none;
  stroke: var(--primary);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 565.48;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
}
.timer-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
.timer-time {
  font-size: 42px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.timer-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.timer-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 16px;
}
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 14px 36px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary:active {
  transform: scale(0.95);
  background: var(--primary-dark);
}
.btn-primary.running {
  background: var(--warning);
}
.btn-primary.break {
  background: var(--success);
}
.btn-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-icon:active {
  transform: scale(0.9);
  background: var(--border);
}

.task-select {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}
.task-select select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  max-width: 200px;
}

/* ===== 添加任务 ===== */
.add-task-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.add-task-bar input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  background: var(--card);
  outline: none;
  transition: border-color 0.2s;
}
.add-task-bar input:focus {
  border-color: var(--primary);
}
.btn-add {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: none;
  background: var(--primary);
  color: white;
  font-size: 24px;
  font-weight: 300;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.btn-add:active {
  transform: scale(0.9);
}

/* ===== 任务列表 ===== */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.task-item {
  background: var(--card);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  transition: all 0.2s;
  animation: slideIn 0.2s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}
.task-checkbox {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}
.task-checkbox.checked {
  background: var(--success);
  border-color: var(--success);
}
.task-checkbox.checked::after {
  content: '✓';
  color: white;
  font-size: 14px;
  font-weight: 700;
}
.task-info {
  flex: 1;
  min-width: 0;
}
.task-title {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-item.completed .task-title {
  text-decoration: line-through;
  color: var(--text-secondary);
}
.task-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.task-pomodoros {
  font-size: 12px;
  color: var(--primary);
  background: rgba(108,99,255,0.1);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}
.task-delete {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s;
}
.task-delete:active {
  background: rgba(244,67,54,0.1);
  color: var(--danger);
}

/* ===== 统计页 - 标签 ===== */
.tab-bar {
  display: flex;
  gap: 0;
  background: var(--card);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.tab.active {
  background: var(--primary);
  color: white;
}

/* ===== 图表 ===== */
.chart-section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.chart-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}
.chart-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.chart-date {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.chart-container {
  position: relative;
  max-width: 280px;
  margin: 0 auto 16px;
}
.chart-container-wide {
  max-width: 100%;
}
.chart-total {
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
}
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: center;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.legend-name {
  font-weight: 500;
}
.legend-pct {
  color: var(--text-secondary);
}

/* ===== 时间轴页 ===== */
.calendar {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.calendar-title {
  font-size: 16px;
  font-weight: 600;
}
.btn-icon-sm {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}
.btn-icon-sm:active {
  background: var(--bg);
}
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.cal-day:hover { background: var(--bg); }
.cal-day.today { font-weight: 700; color: var(--primary); }
.cal-day.selected {
  background: var(--primary);
  color: white;
  font-weight: 600;
}
.cal-day.has-record::after {
  content: '';
  position: absolute;
  bottom: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--primary);
}
.cal-day.selected.has-record::after {
  background: white;
}
.cal-day.other-month { color: var(--border); }

.timeline-header {
  font-size: 16px;
  font-weight: 600;
  padding: 8px 0 12px;
}
.timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 20px;
}
.timeline-empty {
  text-align: center;
  padding: 40px 0;
  color: var(--text-secondary);
  font-size: 14px;
}
.timeline-item {
  display: flex;
  gap: 12px;
  position: relative;
}
.timeline-time {
  width: 50px;
  text-align: right;
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
  padding-top: 4px;
}
.timeline-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: 5px;
  flex-shrink: 0;
  position: relative;
}
.timeline-dot::after {
  content: '';
  position: absolute;
  top: 14px;
  left: 5px;
  width: 2px;
  height: calc(100% + 12px);
  background: var(--border);
}
.timeline-item:last-child .timeline-dot::after { display: none; }
.timeline-card {
  flex: 1;
  background: var(--card);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}
.timeline-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.timeline-task-name {
  font-size: 15px;
  font-weight: 600;
}
.timeline-status {
  font-size: 12px;
  color: var(--success);
  font-weight: 500;
}
.timeline-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-secondary);
}
.timeline-progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}
.timeline-progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ===== 我的页 ===== */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.settings-group {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.settings-group h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.setting-item:last-child { border-bottom: none; }
.setting-item label {
  font-size: 15px;
}
.setting-control {
  display: flex;
  align-items: center;
  gap: 6px;
}
.setting-control input {
  width: 60px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  font-size: 15px;
}
.setting-control span {
  font-size: 13px;
  color: var(--text-secondary);
}
.category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.category-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: default;
}
.category-tag .cat-color {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.category-tag .cat-remove {
  margin-left: 4px;
  cursor: pointer;
  opacity: 0.5;
  font-size: 14px;
}
.category-tag .cat-remove:hover { opacity: 1; }
.add-category {
  display: flex;
  gap: 8px;
}
.add-category input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
}
.btn-danger {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: rgba(244,67,54,0.1);
  color: var(--danger);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-danger:active {
  background: rgba(244,67,54,0.2);
}
.btn-logout {
  margin-top: 10px;
}

/* ===== 底部导航 ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-height);
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: space-around;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  padding: 8px 16px;
  transition: color 0.2s;
}
.nav-item.active {
  color: var(--primary);
}
.nav-item svg {
  width: 24px;
  height: 24px;
}

/* ===== 登录界面 ===== */
.login-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #6C63FF 0%, #8B85FF 50%, #B8B5FF 100%);
  z-index: 1000;
}
.login-box {
  width: 100%;
  max-width: 380px;
  margin: 0 24px;
  background: var(--card);
  border-radius: 24px;
  padding: 36px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  text-align: center;
}
.login-logo {
  color: var(--primary);
  margin-bottom: 12px;
}
.login-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.login-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}
.login-tabs {
  display: flex;
  background: var(--bg);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 24px;
}
.login-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.login-tab.active {
  background: var(--primary);
  color: white;
}
.login-form {
  text-align: left;
}
.login-field {
  margin-bottom: 16px;
}
.login-field label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.login-field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}
.login-field input:focus {
  border-color: var(--primary);
}
.login-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin-bottom: 8px;
}
.login-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: var(--primary);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.login-btn:active {
  transform: scale(0.98);
  background: var(--primary-dark);
}
.login-btn:disabled {
  opacity: 0.6;
}
.login-hint {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ===== 总结页 ===== */
.summary-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--card);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.sel-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg);
  border-radius: 50%;
  font-size: 18px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sel-btn:active {
  background: var(--primary);
  color: white;
}
.sel-label {
  font-size: 16px;
  font-weight: 600;
  min-width: 120px;
  text-align: center;
}
.summary-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.summary-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  text-align: center;
}
.summary-card.highlight {
  grid-column: span 2;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
}
.summary-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.summary-card.highlight .summary-label {
  color: rgba(255,255,255,0.85);
}
.summary-value {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}
.summary-card.highlight .summary-value {
  font-size: 24px;
}
.summary-sub {
  font-size: 12px;
  color: var(--text-secondary);
}
.summary-card.highlight .summary-sub {
  color: rgba(255,255,255,0.85);
}

/* ===== 响应式 ===== */
@media (max-width: 360px) {
  .timer-time { font-size: 36px; }
  .timer-ring { width: 170px; height: 170px; }
  .stat-value { font-size: 18px; }
}
