/* ============================================================
   暑期学习计划 · 移动优先响应式样式
   ============================================================ */

:root {
  --primary: #4f46e5;
  --primary-light: #eef2ff;
  --primary-dark: #4338ca;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --warning: #d97706;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-600: #4b5563;
  --gray-800: #1f2937;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --radius: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 布局 ---------- */
.app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--gray-50);
}

.header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-lg);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.2);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
}

/* 底部导航（仅登录后显示） */
.bottom-nav {
  display: flex;
  position: sticky;
  bottom: 0;
  background: white;
  border-top: 1px solid var(--gray-200);
  z-index: 100;
  padding: 6px 0 env(safe-area-inset-bottom, 6px);
}

.nav-item {
  flex: 1;
  text-align: center;
  padding: 8px;
  color: var(--gray-400);
  font-size: 12px;
  cursor: pointer;
  transition: color .2s;
  border: none;
  background: none;
  font-family: inherit;
}

.nav-item.active { color: var(--primary); }
.nav-item .nav-icon { font-size: 20px; display: block; margin-bottom: 2px; }

/* ---------- 主内容区 ---------- */
.main {
  padding: 16px;
  padding-bottom: 80px;
}

.card {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-600);
  margin-bottom: 12px;
}

/* ---------- 作业卡片 ---------- */
.assignment-card {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--gray-200);
  transition: transform .1s;
}

.assignment-card:active { transform: scale(.98); }
.assignment-card.done { border-left-color: var(--success); }
.assignment-card.pending { border-left-color: var(--warning); }

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

.assignment-title { font-size: 16px; font-weight: 600; }

.assignment-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--gray-400);
  margin-bottom: 8px;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.tag-chinese { background: #fef3c7; color: #92400e; }
.tag-english { background: #dbeafe; color: #1e40af; }
.tag-reading { background: #d1fae5; color: #065f46; }
.tag-dictation { background: #fce7f3; color: #9d174d; }

/* 得分条 */
.score-bar {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--gray-100);
  font-size: 13px;
}

.score-item { display: flex; align-items: center; gap: 4px; }
.score-correct { color: var(--success); }
.score-wrong { color: var(--danger); }

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

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 6px;
}

input[type="text"], input[type="password"], input[type="date"],
input[type="number"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  background: white;
  transition: border-color .2s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
  width: 100%;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:active { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-outline { background: white; color: var(--primary); border: 1px solid var(--primary); }
.btn-gray { background: var(--gray-100); color: var(--gray-600); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 听写界面 ---------- */
.dictation-stage {
  text-align: center;
  padding: 24px 0;
}

.dictation-prompt {
  font-size: 48px;
  font-weight: 700;
  margin: 20px 0;
  letter-spacing: 4px;
}

.dictation-answer-input {
  font-size: 32px;
  text-align: center;
  letter-spacing: 8px;
  padding: 16px;
}

.dictation-progress {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gray-200);
}

.progress-dot.correct { background: var(--success); }
.progress-dot.wrong { background: var(--danger); }
.progress-dot.current { background: var(--primary); transform: scale(1.3); }

/* ---------- 空状态 ---------- */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--gray-400);
}

.empty-state .emoji { font-size: 48px; margin-bottom: 12px; }

/* ---------- 工具类 ---------- */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.mt-16 { margin-top: 16px; }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* 选项卡（看字选拼音） */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}

.option-btn {
  padding: 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  background: white;
  font-size: 20px;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}

.option-btn:active { border-color: var(--primary); }
.option-btn.selected { border-color: var(--primary); background: var(--primary-light); }
.option-btn.correct { border-color: var(--success); background: var(--success-light); }
.option-btn.wrong { border-color: var(--danger); background: var(--danger-light); }

/* 喇叭按钮（TTS） */
.speak-btn {
  background: var(--primary-light);
  color: var(--primary);
  border: none;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  font-size: 36px;
  cursor: pointer;
  transition: transform .1s;
}

.speak-btn:active { transform: scale(.92); }

/* 登录页 */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: 20px;
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  font-size: 48px;
  margin-bottom: 8px;
}

.login-title {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-subtitle {
  text-align: center;
  font-size: 13px;
  color: var(--gray-400);
  margin-bottom: 24px;
}

/* ---------- Modal 弹窗 ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

.modal-box {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 500px;
  padding: 20px;
  margin: 20px 0;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-100);
}

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

.modal-close {
  font-size: 20px;
  cursor: pointer;
  color: var(--gray-400);
  padding: 4px 12px;
}

/* ---------- 字词选择器 ---------- */
.word-chip {
  padding: 8px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  background: white;
  font-size: 15px;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
  text-align: center;
  min-width: 44px;
}

.word-chip.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

.chip-btn {
  padding: 4px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: white;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  color: var(--gray-600);
}

.chip-btn:active { background: var(--gray-100); }

/* ---------- 日历 ---------- */
.mb-12 { margin-bottom: 12px; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 12px;
}

.cal-week {
  text-align: center;
  font-size: 12px;
  color: var(--gray-400);
  font-weight: 600;
  padding: 4px 0;
}

.cal-cell {
  aspect-ratio: 1;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
  cursor: pointer;
  transition: transform .1s;
}

.cal-cell:active { transform: scale(.95); }
.cal-cell.empty { background: transparent; border: none; cursor: default; }
.cal-cell.today { border: 2px solid var(--primary); font-weight: 700; }
.cal-cell.done { background: var(--success-light); border-color: var(--success); }
.cal-cell.pending { background: #fef3c7; border-color: var(--warning); }
.cal-cell.mixed { background: linear-gradient(135deg, var(--success-light) 50%, #fef3c7 50%); border-color: var(--warning); }

.cal-num { font-size: 14px; }
.cal-badge {
  position: absolute;
  bottom: 2px;
  font-size: 9px;
  font-weight: 700;
  background: var(--primary);
  color: white;
  border-radius: 8px;
  padding: 0 5px;
  min-width: 14px;
  text-align: center;
}
.cal-cell.done .cal-badge { background: var(--success); }
.cal-cell.pending .cal-badge { background: var(--warning); }

.cal-legend {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 12px;
  font-size: 11px;
  color: var(--gray-600);
}

.legend-item { display: flex; align-items: center; gap: 4px; }
.legend-dot { width: 12px; height: 12px; border-radius: 3px; }
.legend-dot.done { background: var(--success-light); border: 1px solid var(--success); }
.legend-dot.pending { background: #fef3c7; border: 1px solid var(--warning); }
.legend-dot.mixed { background: linear-gradient(135deg, var(--success-light) 50%, #fef3c7 50%); border: 1px solid var(--warning); }

/* ---------- 错题本 ---------- */
.wrong-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}
.wrong-item:last-child { border-bottom: none; }
.wrong-prompt { font-size: 14px; margin-bottom: 6px; }
.wrong-answers {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  padding-left: 8px;
  border-left: 3px solid var(--danger);
}

/* ---------- 趋势图 ---------- */
.trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 120px;
  padding: 12px 4px 4px;
  overflow-x: auto;
}

.trend-bar-wrap {
  flex: 1;
  min-width: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.trend-score {
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-600);
  margin-bottom: 2px;
}

.trend-bar {
  width: 100%;
  max-width: 36px;
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: opacity .15s;
}
.trend-bar:active { opacity: .7; }

.trend-label {
  font-size: 10px;
  color: var(--gray-400);
  margin-top: 4px;
}

.trend-axis {
  text-align: center;
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 8px;
}

.trend-empty {
  text-align: center;
  color: var(--gray-400);
  font-size: 13px;
  padding: 20px;
}
