/* ===== 全局样式 ===== */
:root {
  /* 主色调 */
  --primary: #58cc02;
  --primary-dark: #46a302;
  --primary-light: #89e219;
  
  /* 辅助色 */
  --secondary: #1cb0f6;
  --warning: #ff9600;
  --error: #ff4b4b;
  --success: #58cc02;
  
  /* 中性色 */
  --bg-dark: #131f24;
  --bg-card: #1a2c34;
  --bg-elevated: #243842;
  --border: #37464f;
  --text: #ffffff;
  --text-secondary: #afbcbf;
  --text-muted: #6e7f86;
  
  /* 字体 */
  --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  /* 圆角 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  /* 阴影 */
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
}

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

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

body {
  font-family: var(--font-main);
  background: var(--bg-dark);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

.page {
  height: 100%;
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: var(--bg-dark);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.page.hidden {
  display: none;
}

/* ===== 按钮样式 ===== */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-bottom: 4px solid var(--primary-dark);
  border-radius: var(--radius-md);
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-primary:active {
  border-bottom-width: 2px;
  transform: translateY(2px);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-large {
  padding: 18px 32px;
  font-size: 17px;
}

.btn-back {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 8px;
  margin: -8px;
}

.btn-back:hover {
  color: var(--text);
}

/* ===== 首页 ===== */
#home-page {
  padding: 20px;
  overflow-y: auto;
}

.home-header {
  text-align: center;
  margin-bottom: 32px;
  padding-top: 16px;
}

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

.home-header h1 {
  font-size: 28px;
  font-weight: 700;
}

.streak-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, #ff9600, #ff6b00);
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 600;
}

.streak-badge .fire {
  font-size: 18px;
}

.streak-badge .streak-num {
  font-size: 18px;
}

.streak-badge .streak-label {
  font-size: 13px;
  opacity: 0.9;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 15px;
}

/* 计划卡片 */
.plan-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  border: 2px solid transparent;
  transition: border-color 0.2s, transform 0.2s;
}

.plan-card:hover {
  border-color: var(--border);
}

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

.plan-icon {
  font-size: 48px;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
}

.plan-info {
  flex: 1;
  min-width: 0;
}

.plan-info h2 {
  font-size: 18px;
  margin-bottom: 4px;
}

.plan-desc {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 12px;
}

.plan-progress {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 4px;
  transition: width 0.5s ease;
}

.progress-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 40px;
}

.plan-actions {
  width: 100%;
  display: flex;
  gap: 12px;
}

