:root {
  --font-main: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --bg-page: #f6f5ef;
  --bg-card: #ffffff;
  --text-main: #20362c;
  --text-muted: #6f8275;
  --text-subtle: #8e9e93;
  --border-light: #dbe2d9;
  --border-focus: #285b4c;
  --brand-green: #285b4c;
  --brand-green-hover: #1e473b;
  --brand-green-light: #eef6f1;
  --brand-green-border: #badbca;
  --wrong-red: #c93535;
  --wrong-red-bg: #fdf2f0;
  --wrong-red-border: #f4c7c2;
  --skipped-bg: #f4f5f2;
  --skipped-border: #dcded8;
  font-family: var(--font-main);
  color: var(--text-main);
  background: var(--bg-page);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 36px 28px 48px;
}

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

.header-actions {
  display: flex;
  gap: 8px;
}

.brand {
  font-size: 26px;
  font-weight: 800;
  text-decoration: none;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.brand small {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-subtle);
  margin-top: 4px;
}

button, select, input {
  font: inherit;
}

button {
  border: 1px solid var(--border-light);
  background: #ffffff;
  color: var(--text-main);
  border-radius: 10px;
  padding: 9px 18px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
}

button:hover {
  background: #f0f4ee;
  border-color: #cbd6c9;
}

button:disabled {
  opacity: .5;
  cursor: wait;
}

button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible {
  outline: 2px solid #b79b57;
  outline-offset: 2px;
}

nav {
  display: flex;
  gap: 8px;
}

nav button {
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 8px;
  color: var(--text-muted);
  border-color: transparent;
  background: transparent;
}

nav button:hover {
  background: #ebeee8;
  color: var(--text-main);
}

nav .active {
  background: var(--brand-green);
  color: #ffffff;
  border-color: var(--brand-green);
  font-weight: 600;
}

nav .active:hover {
  background: var(--brand-green-hover);
  color: #ffffff;
}

/* 统计那行压低视觉权重，低调克制 */
.stats {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin: 18px 0 10px;
  color: var(--text-subtle);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.2px;
}

.stats strong {
  color: var(--text-muted);
  font-weight: 600;
}

progress {
  display: block;
  width: 100%;
  height: 3px;
  accent-color: var(--brand-green);
  margin: 0 0 24px;
  border: 0;
  border-radius: 3px;
  background-color: #e4e9e1;
}

/* 核心练习卡片：稳固居中，固定或最小高度保证不跳动 */
.practice {
  background: var(--bg-card);
  border: 1px solid #dfe5dc;
  border-radius: 20px;
  min-height: 430px;
  padding: 36px 44px 32px;
  box-shadow: 0 8px 30px rgba(32, 54, 44, 0.04);
  position: relative;
}

.eyebrow {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-subtle);
}

h1 {
  font-size: 36px;
  font-weight: 700;
  margin: 32px 0 12px;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

#subtitle {
  color: var(--text-muted);
  font-size: 16px;
  margin: 0 0 32px;
}

.primary {
  background: var(--brand-green);
  border-color: var(--brand-green);
  color: #ffffff;
  font-weight: 600;
}

.primary:hover {
  background: var(--brand-green-hover);
  border-color: var(--brand-green-hover);
}

/* 题目与重听 */
.sound {
  border: 0;
  font-size: 26px;
  padding: 14px 0 4px;
  background: transparent;
  color: var(--brand-green);
  display: inline-flex;
  align-items: center;
}

.sound:hover {
  background: transparent;
  color: var(--brand-green-hover);
}

.sound span {
  font-size: 14px;
  font-weight: 600;
  margin-left: 8px;
  color: var(--text-main);
}

#audioStatus, #message {
  font-size: 12px;
  color: var(--text-subtle);
  min-height: 18px;
  margin: 2px 0 4px;
}

#hint {
  font-size: 15px;
  color: var(--text-muted);
  background: #f7faf7;
  border-left: 3px solid var(--brand-green);
  padding: 8px 12px;
  margin: 10px 0;
  border-radius: 0 6px 6px 0;
}

/* 答题输入框：放大、字重加厚，强化打字焦点手感 */
#answerForm {
  display: flex;
  gap: 16px;
  margin-top: 14px;
  align-items: center;
}

#answer {
  min-width: 0;
  flex: 1;
  border: 0;
  border-bottom: 3px solid #b6c8bb;
  background: transparent;
  padding: 10px 4px;
  font-size: 34px;
  font-weight: 650;
  letter-spacing: 0.5px;
  color: #1a3328;
  border-radius: 0;
  transition: border-color .15s ease;
}

#answer:focus {
  outline: 0;
  border-bottom-color: var(--brand-green);
}

