* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { font-size: 17px; }
html.font-small { font-size: 14px; }
html.font-medium { font-size: 17px; }
html.font-large { font-size: 20px; }

body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f6fa;
  color: #333;
  font-size: 1rem;
}

/* ============ 头部 ============ */
.header {
  background: #4a6cf7;
  color: #fff;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 8px;
}
.header h1 { font-size: 1.06rem; flex: 1; }
.header .user-info {
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.header .user-info button { padding: 4px 10px; font-size: 0.82rem; }

.points-badge {
  background: rgba(255,255,255,0.2);
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 600;
  color: #fff8e1;
}

.font-select {
  padding: 3px 6px;
  border-radius: 6px;
  border: none;
  font-size: 0.76rem;
  background: rgba(255,255,255,0.25);
  color: #fff;
}

.btn-header {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

.menu-btn {
  display: none;
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 1.1rem;
  cursor: pointer;
}
.menu-btn:active { background: rgba(255,255,255,0.3); }

/* ============ 移动端菜单 ============ */
.mobile-menu {
  display: none;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.mobile-menu.open { display: block; }
.mobile-menu .mm-section { padding: 10px 14px; border-bottom: 1px solid #f0f0f0; }
.mobile-menu .mm-section:last-child { border-bottom: none; }
.mobile-menu .mm-label { font-size: 0.76rem; color: #999; margin-bottom: 6px; }
.mobile-menu .mm-search { display: flex; gap: 6px; }
.mobile-menu .mm-search input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.88rem;
}
.mobile-menu .mm-search button {
  padding: 9px 14px;
  background: #4a6cf7;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.88rem;
}
.mobile-menu .mm-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.mobile-menu .mm-actions button {
  flex: 1;
  min-width: 60px;
  padding: 8px 6px;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 8px;
  font-size: 0.82rem;
  color: #666;
  cursor: pointer;
}
.mobile-menu .mm-user { font-size: 0.82rem; color: #666; }
.mobile-menu .mm-font { display: flex; gap: 6px; }
.mobile-menu .mm-font button {
  flex: 1;
  padding: 6px;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
}
.mobile-menu .mm-font button.active {
  background: #4a6cf7;
  color: #fff;
  border-color: #4a6cf7;
}

/* ============ 搜索栏 ============ */
.search-bar {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 12px 14px;
  display: flex;
  gap: 8px;
  align-items: center;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
  position: relative;
  z-index: 98;
}
.search-bar input {
  flex: 1;
  padding: 11px 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 10px;
  font-size: 0.94rem;
  background: rgba(255,255,255,0.95);
  outline: none;
  transition: 0.2s;
}
.search-bar input:focus {
  border-color: #fff;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.2);
}
.search-bar button {
  padding: 11px 18px;
  background: #fff;
  color: #667eea;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.94rem;
  font-weight: 600;
}

/* ============ Tab ============ */
.tabs {
  display: flex;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 99;
  overflow-x: auto;
}
.tabs button {
  flex: 1;
  padding: 11px 4px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.94rem;
  color: #666;
  white-space: nowrap;
}
.tabs button.active {
  color: #4a6cf7;
  border-bottom: 2px solid #4a6cf7;
  font-weight: 600;
}

/* ============ 容器 ============ */
.container { max-width: 900px; margin: 0 auto; padding: 10px; }

.section-title { margin-bottom: 10px; font-size: 0.94rem; }
.mt-12 { margin-top: 12px; }
.mt-20 { margin: 20px 0 10px; }

/* ============ 工具栏 ============ */
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.toolbar select {
  padding: 7px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.88rem;
  background: #fff;
  flex: 1;
  min-width: 0;
}
.toolbar label {
  font-size: 0.88rem;
  color: #666;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.toolbar label input[type="checkbox"] { width: 16px; height: 16px; }

/* ============ 单词卡片 ============ */
.card {
  background: #fff;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.word-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.word-title {
  font-size: 1.47rem;
  font-weight: 700;
  color: #2c3e50;
  word-break: break-word;
}
.phonetic {
  color: #888;
  font-size: 0.88rem;
  margin-top: 3px;
  word-break: break-word;
}
.actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }

/* ============ 按钮 ============ */
.btn {
  padding: 7px 12px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  transition: 0.15s;
  min-width: 44px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.btn:active { transform: scale(0.95); }
.btn-known { background: #e8f5e9; color: #2e7d32; }
.btn-known.active { background: #2e7d32; color: #fff; }
.btn-unknown { background: #ffebee; color: #c62828; }
.btn-unknown.active { background: #c62828; color: #fff; }
.btn-audio { background: #e3f2fd; color: #1565c0; }
.btn-add { background: #fff8e1; color: #f57c00; }
.btn-add.added { background: #f57c00; color: #fff; }
.btn-primary { background: #4a6cf7; color: #fff; flex: 1; }
.btn-gray { background: #eee; color: #666; flex: 1; }

/* ============ 释义与例句 ============ */
.explains { margin-top: 10px; line-height: 1.7; font-size: 0.94rem; }
.explains li { margin-left: 18px; }

.sentences { margin-top: 10px; border-top: 1px dashed #eee; padding-top: 8px; }
.sentence { margin-bottom: 8px; font-size: 0.91rem; line-height: 1.6; }
.sentence .en {
  color: #2c3e50;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.sentence .cn { color: #888; font-size: 0.88rem; margin-top: 2px; }

/* 隐藏英文 */
.word-title.hidden-text,
.phonetic.hidden-text,
.sentence .en.hidden-text,
.sentence .cn.hidden-text {
  color: #fff;
  user-select: none;
}

/* 记录块 */
.note-block {
  margin-top: 8px;
  padding: 8px 10px;
  background: #fffbe6;
  border-left: 3px solid #f5a623;
  border-radius: 4px;
  font-size: 0.88rem;
  color: #666;
  white-space: pre-wrap;
}

/* 关联块 */
.relation-block {
  margin-top: 8px;
  padding: 8px 10px;
  background: #f0f4ff;
  border-left: 3px solid #4a6cf7;
  border-radius: 4px;
  font-size: 0.88rem;
  color: #555;
}
.relation-tag {
  display: inline-block;
  background: #4a6cf7;
  color: #fff;
  padding: 1px 8px;
  border-radius: 10px;
  margin: 2px;
  cursor: pointer;
}

.card-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #eee;
}

/* ============ 分页 ============ */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 14px;
  flex-wrap: wrap;
  padding-bottom: 20px;
}
.pagination button {
  padding: 8px 12px;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  min-width: 40px;
  min-height: 38px;
}
.pagination button.active { background: #4a6cf7; color: #fff; border-color: #4a6cf7; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

.empty { text-align: center; color: #aaa; padding: 40px 20px; font-size: 0.94rem; }

/* ============ 统计 ============ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 10px;
}
.stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}
.stat-card .num { font-size: 1.76rem; font-weight: 700; color: #4a6cf7; }
.stat-card .label { color: #888; font-size: 0.82rem; margin-top: 4px; }
.stat-card.likes .num { color: #e53935; }
.stat-card.points { background: linear-gradient(135deg, #fff8e1, #fffdf5); }
.stat-card.points .num { color: #f57c00; }

/* ============ 成就 ============ */
.ach-section { margin-bottom: 20px; }
.ach-section-title { font-size: 0.88rem; color: #888; margin-bottom: 8px; font-weight: 600; }

.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.ach-card {
  background: #fff;
  border-radius: 10px;
  padding: 14px;
  border: 2px solid #eee;
  transition: 0.2s;
}
.ach-card.achieved {
  border-color: #f5a623;
  background: linear-gradient(135deg, #fffdf5, #fff8e1);
}
.ach-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ach-icon { font-size: 1.6rem; }
.ach-title { font-size: 0.94rem; font-weight: 700; color: #333; }
.ach-progress-bar {
  height: 8px;
  background: #eee;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}
.ach-progress-fill {
  height: 100%;
  background: #4a6cf7;
  border-radius: 4px;
  transition: 0.3s;
}
.ach-card.achieved .ach-progress-fill { background: #f5a623; }
.ach-desc { font-size: 0.76rem; color: #888; }
.ach-card.achieved .ach-desc { color: #b8860b; }
.ach-levels { display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.ach-level {
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: #f0f0f0;
  color: #999;
}
.ach-level.on { background: #f5a623; color: #fff; }

.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}
.badge {
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  border: 2px solid #eee;
  opacity: 0.5;
  transition: 0.2s;
}
.badge.achieved {
  opacity: 1;
  border-color: #4a6cf7;
  background: linear-gradient(135deg, #f0f4ff, #e8f0ff);
}
.badge-icon { font-size: 1.6rem; margin-bottom: 4px; }
.badge-title { font-size: 0.82rem; font-weight: 700; color: #333; }
.badge-desc { font-size: 0.71rem; color: #888; margin-top: 2px; }
.badge.achieved .badge-desc { color: #4a6cf7; }

/* 图表 */
.chart-card { padding: 8px; }
#curve-chart { width: 100%; height: 220px; display: block; }

/* ============ 排行榜 ============ */
.lb-tabs { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; }
.lb-tabs button {
  flex: 1;
  padding: 9px 6px;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  color: #666;
  white-space: nowrap;
}
.lb-tabs button.active {
  background: #4a6cf7;
  color: #fff;
  border-color: #4a6cf7;
  font-weight: 600;
}

.lb-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-radius: 8px;
  margin-bottom: 6px;
}
.lb-item.me { background: #e3f2fd; border: 1px solid #4a6cf7; }
.lb-rank {
  font-weight: 700;
  font-size: 1rem;
  color: #888;
  min-width: 30px;
  text-align: center;
}
.lb-rank.top1 { color: #f5a623; }
.lb-rank.top2 { color: #9b9b9b; }
.lb-rank.top3 { color: #cd7f32; }
.lb-user { flex: 1; font-size: 0.94rem; word-break: break-all; }
.lb-value {
  font-weight: 700;
  color: #4a6cf7;
  font-size: 1rem;
  min-width: 40px;
  text-align: right;
}
.lb-value.likes-value { color: #e53935; }
.lb-value.points-value { color: #f57c00; }

.lb-like {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 2px solid #ffcdd2;
  background: #fff;
  color: #e53935;
  border-radius: 18px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}
.lb-like:disabled { opacity: 0.4; cursor: not-allowed; }
.lb-like.liked { background: #e53935; color: #fff; border-color: #e53935; }
.lb-like-count { font-size: 0.76rem; }

.lb-tip {
  text-align: center;
  color: #999;
  font-size: 0.82rem;
  padding: 16px;
  background: #fff;
  border-radius: 8px;
}

/* ============ 登录页 ============ */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
#login-screen .box {
  background: #fff;
  padding: 28px 24px;
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  width: 100%;
  max-width: 340px;
  text-align: center;
}
#login-screen input {
  width: 100%;
  padding: 13px;
  border: 1px solid #ddd;
  border-radius: 10px;
  margin: 16px 0;
  font-size: 1.06rem;
}
#login-screen button {
  width: 100%;
  padding: 13px;
  background: #4a6cf7;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1.06rem;
  cursor: pointer;
}

/* ============ 弹窗 ============ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 400px;
}
.modal-box-wide { max-width: 500px; max-height: 80vh; overflow-y: auto; }
.modal-title { margin-bottom: 16px; font-size: 1rem; }
.modal-subtitle { color: #888; font-size: 0.82rem; margin-bottom: 12px; }
.modal-input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  margin-bottom: 10px;
  font-size: 0.94rem;
}
.modal-textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.94rem;
  resize: vertical;
  font-family: inherit;
}
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

/* 记录整理里每条 */
.note-item {
  background: #fff;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.note-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.note-item-word { font-size: 1rem; font-weight: 700; cursor: pointer; color: #2c3e50; }
.note-item-body {
  margin-top: 6px;
  color: #666;
  font-size: 0.88rem;
  white-space: pre-wrap;
}
.relation-tag-list { margin-top: 6px; }

/* ============ 通用 ============ */
.hidden { display: none !important; }

/* ============ 手机端适配 ============ */
@media (max-width: 600px) {
  .header .user-info { display: none; }
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .search-bar { display: none; }
  .tabs { position: sticky; top: 46px; }
  .tabs button { font-size: 0.88rem; padding: 10px 2px; }

  .container { padding: 8px; }
  .card { padding: 12px; border-radius: 8px; }
  .word-title { font-size: 1.35rem; }
  .phonetic { font-size: 0.82rem; }
  .actions { gap: 4px; }
  .btn { padding: 6px 10px; font-size: 0.82rem; min-width: 40px; min-height: 34px; }
  .explains { font-size: 0.91rem; }
  .sentence { font-size: 0.88rem; }
  .header h1 { font-size: 1rem; }
  .stat-card .num { font-size: 1.53rem; }
  .pagination button { padding: 7px 10px; font-size: 0.82rem; min-width: 36px; }
  .lb-user { font-size: 0.88rem; }
  .lb-value { font-size: 0.94rem; min-width: 32px; }
  .ach-icon { font-size: 1.3rem; }
  .ach-title { font-size: 0.88rem; }
  .ach-desc { font-size: 0.71rem; }
  .badge-icon { font-size: 1.3rem; }
  .badge-title { font-size: 0.76rem; }
  .lb-like { padding: 5px 8px; font-size: 0.76rem; }
  .lb-tabs button { font-size: 0.76rem; padding: 8px 4px; }
}