/* ===== 基础重置与变量 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #cf422a;
  --primary-light: #e85d44;
  --primary-dark: #a8341f;
  --secondary: #2c5f2d;
  --bg: #f5f1ea;
  --card: #ffffff;
  --text: #2c2c2c;
  --text-light: #666;
  --text-muted: #999;
  --border: #e0d9cc;
  --success: #4caf50;
  --warning: #ff9800;
  --danger: #f44336;
  --info: #2196f3;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.2s ease;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== 加载状态 ===== */
#app-loading {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  flex-direction: column; gap: 16px;
}
.spinner {
  width: 40px; height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 注册/登录弹窗 ===== */
.auth-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 9998;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.auth-modal {
  background: var(--card);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  position: relative;
  animation: modalIn 0.25s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.auth-modal-close {
  position: absolute; top: 12px; right: 16px;
  background: none; border: none;
  font-size: 24px; cursor: pointer;
  color: var(--text-muted); line-height: 1;
}
.auth-modal-close:hover { color: var(--text); }
.auth-modal h2 {
  font-size: 20px; color: var(--primary);
  margin-bottom: 6px;
}
.auth-modal-desc {
  font-size: 13px; color: var(--text-light);
  margin-bottom: 20px;
}
.auth-modal-form {
  display: flex; flex-direction: column; gap: 12px;
}
.auth-modal-switch {
  text-align: center; margin-top: 16px;
  font-size: 13px; color: var(--text-light);
}
.auth-modal-switch a {
  color: var(--primary); text-decoration: none;
  font-weight: 500; margin-left: 4px;
}
.auth-modal-switch a:hover { text-decoration: underline; }
.form-group {
  margin-bottom: 18px;
}
.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 6px;
  font-weight: 500;
}
.form-input {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
}
.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(207,66,42,0.1);
}
.form-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 4px;
}
.btn {
  padding: 11px 22px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #d0c8b8; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ===== 主布局 ===== */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  padding: 16px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(207,66,42,0.3);
}
.header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.header h1 { font-size: 20px; font-weight: 600; }
.header-info { display: flex; gap: 16px; font-size: 13px; align-items: center; flex-wrap: wrap; }
.header-info span { display: flex; align-items: center; gap: 4px; }
.countdown-badge {
  background: rgba(255,255,255,0.2);
  padding: 5px 12px;
  border-radius: 16px;
  font-weight: 600;
}
.user-menu {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  position: relative;
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-size: 14px;
}
.user-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  overflow: hidden;
  margin-top: 8px;
  z-index: 101;
}
.user-dropdown.show { display: block; }
.user-dropdown a, .user-dropdown button {
  display: block;
  width: 100%;
  padding: 10px 16px;
  text-align: left;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
}
.user-dropdown a:hover, .user-dropdown button:hover {
  background: #faf7f2;
}
.user-dropdown .divider {
  border-top: 1px solid var(--border);
}

/* ===== 导航 ===== */
.nav {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 64px;
  z-index: 99;
  box-shadow: var(--shadow);
}
.nav-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  overflow-x: auto;
}
.nav-item {
  padding: 14px 20px;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: var(--transition);
  font-size: 14px;
  color: var(--text-light);
}
.nav-item:hover { color: var(--primary); background: #faf7f2; }
.nav-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ===== 主内容 ===== */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
  width: 100%;
}
.page { display: none; }
.page.active { display: block; }

