/* 主题与护眼变量：日间 = 方案 A「纸本」（墨绿）；夜间 = 方案 B「清简」纯黑夜读（克制蓝） */
:root {
  --app-bg: #F7F5F0;
  --app-surface: #FFFFFF;
  --app-surface-subtle: #F1EFE8;
  --app-border: #E7E3DA;
  --app-text: #2B2A27;
  --app-muted: #8A867D;
  --app-accent: #2F6F62;
  --app-accent-hover: #25594E;
  --app-correct: #3E7D5A;
  --app-wrong: #B4533E;
  --font-ui: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  --font-word: Georgia, "Times New Roman", serif;
  --word-weight: 400;
  --word-tracking: 0.04em;
  --kb-radius: 12px;

  /* 主界面动态主题色通道：日间墨绿 (#2F6F62) */
  --theme-50: 240 245 243;
  --theme-100: 221 234 229;
  --theme-200: 188 214 205;
  --theme-300: 140 184 170;
  --theme-400: 92 148 132;
  --theme-500: 58 124 108;
  --theme-600: 47 111 98;
  --theme-700: 37 89 78;
  --theme-800: 29 71 62;
  --theme-900: 23 56 49;
  --theme-950: 13 33 29;

  /* 暖纸中性灰阶 */
  --neutral-50: 247 245 240;
  --neutral-100: 240 237 230;
  --neutral-200: 231 227 218;
  --neutral-300: 210 205 194;
  --neutral-400: 163 158 148;
  --neutral-500: 138 134 125;
  --neutral-600: 102 98 90;
  --neutral-700: 74 71 65;
  --neutral-800: 52 50 46;
  --neutral-900: 43 42 39;
  --neutral-950: 24 23 21;
}

html.dark {
  --app-bg: #000000;
  --app-surface: #0C0D10;
  --app-surface-subtle: #15171C;
  --app-border: #22252C;
  --app-text: #F4F4F5;
  --app-muted: #8E929B;
  --app-accent: #3B82F6;
  --app-accent-hover: #2563EB;
  --app-correct: #34A86A;
  --app-wrong: #D95C5C;
  --font-ui: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  --font-word: "Segoe UI", "Microsoft YaHei UI", sans-serif;
  --word-weight: 500;
  --word-tracking: 0.03em;
  --kb-radius: 10px;

  /* 主界面动态主题色通道：夜间克制蓝 (#2563EB / #3B82F6) */
  --theme-50: 239 246 255;
  --theme-100: 219 234 254;
  --theme-200: 191 219 254;
  --theme-300: 147 197 253;
  --theme-400: 96 165 250;
  --theme-500: 59 130 246;
  --theme-600: 37 99 235;
  --theme-700: 29 78 216;
  --theme-800: 30 64 175;
  --theme-900: 30 58 138;
  --theme-950: 15 26 56;

  /* 纯黑底色与中性深灰表层（消除深蓝偏色） */
  --neutral-50: 250 250 250;
  --neutral-100: 244 244 245;
  --neutral-200: 228 228 231;
  --neutral-300: 212 212 216;
  --neutral-400: 142 146 155;
  --neutral-500: 113 113 122;
  --neutral-600: 82 82 91;
  --neutral-700: 38 42 50;
  --neutral-800: 22 24 29;
  --neutral-900: 12 13 16;
  --neutral-950: 0 0 0;
}

/* 平滑过渡与护眼细节样式 */
html {
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--app-bg);
  color: var(--app-text);
  font-family: var(--font-ui);
}

input[type="range"],
input[type="checkbox"],
input[type="radio"] {
  accent-color: rgb(var(--theme-600));
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.6);
}

@keyframes soundWave {
  0%, 100% { transform: scaleY(0.4); }
  50% { transform: scaleY(1); }
}
.wave-bar {
  animation: soundWave 0.7s ease-in-out infinite;
  transform-origin: bottom;
}
.wave-bar:nth-child(2) { animation-delay: 0.15s; }
.wave-bar:nth-child(3) { animation-delay: 0.3s; }

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-fade-up {
  animation: fadeSlideUp 0.22s ease-out forwards;
}

@keyframes pulseMic {
  0%, 100% { box-shadow: 0 0 0 0 rgb(var(--theme-600) / 0.45); }
  50% { box-shadow: 0 0 0 12px rgb(var(--theme-600) / 0); }
}
.mic-listening {
  animation: pulseMic 1.4s ease-in-out infinite;
}

/* =====================================================================
   键盘默写极简零跳动视图 (日间: 方案 A「纸本」 / 夜间: 方案 B「清简」黑底)
   字号严格 5 档: 12 / 14 / 16 / 32 / 40px；字重仅 400 / 500
   ===================================================================== */
.kb-shell {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.kb-topbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kb-topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  color: var(--app-muted);
}

.kb-meta-right {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--app-muted);
  font-variant-numeric: tabular-nums;
}