#answer::placeholder {
  color: #abbcb0;
  font-weight: 400;
  font-size: 28px;
}

#submit {
  height: 52px;
  padding: 0 24px;
  font-size: 16px;
  border-radius: 12px;
  white-space: nowrap;
}

/* 反馈区：固定最小高度以防止页面顶动，结构规整清晰 */
#feedback {
  min-height: 116px;
  margin: 16px 0 12px;
  box-sizing: border-box;
}

.feedback-empty {
  visibility: hidden;
  height: 116px;
  min-height: 116px;
}

.feedback-card {
  box-sizing: border-box;
  min-height: 116px;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  justify-content: center;
  animation: fbFadeIn .12s ease-out;
}

@keyframes fbFadeIn {
  from { opacity: 0; transform: translateY(-2px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 状态徽章与头部 */
.fb-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.fb-badge {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 6px;
  letter-spacing: 0.2px;
}

.fb-word {
  font-size: 24px;
  font-weight: 750;
  letter-spacing: 0.5px;
}

/* 正确状态：温润森林绿 */
.is-correct {
  background: var(--brand-green-light);
  border-color: var(--brand-green-border);
}

.badge-correct {
  background: #d8ece0;
  color: #175435;
}

.is-correct .fb-word {
  color: #14482d;
}

/* 错误状态：克制砖红 */
.is-wrong {
  background: var(--wrong-red-bg);
  border-color: var(--wrong-red-border);
}

.badge-wrong {
  background: #fadcd9;
  color: var(--wrong-red);
}

/* 跳过状态：低饱和中性 */
.is-skipped {
  background: var(--skipped-bg);
  border-color: var(--skipped-border);
}

.badge-skipped {
  background: #e5e7e1;
  color: #5c635b;
}

/* 错题/跳过对比行：并排展示 */
.fb-comp-row, .fb-spelling-row {
  display: flex;
  align-items: baseline;
  gap: 28px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.fb-diff-wrap, .fb-right-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.fb-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

/* 逐字 diff 样式强化：错字带醒目下划线与高亮 */
.spelling {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 1.5px;
  font-family: inherit;
}

.spelling .wrong {
  color: #ba2323;
  background: #fbd6d2;
  border-bottom: 2.5px solid #c92828;
  border-radius: 2px 2px 0 0;
  padding: 0 1px;
  margin: 0 0.5px;
}

.fb-correct-word {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #1a4f32;
}

.is-wrong .fb-correct-word {
  color: #1f5737;
}

.is-skipped .fb-correct-word {
  color: #244133;
}

/* 重试输入时隐藏正确答案，只留中文释义，避免照着抄 */
#feedback.is-retrying .fb-correct-word,
#feedback.is-retrying .fb-comp-row,
#feedback.is-retrying .fb-spelling-row,
#feedback.is-retrying .fb-label,
#feedback.is-retrying .fb-word {
  display: none;
}

#feedback.is-retrying .fb-header {
  min-height: 0;
  margin-bottom: 2px;
}

#feedback.is-retrying .fb-gloss {
  margin-top: 2px;
  font-size: 15px;
}

/* 中文释义：次级样式，小一号灰一点，CSS line-clamp 限制 2 行 */
.fb-gloss {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.45;
  color: #576b5f;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.2px;
}

.fb-gloss-empty {
  color: var(--text-subtle);
  font-style: italic;
}

/* 辅助操作栏 */
.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.actions button {
  font-size: 13px;
  padding: 8px 14px;
  color: var(--text-muted);
  border-radius: 8px;
}

.actions button:hover {
  color: var(--text-main);
}

/* 底部按键提示 */
footer {
  font-size: 12px;
  line-height: 2.3;
  color: var(--text-subtle);
  text-align: center;
  margin: 28px 0;
}

kbd {
  font-family: inherit;
  border: 1px solid #d4ded4;
  background: #ffffff;
  border-radius: 4px;
  padding: 2px 6px;
  color: #3b5446;
  box-shadow: 0 1px 1px rgba(0,0,0,0.04);
}

details, .muted {
  font-size: 12px;
  color: var(--text-subtle);
  margin-top: 18px;
}

dialog {
  border: 1px solid #cbd4ca;
  border-radius: 18px;
  padding: 28px;
  max-width: 480px;
  width: calc(100% - 32px);
  color: var(--text-main);
  background: #ffffff;
  box-shadow: 0 16px 48px rgba(0,0,0,0.12);
}

dialog::backdrop {
  background: rgba(28, 45, 36, 0.45);
}

dialog label {
  display: block;
  margin: 18px 0;
  font-size: 14px;
}

dialog input[type=number], dialog select {
  padding: 6px 8px;
  border: 1px solid #bccabd;
  border-radius: 6px;
  max-width: 140px;
  margin-left: 12px;
}

dialog input[type=checkbox] {
  accent-color: var(--brand-green);
  width: 16px;
  height: 16px;
  vertical-align: middle;
  margin-right: 6px;
}

h2 {
  font-size: 22px;
  margin-top: 0;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

[hidden] {
  display: none !important;
}

/* 词表视图容器与卡片 */
#wordListView {
  background: var(--bg-card);
  border: 1px solid #dfe5dc;
  border-radius: 20px;
  padding: 24px 28px 32px;
  box-shadow: 0 8px 30px rgba(32, 54, 44, 0.04);
}

.wl-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid #ebf0ea;
}