/* ===== 卡片 ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
  border-left: 4px solid var(--primary);
  padding-left: 12px;
}

/* ===== 统计网格 ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--primary);
}
.stat-label { font-size: 12px; color: var(--text-light); margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ===== 阶段卡片 ===== */
.phases-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.phase-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border-left: 5px solid var(--primary);
  transition: var(--transition);
}
.phase-card:hover { transform: translateY(-2px); }
.phase-card.current { box-shadow: 0 4px 20px rgba(207,66,42,0.2); }
.phase-1 .phase-tag, .phase-card[data-phase="1"] { border-left-color: #4caf50; }
.phase-2 .phase-tag, .phase-card[data-phase="2"] { border-left-color: #2196f3; }
.phase-3 .phase-tag, .phase-card[data-phase="3"] { border-left-color: #ff9800; }
.phase-4 .phase-tag, .phase-card[data-phase="4"] { border-left-color: #9c27b0; }
.phase-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 12px;
  color: white;
  margin-bottom: 8px;
}
.phase-1 .phase-tag { background: #4caf50; }
.phase-2 .phase-tag { background: #2196f3; }
.phase-3 .phase-tag { background: #ff9800; }
.phase-4 .phase-tag { background: #9c27b0; }
.phase-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.phase-time { font-size: 12px; color: var(--text-light); margin-bottom: 10px; }
.phase-goal { font-size: 13px; color: var(--text); padding: 10px; background: #faf7f2; border-radius: 6px; }
.progress-bar {
  background: #e0d9cc;
  border-radius: 10px;
  height: 8px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 10px;
  transition: width 0.5s;
}

/* ===== 打卡日历 ===== */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin-top: 12px;
}
.calendar-header {
  text-align: center;
  font-size: 12px;
  color: var(--text-light);
  padding: 6px 0;
  font-weight: 600;
}
.calendar-day {
  aspect-ratio: 1;
  border-radius: 8px;
  background: #faf7f2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid transparent;
}
.calendar-day:hover { border-color: var(--primary); }
.calendar-day.checked { background: var(--success); color: white; }
.calendar-day.today { border-color: var(--primary); font-weight: 700; }
.calendar-day.future { opacity: 0.35; cursor: not-allowed; }

/* ===== 任务列表 ===== */
.task-list { display: flex; flex-direction: column; gap: 10px; }
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: #faf7f2;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--border);
  transition: var(--transition);
}
.task-item.completed {
  background: #e8f5e9;
  border-left-color: var(--success);
}
.task-item.completed .task-name { text-decoration: line-through; color: var(--text-light); }
.task-checkbox {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  transition: var(--transition);
}
.task-checkbox.checked {
  background: var(--success);
  border-color: var(--success);
  color: white;
  font-size: 12px;
}
.task-content { flex: 1; }
.task-name { font-weight: 500; font-size: 14px; margin-bottom: 3px; }
.task-detail { font-size: 12px; color: var(--text-light); }
.task-time {
  display: inline-block;
  background: var(--primary);
  color: white;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 8px;
  margin-top: 5px;
}

/* ===== 番茄钟 ===== */
.pomodoro-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
}
.pomodoro-display {
  width: 260px; height: 260px;
  border-radius: 50%;
  background: conic-gradient(var(--primary) 0deg, #e0d9cc 0deg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px 0;
  transition: background 1s;
}
.pomodoro-inner {
  width: 230px; height: 230px;
  border-radius: 50%;
  background: var(--card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.pomodoro-time { font-size: 50px; font-weight: 700; color: var(--primary); }
.pomodoro-label { font-size: 13px; color: var(--text-light); margin-top: 6px; }
.pomodoro-modes { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.mode-btn {
  padding: 7px 14px;
  border: 2px solid var(--border);
  background: var(--card);
  border-radius: 18px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: var(--transition);
}
.mode-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.pomodoro-controls { display: flex; gap: 10px; margin-top: 16px; }

/* ===== 笔记 ===== */
.note-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.note-input, .note-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
}
.note-input:focus, .note-textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.note-textarea { resize: vertical; }
.note-type-select {
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  font-size: 14px;
  font-family: inherit;
}
.note-list { display: flex; flex-direction: column; gap: 10px; }
.note-item {
  padding: 14px;
  background: #faf7f2;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--primary);
}
.note-item.type-error { border-left-color: #f44336; }
.note-item.type-politics { border-left-color: #2196f3; }
.note-item.type-study { border-left-color: var(--secondary); }
.note-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-light);
}
.note-type-tag {
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 11px;
  color: white;
}
.note-type-tag.study { background: var(--secondary); }
.note-type-tag.error { background: #f44336; }
.note-type-tag.politics { background: #2196f3; }
.note-content { font-size: 13px; white-space: pre-wrap; line-height: 1.6; }
.note-actions { margin-top: 8px; display: flex; gap: 8px; justify-content: flex-end; }

/* ===== 资源卡片 ===== */
.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.resource-card {
  background: #faf7f2;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: var(--transition);
}
.resource-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--primary-light);
  transform: translateY(-1px);
}
.resource-card h4 { margin-bottom: 10px; color: var(--primary); font-size: 15px; }
.resource-card ul { list-style: none; }
.resource-card li {
  padding: 5px 0;
  font-size: 13px;
  border-bottom: 1px dashed var(--border);
}
.resource-card li:last-child { border-bottom: none; }
.resource-card a.btn { color: white !important; text-decoration: none; }
.resource-card a:not(.btn) { color: var(--primary); text-decoration: none; }
.resource-card a:hover { text-decoration: underline; }

/* ===== 表格 ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th, .data-table td {
  border: 1px solid var(--border);
  padding: 10px;
  text-align: center;
}
.data-table th { background: var(--primary); color: white; }
.data-table td { background: #faf7f2; }
.data-table .time-col { background: #f0ebe0; font-weight: 600; }

/* ===== 公告 ===== */
.announcement-list { display: flex; flex-direction: column; gap: 12px; }
.announcement-item {
  padding: 14px;
  background: #faf7f2;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.announcement-item:hover { background: #f0ebe0; }
.announcement-item.pinned { border-left: 4px solid var(--warning); }
.announcement-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.announcement-meta { font-size: 12px; color: var(--text-muted); }
.announcement-content { font-size: 13px; color: var(--text); margin-top: 8px; display: none; }
.announcement-item.expanded .announcement-content { display: block; }

/* ===== 时政卡片 ===== */
.politics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}
.politics-card {
  background: #faf7f2;
  padding: 16px;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--info);
}
.politics-card h4 { font-size: 14px; margin-bottom: 8px; color: var(--text); }
.politics-card p { font-size: 13px; color: var(--text-light); line-height: 1.7; }
.politics-meta { font-size: 11px; color: var(--text-muted); margin-top: 8px; display: flex; gap: 10px; flex-wrap: wrap; }
.politics-tag { padding: 2px 6px; border-radius: 4px; background: var(--info); color: white; font-size: 10px; }

/* ===== 管理后台 ===== */
.admin-form { display: flex; flex-direction: column; gap: 12px; }
.admin-table { overflow-x: auto; }
.admin-actions { display: flex; gap: 6px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 90px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateX(100px);
  transition: var(--transition);
  z-index: 1000;
  font-size: 14px;
  max-width: 300px;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast.success { background: var(--success); color: white; }
.toast.error { background: var(--danger); color: white; }
.toast.info { background: var(--info); color: white; }

/* ===== 阶段时间线条 ===== */
.phase-item {
  background: #faf7f2;
  padding: 14px;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--primary);
  transition: var(--transition);
}
.phase-item.active {
  background: #fff3e0;
  border-left-color: var(--warning);
  box-shadow: 0 2px 8px rgba(255,152,0,0.15);
}
.phase-num { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.phase-name { font-size: 15px; font-weight: 600; margin: 2px 0; }
.phase-period { font-size: 12px; color: var(--text-light); }
.phase-desc { font-size: 13px; color: var(--text); margin-top: 6px; }

/* ===== 笔记补充样式 ===== */
.note-type-badge {
  padding: 2px 8px; border-radius: 8px;
  font-size: 11px; color: white; display: inline-block;
}
.note-type-badge.study { background: var(--secondary); }
.note-type-badge.error { background: #f44336; }
.note-type-badge.politics { background: #2196f3; }
.note-title { font-weight: 600; font-size: 14px; margin: 4px 0; }
.note-date { font-size: 12px; color: var(--text-muted); }
.note-content { font-size: 13px; line-height: 1.6; white-space: pre-wrap; }

/* ===== 任务分类标签 ===== */
.task-category { font-size: 11px; color: var(--primary); font-weight: 600; }

/* ===== 资源补充样式 ===== */
.resource-category { font-size: 11px; color: var(--primary); font-weight: 600; margin-bottom: 4px; }
.resource-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.resource-desc { font-size: 13px; color: var(--text-light); line-height: 1.6; }

/* ===== 时政补充样式 ===== */
.politics-category { font-size: 11px; color: var(--info); font-weight: 600; margin-bottom: 4px; }
.politics-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.politics-content { font-size: 13px; color: var(--text-light); line-height: 1.6; }
.politics-date { font-size: 11px; color: var(--text-muted); margin-top: 8px; }

/* ===== 日历补充 ===== */
.calendar-header, .calendar-body { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; text-align: center; }
.calendar-weekday { font-size: 12px; color: var(--text-light); font-weight: 600; padding: 6px 0; }

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

/* ===== 底部备案信息 ===== */
.footer {
  text-align: center;
  padding: 16px 0;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 20px;
}
.footer-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.footer-divider {
  color: var(--border);
}
.footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition);
}
.footer a:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .header h1 { font-size: 17px; }
  .header-info { font-size: 12px; gap: 8px; }
  .pomodoro-display { width: 200px; height: 200px; }
  .pomodoro-inner { width: 175px; height: 175px; }
  .pomodoro-time { font-size: 38px; }
  .main { padding: 16px 12px; }
  .nav-item { padding: 10px 14px; font-size: 13px; }
  .auth-card { padding: 24px; }
  .card { padding: 16px; }
}

/* ===== 滚动条美化 ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