.btn-continue {
  flex: 1;
  background: var(--primary);
  color: #fff;
  border: none;
  border-bottom: 3px solid var(--primary-dark);
  border-radius: var(--radius-md);
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-continue:active {
  border-bottom-width: 1px;
  transform: translateY(2px);
}

.btn-detail {
  flex: 1;
  background: var(--bg-elevated);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

/* 首页底部 */
.home-footer {
  margin-top: auto;
  padding: 20px 0;
  text-align: center;
}

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

/* ===== 详情页 ===== */
#detail-page {
  padding: 0;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.detail-header h1 {
  font-size: 20px;
}

.detail-main {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* 阶段列表 */
.stages-list {
  margin-bottom: 32px;
}

.stage-item {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
}

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

.stage-name {
  font-weight: 600;
  font-size: 16px;
}

.stage-count {
  color: var(--text-secondary);
  font-size: 14px;
}

.stage-progress-bar {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
}

.stage-progress-fill {
  height: 100%;
  background: var(--secondary);
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* 已完成列表 */
.completed-section h3 {
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.completed-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.completed-item {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background 0.2s;
}

.completed-item:hover {
  background: var(--bg-elevated);
}

.completed-item .q-title {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  margin-right: 12px;
}

.completed-item .q-result {
  font-size: 18px;
}

.empty-hint {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 20px;
}

.detail-footer {
  padding: 20px;
  border-top: 1px solid var(--border);
}

/* ===== 学习页 ===== */
#learn-page {
  background: var(--bg-dark);
}

.learn-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
}

.learn-progress {
  flex: 1;
}

.progress-dots {
  display: flex;
  gap: 6px;
}

.progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: all 0.3s ease;
}

.progress-dot.current {
  background: var(--secondary);
  transform: scale(1.2);
}

.progress-dot.correct {
  background: var(--success);
}

.progress-dot.wrong {
  background: var(--error);
}

.question-counter {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 600;
}

.learn-main {
  flex: 1;
  padding: 0 20px;
  overflow-y: auto;
}

.question-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}

.stage-tag {
  display: inline-block;
  background: var(--bg-elevated);
  color: var(--secondary);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 16px;
}

.question-text {
  font-size: 18px;
  line-height: 1.6;
  margin-bottom: 16px;
}

.question-code {
  background: var(--bg-dark);
  padding: 16px;
  border-radius: var(--radius-md);
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 14px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.question-code:empty {
  display: none;
}

/* 选项 */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-item {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 16px;
}

.option-item:hover {
  border-color: var(--text-muted);
}

.option-item.selected {
  border-color: var(--secondary);
  background: rgba(28, 176, 246, 0.1);
}

.option-item.correct {
  border-color: var(--success);
  background: rgba(88, 204, 2, 0.15);
}

.option-item.wrong {
  border-color: var(--error);
  background: rgba(255, 75, 75, 0.15);
}

.option-item.disabled {
  pointer-events: none;
  opacity: 0.6;
}

/* 学习页底部 */
.learn-footer {
  display: flex;
  gap: 12px;
  padding: 20px;
  border-top: 1px solid var(--border);
}

.learn-footer button {
  flex: 1;
}

/* 反馈弹窗 */
.feedback-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

.feedback-overlay.hidden {
  display: none;
}

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

.feedback-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 32px 24px;
  width: 100%;
  max-width: 480px;
  animation: slideUp 0.3s ease;
}

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

.feedback-icon {
  font-size: 64px;
  text-align: center;
  margin-bottom: 16px;
}

.feedback-title {
  text-align: center;
  font-size: 24px;
  margin-bottom: 16px;
}

.feedback-title.correct {
  color: var(--success);
}

.feedback-title.wrong {
  color: var(--error);
}

.feedback-explanation {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 24px;
  font-size: 14px;
  line-height: 1.7;
}

.feedback-card .btn-primary {
  width: 100%;
}

/* ===== 完成页 ===== */
#complete-page {
  justify-content: center;
  align-items: center;
  background: linear-gradient(180deg, var(--bg-dark), #0d1518);
}

.complete-content {
  text-align: center;
  padding: 40px 24px;
  max-width: 360px;
}

.complete-animation {
  position: relative;
  height: 120px;
  margin-bottom: 24px;
}

.confetti {
  font-size: 48px;
  position: absolute;
  left: 20%;
  animation: float 2s ease-in-out infinite;
}

.trophy {
  font-size: 80px;
  animation: bounce 1s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-10deg); }
  50% { transform: translateY(-20px) rotate(10deg); }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}

.complete-content h1 {
  font-size: 32px;
  margin-bottom: 8px;
}

.complete-subtitle {
  color: var(--text-secondary);
  font-size: 16px;
  margin-bottom: 32px;
}

.stats-card {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}

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

.stat-value {
  display: block;
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

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

.stat-divider {
  width: 1px;
  height: 40px;
  background: var(--border);
}

.streak-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #ff9600, #ff6b00);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 32px;
}

.streak-emoji {
  font-size: 28px;
}

.streak-text {
  font-size: 16px;
  font-weight: 600;
}

.complete-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ===== 回顾页 ===== */
#review-page {
  background: var(--bg-dark);
}

.review-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.review-header h1 {
  font-size: 20px;
}

.review-main {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.review-item {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.review-question {
  font-size: 16px;
  margin-bottom: 12px;
  line-height: 1.5;
}

.review-answer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.your-answer {
  font-size: 14px;
}

.your-answer span {
  color: var(--text-muted);
}

.your-answer.correct {
  color: var(--success);
}

.your-answer.wrong {
  color: var(--error);
}

/* ===== 响应式 ===== */
@media (max-width: 375px) {
  .home-header h1 {
    font-size: 24px;
  }
  
  .plan-icon {
    font-size: 40px;
    width: 56px;
    height: 56px;
  }
  
  .question-text {
    font-size: 16px;
  }
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}
