/* style.css — 中文听写应用样式，移动端优先 */

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

:root {
  --primary: #4A90D9;
  --primary-light: #E6F1FB;
  --primary-dark: #185FA5;
  --success: #34A853;
  --success-light: #EAF3DE;
  --danger: #E24B4A;
  --danger-light: #FCEBEB;
  --warning: #F5A623;
  --warning-light: #FAEEDA;
  --purple: #7F77DD;
  --purple-light: #EEEDFE;
  --gray-50: #F7F6F3;
  --gray-100: #EDECE8;
  --gray-200: #D3D1C7;
  --gray-400: #888780;
  --gray-600: #5F5E5A;
  --gray-800: #444441;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ── 导航栏 ── */
.nav {
  display: flex;
  gap: 4px;
  padding: 12px 0;
  position: sticky;
  top: 0;
  background: var(--gray-50);
  z-index: 100;
}
.nav button {
  flex: 1;
  padding: 8px 4px;
  border: none;
  background: transparent;
  color: var(--gray-400);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.nav button.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ── 页面容器 ── */
.page { display: none; padding-bottom: 80px; }
.page.active { display: block; }

/* ── 通用组件 ── */
.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline {
  background: #fff;
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
}
.btn-outline:active { background: var(--gray-50); }
.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.title-lg {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 12px;
}
.title-md {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 8px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
}
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-success { background: var(--success-light); color: #27500A; }
.badge-danger { background: var(--danger-light); color: #791F1F; }
.badge-warning { background: var(--warning-light); color: #633806; }
.badge-purple { background: var(--purple-light); color: #3C3489; }

input[type="text"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
}

/* ── 首页 ── */
.home-header {
  text-align: center;
  padding: 32px 0 24px;
}
.home-header h1 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 4px;
}
.home-header p {
  color: var(--gray-400);
  font-size: 14px;
}

.stat-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
.stat-item {
  flex: 1;
  text-align: center;
  padding: 12px 8px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat-item .num {
  font-size: 24px;
  font-weight: 600;
  color: var(--primary);
}
.stat-item .label {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 2px;
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── 字词库页 ── */
.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}
.toolbar select {
  flex: 1;
}
.toolbar .btn-sm {
  white-space: nowrap;
}

.word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.word-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: #fff;
  border-radius: 20px;
  font-size: 15px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.word-item:active { background: var(--gray-50); }
.word-item.selected { border-color: var(--primary); background: var(--primary-light); }
.word-item .wrong-badge {
  background: var(--danger-light);
  color: var(--danger);
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 8px;
}
.word-item .delete-btn {
  width: 18px;
  height: 18px;
  border: none;
  background: var(--gray-200);
  color: var(--gray-600);
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.add-words-area textarea {
  min-height: 80px;
  resize: vertical;
  margin-bottom: 8px;
}

/* ── 听写页 ── */
.dictation-setup {
  padding: 16px 0;
}

.setting-group {
  margin-bottom: 16px;
}
.setting-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--gray-600);
}
.setting-group .range-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.setting-group input[type="range"] {
  flex: 1;
  accent-color: var(--primary);
}
.setting-group .range-value {
  min-width: 36px;
  text-align: center;
  font-weight: 500;
  color: var(--primary);
}
.setting-group .btn-group {
  display: flex;
  gap: 6px;
}
.setting-group .btn-group button {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--gray-200);
  background: #fff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
}
.setting-group .btn-group button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* 听写进行中 */
.dictation-player {
  text-align: center;
  padding: 24px 0;
}
.dictation-progress {
  font-size: 14px;
  color: var(--gray-400);
  margin-bottom: 16px;
}
.dictation-current-word {
  font-size: 42px;
  font-weight: 500;
  color: var(--primary-dark);
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  word-break: break-all;
  overflow-wrap: break-word;
  line-height: 1.3;
}
.dictation-hint {
  font-size: 14px;
  color: var(--gray-400);
  margin-bottom: 24px;
  min-height: 20px;
}
.dictation-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
}
.dictation-controls .btn {
  min-width: 80px;
}

/* 结果核对 */
.result-list {
  text-align: left;
}
.result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
}
.result-item:last-child { border-bottom: none; }
.result-word {
  font-size: 18px;
  font-weight: 500;
}
.result-actions {
  display: flex;
  gap: 6px;
}
.result-score {
  text-align: center;
  padding: 16px 0;
}
.result-score .score-num {
  font-size: 36px;
  font-weight: 600;
}
.result-score .score-label {
  font-size: 14px;
  color: var(--gray-400);
}

/* ── 设置页 ── */
.settings-section {
  margin-bottom: 24px;
}
.settings-section h3 {
  font-size: 14px;
  color: var(--gray-400);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── 空状态 ── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-400);
}
.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
}
.empty-state p {
  margin-bottom: 16px;
}

/* ── 弹窗 ── */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-content {
  background: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 20px;
  width: 100%;
  max-width: 480px;
  max-height: 70vh;
  overflow-y: auto;
}
.modal-content .title-md { margin-bottom: 12px; }

/* ── 动画 ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.page.active { animation: fadeIn 0.2s ease; }