.wl-summary {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}

.wl-controls {
  margin: 18px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wl-search-row {
  display: flex;
  gap: 12px;
}

#wlSearch {
  flex: 1;
  padding: 10px 14px;
  font-size: 15px;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  background: #fbfcfb;
  color: var(--text-main);
  outline: 0;
  transition: border-color .15s ease;
}

#wlSearch:focus {
  border-color: var(--brand-green);
  background: #ffffff;
}

#wlSort {
  padding: 10px 14px;
  font-size: 14px;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  background: #ffffff;
  color: var(--text-main);
  cursor: pointer;
}

.wl-chips {
  display: flex;
  gap: 10px 8px;
  flex-wrap: wrap;
}

.chip {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 9px;
  border: 1px solid var(--border-light);
  background: #ffffff;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s ease;
}

.chip:hover {
  background: #f0f4ee;
  color: var(--text-main);
}

.chip.active {
  background: var(--brand-green);
  border-color: var(--brand-green);
  color: #ffffff;
  font-weight: 600;
}

/* 词表表格 */
.wl-table-wrap {
  overflow-x: auto;
  margin-top: 8px;
  max-height: 68vh;
  overflow-y: auto;
  border: 1px solid #ebf0ea;
  border-radius: 12px;
}

.wl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  text-align: left;
}

.wl-table thead {
  position: sticky;
  top: 0;
  background: #f7faf7;
  z-index: 2;
  box-shadow: 0 1px 0 #ebf0ea;
}

.wl-table th {
  padding: 12px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-subtle);
  letter-spacing: 0.5px;
}

.wl-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f2f5f1;
  color: var(--text-main);
}

.wl-row {
  cursor: pointer;
  transition: background .12s ease;
}

.wl-row:hover {
  background: #f7faf8;
}

.wl-row.is-expanded {
  background: #f0f7f3;
}

.wl-word-cell {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-main);
  white-space: nowrap;
}

.wl-gloss-cell {
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-muted);
}

.wl-num-cell {
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.wl-num-cell.has-wrong {
  color: var(--wrong-red);
  font-weight: 600;
}

.wl-due-cell {
  font-variant-numeric: tabular-nums;
  color: var(--text-subtle);
  font-size: 13px;
  white-space: nowrap;
}

/* 状态徽章 */
.wl-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 4px;
  white-space: nowrap;
}

.badge-unlearned {
  background: #eef0ec;
  color: #7b857c;
}

.badge-mastered {
  background: #e2f4ea;
  color: #17683f;
}

.badge-wrong {
  background: #fadcd9;
  color: var(--wrong-red);
  font-weight: 700;
}

/* 展开行详情 */
.wl-detail-row td {
  padding: 0;
  background: #eef6f1;
  border-bottom: 1px solid #dce8e0;
}

.wl-expanded-content {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.wl-expanded-text {
  line-height: 1.5;
  color: #244133;
}

.wl-listen-btn {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid var(--brand-green-border);
  color: var(--brand-green);
  white-space: nowrap;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
}

.wl-listen-btn:hover {
  background: var(--brand-green);
  color: #ffffff;
}

.wl-empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--text-subtle);
  font-size: 15px;
}