.kb-text-btn {
  background: none;
  border: none;
  color: var(--app-muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  padding: 4px 0;
  transition: color 0.15s ease;
}
.kb-text-btn:hover:not(:disabled) {
  color: var(--app-text);
}
.kb-text-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.kb-progress-track {
  width: 100%;
  height: 2px;
  background: var(--app-border);
  border-radius: 1px;
  overflow: hidden;
}

.kb-progress-fill {
  height: 100%;
  background: var(--app-accent);
  transition: width 0.25s ease;
}

.kb-card {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--kb-radius);
  padding: 32px 36px 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

@media (max-width: 640px) {
  .kb-card {
    padding: 22px 18px 20px;
    gap: 14px;
  }
}

.kb-card-meta {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--app-muted);
  min-height: 24px;
}

.kb-meta-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.kb-hint-toggles {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--app-muted);
}

.kb-hint-toggle {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
  color: var(--app-muted);
  cursor: pointer;
  padding: 2px 0;
  transition: color 0.15s ease;
}
.kb-hint-toggle.on {
  color: var(--app-accent);
}

.kb-fav-btn {
  background: none;
  border: none;
  padding: 2px;
  color: var(--app-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease;
}
.kb-fav-btn.is-active {
  color: var(--app-accent);
}

.kb-replay-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--app-border);
  background: var(--app-bg);
  color: var(--app-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.kb-replay-btn:hover {
  border-color: var(--app-accent);
}

.kb-meaning-wrap {
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
}

.kb-first-hint {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  letter-spacing: 0.22em;
  color: var(--app-accent);
}

.kb-meaning {
  font-size: 16px;
  font-weight: 400;
  color: var(--app-muted);
  line-height: 1.6;
}
.kb-meaning.is-hidden-note {
  font-size: 14px;
}

.kb-input-wrap {
  width: 100%;
  max-width: 460px;
}

.kb-word-input {
  width: 100%;
  border: none;
  border-bottom: 1.5px solid var(--app-border);
  background: transparent;
  text-align: center;
  font-family: var(--font-word);
  font-size: 40px;
  font-weight: var(--word-weight);
  letter-spacing: var(--word-tracking);
  color: var(--app-text);
  padding: 8px 4px;
  line-height: 1.25;
  outline: none;
  border-radius: 0;
}
.kb-word-input.is-answering:focus,
.kb-word-input.is-answering,
.kb-word-input.is-retrying {
  border-bottom-color: var(--app-accent);
}
.kb-word-input.is-correct {
  border-bottom-color: var(--app-correct);
  color: var(--app-correct);
}
.kb-word-input.is-wrong {
  border-bottom-color: var(--app-wrong);
  color: var(--app-wrong);
}

.kb-feedback-slot {
  width: 100%;
  height: 152px;
  min-height: 152px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  border-top: 1px solid transparent;
}
.kb-feedback-slot.is-graded {
  border-top-color: var(--app-border);
  padding-top: 12px;
  justify-content: space-between;
}
.kb-feedback-slot.is-retrying .kb-status-line {
  display: none;
}
@media (max-width: 560px) {
  .kb-feedback-slot {
    height: auto;
    min-height: 152px;
  }
}

.kb-quiet-hint {
  font-size: 12px;
  color: var(--app-muted);
  text-align: center;
}

.kb-feedback-box {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.kb-card .kb-correct-word {
  font-family: var(--font-word);
  font-size: 32px;
  font-weight: var(--word-weight);
  letter-spacing: 0.05em;
  color: var(--app-correct);
  line-height: 1.2;
  word-break: break-word;
  text-align: center;
}

.kb-typed-row {
  font-size: 14px;
  color: var(--app-muted);
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.kb-typed-word {
  font-family: var(--font-word);
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--app-text);
  word-break: break-word;
}

.kb-skipped-text {
  font-size: 12px;
  color: var(--app-muted);
}

.kb-diff-del {
  color: var(--app-wrong);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  padding: 0 1.5px;
}

.kb-diff-miss {
  color: var(--app-accent);
  text-decoration: underline;
  text-underline-offset: 4px;
  padding: 0 1.5px;
}

.kb-confusable-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--app-muted);
}

.kb-confusable-warn {
  color: var(--app-wrong);
}

.kb-confusable-chip {
  background: none;
  border: 1px solid var(--app-border);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 12px;
  font-family: var(--font-word);
  color: var(--app-text);
  cursor: pointer;
}
.kb-confusable-chip:hover {
  border-color: var(--app-accent);
  color: var(--app-accent);
}

.kb-status-line,
.kb-retry-line {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--app-muted);
}

.kb-retry-line {
  justify-content: center;
  color: var(--app-accent);
}

.kb-inline-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
}

.kb-inline-btn {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
  color: var(--app-accent);
  cursor: pointer;
  padding: 0;
}
.kb-inline-btn:hover:not(:disabled) {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.kb-inline-btn:disabled {
  color: var(--app-muted);
  cursor: default;
}

.kb-bottombar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 14px;
  color: var(--app-muted);
}

.kb-bottom-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.kb-bottom-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.kb-shortcut-text {
  font-size: 12px;
  color: var(--app-muted);
}

.kb-primary-btn {
  background: var(--app-accent);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.kb-primary-btn:hover {
  background: var(--app-accent-hover);
}

/* 仿原书双栏单词表预览与打印样式（无题号画圈） */
.book-sheet {
  background: #ffffff;
  color: #111827;
  width: 100%;
  max-width: 794px;
  margin: 0 auto 20px auto;
  padding: 20px 22px 16px 22px;
  border-radius: 12px;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.12);
  font-family: "Times New Roman", "Songti SC", "SimSun", Georgia, serif;
}
.book-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
}
.book-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  border: 1.5px solid #1e293b;
  font-size: 11px;
  line-height: 1.28;
}
.book-table th,
.book-table td {
  border: 1px solid #475569;
  padding: 2.5px 4px;
  vertical-align: middle;
  word-break: break-word;
}
.book-table thead th {
  background: #f1f5f9;
  font-weight: 700;
  text-align: center;
  padding: 4px 4px;
  font-size: 11.5px;
}
.book-table .col-num {
  width: 5.5%;
  text-align: center;
  font-weight: 600;
}
.book-table .col-word {
  width: 15.5%;
  font-weight: 600;
  font-size: 11.5px;
}
.book-table .col-meaning {
  width: 29%;
  font-size: 10.5px;
}
.book-table .col-divider {
  border-right: 2px solid #0f172a;
}
.book-sheet-footer {
  text-align: center;
  font-size: 11px;
  color: #475569;
  margin-top: 8px;
}

#printOnlyArea {
  display: none;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 8mm 8mm 10mm 8mm;
  }
  html,
  body {
    margin: 0;
    padding: 0;
    background: #ffffff !important;
    color: #111827 !important;
  }
  body > *:not(#printOnlyArea) {
    display: none !important;
  }
  #printOnlyArea {
    display: block !important;
    background: #ffffff !important;
  }
  .book-sheet {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    page-break-after: always;
    break-after: page;
    page-break-inside: avoid;
    break-inside: avoid;
  }
  .book-sheet-full {
    height: 277mm;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
  }
  .book-sheet-full .book-table {
    flex: 1 1 auto;
  }
  .book-table tbody td {
    height: 7.2mm;
  }
  .book-table {
    font-size: 11.5px;
  }
  .book-table .col-word {
    font-size: 12.5px;
  }
  .book-table .col-meaning {
    font-size: 11px;
  }
  .book-sheet:last-child {
    page-break-after: auto;
    break-after: auto;
  }
}

/* =====================================================================
   离线兜底样式：当 Tailwind CDN 未加载（断网 / 手机离线打开）时启用
   ===================================================================== */
body.no-tailwind .hidden { display: none !important; }
body.no-tailwind .pointer-events-none { pointer-events: none; }
body.no-tailwind svg { width: 20px; height: 20px; flex: none; }
body.no-tailwind svg[viewBox="0 0 120 120"] { width: 100%; height: 100%; }
body.no-tailwind header > div { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; }
body.no-tailwind .fixed { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 50; overflow: auto; background: rgba(15, 23, 42, 0.55); }
body.no-tailwind .fixed > div { margin: 24px auto; max-width: 760px; background: #fff; color: #1e293b; border-radius: 16px; padding: 16px 18px; box-sizing: border-box; }
html.dark body.no-tailwind .fixed > div { background: #0C0D10; color: #F4F4F5; border: 1px solid #22252C; }
body.no-tailwind #toastContainer { position: fixed; top: auto; right: auto; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 60; width: 90%; max-width: 384px; background: transparent; overflow: visible; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 8px; }
body.no-tailwind #toastContainer > div { margin: 0; padding: 8px 14px; border-radius: 12px; background: #2B2A27; color: #ffffff; font-size: 13px; }
body.no-tailwind main { max-width: 880px; margin: 0 auto; padding: 12px 12px 72px; }
body.no-tailwind header { background: var(--app-bg); border-bottom: 1px solid var(--app-border); }
html.dark body.no-tailwind header { background: #000000; border-bottom-color: #22252C; }
body.no-tailwind .grid { display: flex; flex-wrap: wrap; gap: 8px; }
body.no-tailwind button { cursor: pointer; border: 1px solid var(--app-border); background: var(--app-surface); color: inherit; border-radius: 10px; padding: 7px 11px; font-size: 14px; }
body.no-tailwind input,
body.no-tailwind select,
body.no-tailwind textarea { font: inherit; padding: 8px; border: 1px solid var(--app-border); border-radius: 10px; width: 100%; box-sizing: border-box; background: var(--app-surface); color: inherit; }
body.no-tailwind input[type="checkbox"],
body.no-tailwind input[type="radio"],
body.no-tailwind input[type="range"] { width: auto; }
body.no-tailwind section { margin-bottom: 18px; }
body.no-tailwind .book-sheet { box-shadow: none; border: 1px solid #94a3b8; margin-bottom: 12px; }
body.no-tailwind .book-table th,
body.no-tailwind .book-table td { padding: 3px 5px; }
body.no-tailwind #mainNav { display: flex !important; flex-wrap: wrap; gap: 4px; }
body.no-tailwind #mainNav button { margin: 2px 4px 2px 0; }
body.no-tailwind #mobileNav { display: none !important; }