@media(max-width: 640px) {
  #wordListView {
    padding: 16px 14px 24px;
    border-radius: 14px;
  }
  .wl-topbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px 8px;
    padding-bottom: 14px;
  }
  #closeWordListBtn {
    order: 1;
    flex: 0 0 auto;
    padding: 8px 14px;
    font-size: 13px;
    min-height: 40px;
  }
  #exportCsvBtn {
    order: 2;
    flex: 0 0 auto;
    padding: 8px 14px;
    font-size: 13px;
    min-height: 40px;
  }
  .wl-summary {
    order: 3;
    width: 100%;
    margin: 4px 0 0;
    padding: 10px 12px;
    background: #f4f7f4;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
    letter-spacing: 0.2px;
    box-sizing: border-box;
  }
  .wl-search-row {
    flex-direction: column;
    gap: 8px;
  }
  .wl-table thead {
    display: none;
  }
  .wl-table, .wl-table tbody, .wl-table tr, .wl-table td {
    display: block;
    width: 100%;
  }
  .wl-table-wrap {
    border: 0;
    max-height: none;
    overflow-y: visible;
  }
  .wl-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    background: #ffffff;
    border: 1px solid #e1e8de;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.02);
  }
  .wl-row td {
    border: 0;
    padding: 0;
    text-align: left;
  }
  .wl-row td.wl-word-cell {
    flex: 1;
    font-size: 18px;
    font-weight: 700;
  }
  .wl-row td.wl-status-cell {
    display: inline-block;
    width: auto;
    margin-left: auto;
    text-align: right;
  }
  .wl-row td.wl-gloss-cell {
    width: 100%;
    margin: 6px 0 10px;
    max-width: none;
    white-space: normal;
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.45;
  }
  .wl-row td.wl-num-cell, .wl-row td.wl-due-cell {
    display: inline-flex;
    align-items: center;
    width: auto;
    font-size: 12px;
    margin-right: 14px;
    margin-top: 2px;
    color: var(--text-muted);
    white-space: nowrap;
  }
  .wl-row .wl-num-cell::before {
    content: attr(data-label);
    color: var(--text-subtle);
    font-size: 12px;
    margin-right: 4px;
  }
  .wl-row .wl-due-cell::before {
    content: "复习";
    color: var(--text-subtle);
    font-size: 12px;
    margin-right: 4px;
  }
  .wl-detail-row {
    margin-top: -8px;
    margin-bottom: 12px;
    border-radius: 0 0 12px 12px;
  }
  .wl-expanded-content {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .wl-listen-btn {
    min-height: 40px;
    justify-content: center;
    font-size: 13px;
  }
}

@media(max-width: 600px) {
  main {
    padding: 20px 14px 36px;
  }
  .practice {
    padding: 24px 18px;
    border-radius: 16px;
  }
  h1 {
    font-size: 28px;
  }
  .stats {
    gap: 12px;
  }
  #answerForm {
    flex-wrap: wrap;
  }
  #answer {
    width: 100%;
    font-size: 26px;
  }
  #submit {
    width: 100%;
  }
  .fb-comp-row {
    flex-direction: column;
    gap: 8px;
  }
  .brand small {
    font-size: 8px;
  }
  header button {
    font-size: 12px;
  }
  footer {
    font-size: 11px;
  }
}

/* 云端同步指示器与设置样式 */
.sync-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid #dce2da;
  font-size: 11px;
  color: var(--text-subtle);
  cursor: pointer;
  margin: 12px auto 0;
  width: fit-content;
  transition: all .15s ease;
}
.sync-indicator:hover {
  border-color: #bccabd;
  color: var(--text-main);
}
.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot-local {
  background: #9faaa1;
}
.dot-synced {
  background: #2a945d;
  box-shadow: 0 0 0 2px rgba(42, 148, 93, 0.2);
}
.dot-syncing {
  background: #df9e28;
  box-shadow: 0 0 0 2px rgba(223, 158, 40, 0.2);
  animation: pulseDot 1s infinite alternate;
}
.dot-error {
  background: #d93838;
  box-shadow: 0 0 0 2px rgba(217, 56, 56, 0.2);
}
.dot-pending {
  background: #df9e28;
  box-shadow: 0 0 0 2px rgba(223, 158, 40, 0.16);
}
@keyframes pulseDot {
  from { opacity: 0.5; }
  to { opacity: 1; }
}

.settings-divider {
  border: 0;
  border-top: 1px solid #e1e8df;
  margin: 20px 0 16px;
}
.sync-section h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}
.sync-desc, .sync-note {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
  margin: 4px 0 12px;
}
.sync-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
#syncTokenInput {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  font-family: monospace;
  border: 1px solid var(--border-light);
  border-radius: 8px;
}
.sync-code-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f4f7f4;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #dce5dc;
  margin-bottom: 8px;
}
.sync-code-box code {
  flex: 1;
  font-size: 11px;
  word-break: break-all;
  color: #1a422f;
  font-family: monospace;
}
.sync-actions-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}
.danger {
  color: var(--wrong-red);
  border-color: var(--wrong-red-border);
}
.danger:hover {
  background: var(--wrong-red-bg);
}
.sync-msg {
  font-size: 12px;
  min-height: 18px;
  margin-top: 8px;
  color: var(--text-muted);
}
.sync-msg.is-error {
  color: var(--wrong-red);
}
.sync-msg.is-success {
  color: var(--brand-green);
}
.settings-footer {
  margin-top: 24px;
  text-align: right;
}
