/* macOS 风格打字练习 — 全屏大字号 */
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.macos-desk {
  --ink: #1c2430;
  --muted: #6b7280;
  --line: rgba(28, 36, 48, 0.08);
  --blue: #007aff;
  --blue-press: #0062cc;
  --green: #28c840;
  --yellow: #febc2e;
  --red: #ff5f57;
  --orange: #ff9500;
  --glass: rgba(255, 255, 255, 0.82);
  --panel: rgba(255, 255, 255, 0.92);
  --skin: #f0c4a8;
  --skin-dark: #d9a88a;
  --skin-light: #ffe8dc;
  --finger-glow: #ff9500;
  --letter-size: clamp(120px, 26vh, 260px);
  --word-size: clamp(48px, 10vh, 96px);
  --kb-scale: 1.25;
  --key-h: calc(clamp(46px, 6.8vh, 62px) * var(--kb-scale));
  --key-font: calc(clamp(15px, 2.2vh, 20px) * var(--kb-scale));
  --queue-size: calc(clamp(48px, 6.5vh, 64px) * var(--kb-scale));
  --layout-pad-x: 10px;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  box-sizing: border-box;
}

.desk-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 70% 55% at 12% 8%, rgba(147, 197, 253, 0.38), transparent 58%),
    radial-gradient(ellipse 55% 45% at 88% 18%, rgba(165, 243, 252, 0.3), transparent 52%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(226, 232, 240, 0.92), transparent 60%),
    linear-gradient(165deg, #dbeafe 0%, #e2e8f0 42%, #f1f5f9 100%);
}

.mac-window {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  border-radius: 0;
  overflow: hidden;
  background: var(--glass);
  backdrop-filter: saturate(160%) blur(24px);
  -webkit-backdrop-filter: saturate(160%) blur(24px);
  border: none;
  box-shadow: none;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 8px var(--layout-pad-x) 6px;
  background: transparent;
  border-bottom: none;
}

.toolbar-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px 16px;
  flex-wrap: nowrap;
  position: relative;
  width: 100%;
  max-width: 100%;
  min-height: clamp(52px, 7vh, 64px);
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: 0 2px 12px rgba(30, 58, 95, 0.06);
  box-sizing: border-box;
}

.nav-seg {
  display: inline-flex;
  flex: 0 0 auto;
  justify-content: center;
  padding: 4px;
  border-radius: 980px;
  background: rgba(118, 118, 128, 0.14);
}

.seg-btn {
  height: clamp(44px, 6.5vh, 56px);
  padding: 0 clamp(20px, 3vw, 32px);
  border: none;
  border-radius: 980px;
  background: transparent;
  font-size: clamp(18px, 2.8vh, 24px);
  font-weight: 700;
  color: #64748b;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.on {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
}

.chip {
  display: inline-flex;
  align-items: center;
  height: clamp(28px, 4vh, 32px);
  padding: 0 12px;
  border-radius: 980px;
  background: rgba(0, 122, 255, 0.12);
  color: var(--blue);
  font-size: clamp(13px, 1.8vh, 15px);
  font-weight: 600;
}
.chip.soft {
  background: rgba(118, 118, 128, 0.12);
  color: #64748b;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(16px, 2.2vh, 18px);
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  user-select: none;
}
.switch {
  position: relative;
  width: 40px;
  height: 24px;
  border-radius: 980px;
  background: rgba(118, 118, 128, 0.32);
  transition: background 0.2s;
}
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s;
}
.toggle input:checked + .switch { background: #34c759; }
.toggle input:checked + .switch::after { transform: translateX(16px); }

.content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 12px var(--layout-pad-x) 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.35), rgba(248,250,252,0.5));
  display: flex;
  flex-direction: column;
}

/* 练习页：键盘拉满，两侧只留细白边 */
.content:has(#viewDrill.active, #viewTest.active, #viewWords.active) {
  padding: 6px var(--layout-pad-x) 8px;
}

.view { display: none; flex: 1; min-height: 0; overflow: hidden; }
.view.active {
  display: flex;
  flex-direction: column;
}
.hidden { display: none !important; }

/* 首页 — 撑满一屏，三关多行居中 */
.view-home.active {
  overflow-y: auto;
  justify-content: center;
  align-items: center;
  gap: clamp(16px, 3vh, 24px);
  padding: 12px 20px;
}

.home-hero {
  text-align: center;
  width: 100%;
  max-width: min(680px, 92vw);
  padding: clamp(24px, 5vh, 48px) 24px;
  background: var(--panel);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 8px 24px rgba(30, 58, 95, 0.06);
}
.home-icon { font-size: clamp(56px, 10vh, 80px); margin-bottom: 12px; }
.home-hero h2 { margin: 0 0 12px; font-size: clamp(28px, 5vh, 40px); font-weight: 700; }
.home-hero p {
  margin: 0 auto;
  color: var(--muted);
  line-height: 1.6;
  font-size: clamp(16px, 2.4vh, 20px);
  max-width: 640px;
}

.home-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(14px, 2.5vh, 20px);
  width: 100%;
  max-width: min(680px, 92vw);
}
.home-tile {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: clamp(20px, 3.5vh, 28px) clamp(20px, 3vw, 28px);
  background: var(--panel);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 6px 20px rgba(30, 58, 95, 0.06);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  text-align: left;
}
.home-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(30, 58, 95, 0.1);
}
.tile-body { text-align: left; }
.tile-icon {
  width: clamp(52px, 8vh, 64px);
  height: clamp(52px, 8vh, 64px);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(22px, 3.5vh, 28px); font-weight: 800; color: #fff;
}
.tile-blue { background: linear-gradient(135deg, #007aff, #5856d6); }
.tile-green { background: linear-gradient(135deg, #34c759, #30b0c7); }
.tile-orange { background: linear-gradient(135deg, #ff9500, #ff6482); }
.tile-body h3 { margin: 0 0 6px; font-size: clamp(17px, 2.6vh, 22px); }
.tile-body p { margin: 0; font-size: clamp(14px, 2vh, 17px); color: var(--muted); line-height: 1.5; }
.tile-arrow { color: #cbd5e1; font-size: clamp(20px, 3vh, 26px); font-weight: 700; }

/* 练习区 — 拉满宽度，两侧留白 */
.practice-stack {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 8px;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

.zone {
  background: var(--panel);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 16px rgba(30, 58, 95, 0.05);
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
}

.zone-keyboard {
  padding: 10px 14px 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(236, 244, 255, 0.92));
  flex: 0 1 auto;
  max-height: 68vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.kb-block {
  width: fit-content;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.kb-block > [id$="Keyboard"],
.kb-block > #keyboard {
  width: fit-content;
  max-width: 100%;
}

.kb-panel { flex-shrink: 0; }

/* 键盘下方工具条 — 与键盘同宽居中 */
.kb-toolbar {
  width: 100%;
  margin-top: 8px;
  padding: 10px 8px 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.45);
  border-radius: 0 0 10px 10px;
  box-sizing: border-box;
}

.kb-toolbar .scope-hint {
  margin: 8px 0 0;
}

.kb-toolbar .type-field.compact {
  margin-top: 10px;
  width: 100%;
  max-width: 480px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.kb-toolbar .word-feedback {
  margin: 6px 0 0;
}

.bar-stats-row {
  gap: 6px;
}

.bar-score.score-accent b {
  color: var(--blue);
}

.bar-btn-primary {
  background: var(--blue);
  color: #fff;
}

.bar-btn-primary:hover {
  background: var(--blue-press);
  color: #fff;
}

.bar-btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
}

#testStart {
  min-width: 6.5em;
}

.kb-shell {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.type-queue {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(8px, 1.1vw, 12px);
  padding: 8px 4px 12px;
  flex-wrap: wrap;
  width: fit-content;
  max-width: 100%;
  min-height: calc(var(--queue-size) + 20px);
  box-sizing: border-box;
}

.queue-key {
  width: var(--queue-size);
  min-width: var(--queue-size);
  height: var(--queue-size);
  padding: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(clamp(24px, 3.8vh, 34px) * var(--kb-scale));
  font-weight: 800;
  color: #64748b;
  background: linear-gradient(180deg, #ffffff 0%, #eef2f7 100%);
  box-shadow: 0 2px 0 #b8c4d0, 0 3px 8px rgba(30, 58, 95, 0.08);
}

.queue-key.active {
  color: #0f172a;
  background: linear-gradient(180deg, #e2e8f0 0%, #cbd5e1 100%);
  box-shadow: 0 2px 0 #94a3b8, inset 0 1px 2px rgba(255, 255, 255, 0.8);
}

.queue-key.done {
  opacity: 0.45;
  color: #94a3b8;
}

/* 全键盘 — 正方形键帽，整体居中，两侧自然留白 */
.keyboard {
  display: flex;
  flex-direction: column;
  gap: clamp(5px, 0.75vh, 8px);
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  padding: clamp(10px, 1.4vh, 14px);
  border-radius: 10px;
  background: linear-gradient(180deg, #dce4ee 0%, #c5d0dc 100%);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.07);
}

.kb-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(4px, 0.65vw, 7px);
  width: fit-content;
}

.kb-key {
  flex: 0 0 auto;
  box-sizing: border-box;
  width: calc(var(--key-h) * var(--key-w, 1));
  height: var(--key-h);
  border-radius: 8px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--key-font);
  font-weight: 700;
  color: #334155;
  position: relative;
  user-select: none;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.14), 0 2px 5px rgba(0, 0, 0, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.55);
  transition: transform 0.1s, box-shadow 0.1s, background 0.1s, color 0.1s;
  padding: 2px 4px;
  line-height: 1;
}

.kb-key.kb-dual {
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  padding: 4px 6px 5px;
}

.kb-key .key-top {
  align-self: flex-end;
  font-size: 0.62em;
  font-weight: 700;
  opacity: 0.8;
  line-height: 1;
  padding-right: 2px;
}

.kb-key .key-bottom {
  align-self: center;
  font-size: 1.05em;
  font-weight: 800;
  line-height: 1;
  margin-top: auto;
}

.kb-key.kb-wide { font-size: clamp(11px, 1.6vh, 14px); font-weight: 600; }
.kb-key.kb-wide.kb-dual .key-bottom { font-size: 0.95em; }

/* 手指分区颜色 */
.kb-key.zone-l4 { background: linear-gradient(180deg, #ffe4ec, #ffc9d8); color: #9d174d; }
.kb-key.zone-l3 { background: linear-gradient(180deg, #f3e8ff, #e9d5ff); color: #7e22ce; }
.kb-key.zone-l2 { background: linear-gradient(180deg, #dbeafe, #bfdbfe); color: #1d4ed8; }
.kb-key.zone-l1 { background: linear-gradient(180deg, #ffffff, #f1f5f9); color: #334155; }
.kb-key.zone-r1 { background: linear-gradient(180deg, #ffffff, #f1f5f9); color: #334155; }
.kb-key.zone-r2 { background: linear-gradient(180deg, #dbeafe, #bfdbfe); color: #1d4ed8; }
.kb-key.zone-r3 { background: linear-gradient(180deg, #f3e8ff, #e9d5ff); color: #7e22ce; }
.kb-key.zone-r4 { background: linear-gradient(180deg, #ffe4ec, #ffc9d8); color: #9d174d; }
.kb-key.zone-mod { background: linear-gradient(180deg, #ede9fe, #ddd6fe); color: #5b21b6; font-size: clamp(11px, 1.6vh, 14px); }

.kb-key.highlight {
  color: #fff !important;
  background: linear-gradient(180deg, #67e8f9 0%, #06b6d4 55%, #0891b2 100%) !important;
  box-shadow:
    0 2px 0 #0e7490,
    0 0 18px rgba(6, 182, 212, 0.65),
    inset 0 2px 4px rgba(255, 255, 255, 0.3) !important;
  transform: translateY(2px) scale(0.98);
  z-index: 2;
  animation: keyGlowCyan 1.1s ease infinite;
}
.kb-key.highlight .key-top,
.kb-key.highlight .key-bottom { color: #fff !important; opacity: 1; }

.kb-key.flash-correct {
  background: linear-gradient(180deg, #bbf7d0, #4ade80) !important;
  color: #14532d !important;
  box-shadow: 0 2px 0 #16a34a !important;
}

.kb-key.flash-wrong {
  background: linear-gradient(180deg, #fecaca, #f87171) !important;
  color: #7f1d1d !important;
  animation: shake 0.28s;
}

.kb-row-space {
  justify-content: center;
  width: 100%;
}

.kb-row-space .kb-key {
  flex: 0 0 auto;
}

.zone-hands {
  padding: 0;
  flex: 1;
  min-height: clamp(120px, 18vh, 180px);
  max-height: 26vh;
  overflow: hidden;
  display: flex;
  align-items: stretch;
}

.hands-stage {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  width: 100%;
  height: 100%;
  min-height: clamp(120px, 18vh, 180px);
  padding: 4px 12px 8px;
}

.hands-wrap {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: clamp(12px, 3vw, 36px);
  width: 100%;
  max-width: min(920px, 96vw);
  height: 100%;
}

.hand-side {
  position: relative;
  flex: 0 1 auto;
  height: min(22vh, 200px);
  max-height: 100%;
  transition: opacity 0.2s ease;
}

.hand-side.dim {
  opacity: 0.45;
}

.hand-photo {
  display: block;
  height: 100%;
  width: auto;
  max-width: min(42vw, 420px);
  object-fit: contain;
  object-position: bottom center;
  user-select: none;
  pointer-events: none;
  -webkit-user-drag: none;
}

.finger-spot {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 0;
  height: 0;
  pointer-events: none;
}

.finger-tip-ring {
  position: absolute;
  left: 0;
  top: 0;
  width: clamp(18px, 2.8vh, 26px);
  height: clamp(18px, 2.8vh, 26px);
  transform: translate(-50%, -50%);
  border: 2px solid #ff5722;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.15s;
  box-sizing: border-box;
}

.finger-tip-glow {
  position: absolute;
  left: 0;
  top: 0;
  width: clamp(10px, 1.6vh, 14px);
  height: clamp(10px, 1.6vh, 14px);
  transform: translate(-50%, -50%);
  background: #ff9800;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.15s;
  box-shadow: 0 0 6px rgba(255, 152, 0, 0.7);
}

.finger-tip-ring.show,
.finger-tip-glow.show {
  opacity: 1;
}

.finger-tip-glow.show {
  animation: tipPulse 0.85s ease infinite;
}

.finger-tip-ring.show {
  animation: ringPulse 0.85s ease infinite;
}

.scope-hint {
  margin: 8px 0 0;
  text-align: center;
  font-size: clamp(12px, 1.6vh, 14px);
  color: #94a3b8;
  line-height: 1.45;
  padding: 0 8px;
}

/* 底部工具条 — 简洁 macOS 风格（位于键盘下方） */
.drill-bar,
.test-bar,
.word-bar {
  padding: 10px 8px 12px;
  background: transparent;
  border-top: none;
}

/* 速度测试：工具条与手势区拉开，避免手指图挡住计时 */
#viewTest .practice-stack {
  gap: 6px;
}

#viewTest .zone-keyboard.kb-panel {
  padding-bottom: 0;
  flex: 1 1 auto;
  min-height: 0;
  max-height: calc(100vh - 190px);
}

#viewTest .zone-keyboard .kb-block {
  min-height: 0;
  max-height: 100%;
}

#viewTest .test-bar {
  position: relative;
  z-index: 4;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.95);
  padding: 6px 8px 8px;
  margin-bottom: 0;
  box-shadow: none;
}

#viewTest .timer-pill {
  min-width: clamp(54px, 7vw, 68px);
  height: 36px;
  padding: 0 12px;
  font-size: clamp(17px, 2.3vh, 20px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

#viewTest .zone-hands {
  flex: 0 0 auto;
  max-height: min(15vh, 118px);
  min-height: clamp(78px, 10vh, 104px);
  margin-top: 0;
}

#viewTest .hand-side {
  height: min(14vh, 112px);
}

#viewTest .hands-stage {
  min-height: 0;
  padding-top: 0;
  padding-bottom: 4px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bar-row-center {
  justify-content: center;
}

.bar-divider {
  width: 1px;
  height: 24px;
  background: rgba(0, 0, 0, 0.1);
  margin: 0 4px;
  flex-shrink: 0;
}

.bar-select {
  height: 36px;
  padding: 0 16px;
  border-radius: 980px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  font-family: inherit;
  font-size: clamp(13px, 1.8vh, 15px);
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  outline: none;
}

.bar-select-wide {
  min-width: clamp(140px, 18vw, 200px);
}

.bar-select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.bar-btn {
  height: 36px;
  padding: 0 16px;
  border: none;
  border-radius: 980px;
  background: rgba(118, 118, 128, 0.1);
  font-family: inherit;
  font-size: clamp(13px, 1.8vh, 15px);
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: background 0.15s;
}

.bar-btn:hover {
  background: rgba(118, 118, 128, 0.16);
  color: var(--ink);
}

.bar-score {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 980px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.bar-score em {
  font-style: normal;
  font-size: 12px;
  color: #94a3b8;
  font-weight: 600;
}

.bar-score b {
  font-size: clamp(18px, 2.8vh, 22px);
  font-weight: 800;
  line-height: 1;
}

.bar-score.score-ok b { color: #16a34a; }
.bar-score.score-bad b { color: #dc2626; }

.mini-stats.inline {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 0;
}

.mini-stats.inline .mini-stat {
  min-width: 88px;
  padding: 8px 14px;
}

.mini-stats.inline .mini-stat b {
  font-size: clamp(20px, 3vh, 28px);
}

.zone-footer {
  padding: 10px 14px 12px;
  flex-shrink: 0;
}

.type-field.compact {
  height: clamp(44px, 6vh, 52px);
  font-size: clamp(20px, 3vh, 26px);
  margin-bottom: 6px;
}

.mac-btn.sm { height: clamp(32px, 4.5vh, 36px); padding: 0 14px; font-size: clamp(13px, 1.8vh, 14px); }

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.settings-row.center { justify-content: center; }

.field-label {
  font-size: clamp(14px, 2vh, 16px);
  font-weight: 600;
  color: var(--muted);
}
.mac-select {
  margin-left: 6px;
  height: clamp(34px, 5vh, 40px);
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.1);
  background: rgba(255,255,255,0.9);
  font-family: inherit;
  font-size: clamp(14px, 2vh, 16px);
}

.mac-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: clamp(38px, 5.5vh, 44px);
  padding: 0 18px;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: clamp(14px, 2vh, 16px);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.mac-btn:active { transform: scale(0.98); }
.mac-btn.primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.28);
}
.mac-btn.primary:hover { background: var(--blue-press); }
.mac-btn.soft {
  background: rgba(118, 118, 128, 0.12);
  color: var(--ink);
}
.mac-btn.soft:hover { background: rgba(118, 118, 128, 0.18); }
.mac-btn.sm { height: 32px; padding: 0 12px; font-size: 12px; }

.target-block {
  text-align: center;
  padding: clamp(8px, 2vh, 20px) 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.target-caption { font-size: clamp(16px, 2.5vh, 22px); color: var(--muted); font-weight: 600; }
.target-letter {
  font-size: var(--letter-size);
  font-weight: 800;
  line-height: 1;
  margin: clamp(8px, 2vh, 16px) 0;
  background: linear-gradient(180deg, var(--blue), #5856d6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: popIn 0.35s ease;
}
.target-sub { font-size: clamp(20px, 3.5vh, 32px); font-weight: 700; color: var(--orange); }

.mini-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: auto;
  flex-shrink: 0;
}
.mini-stats.three { grid-template-columns: repeat(3, 1fr); }
.mini-stats.four { grid-template-columns: repeat(4, 1fr); }
.mini-stat {
  text-align: center;
  padding: clamp(12px, 2vh, 18px);
  border-radius: 12px;
  background: rgba(118, 118, 128, 0.08);
}
.mini-stat span { display: block; font-size: clamp(13px, 1.8vh, 16px); color: var(--muted); font-weight: 600; }
.mini-stat b { font-size: clamp(26px, 4.5vh, 40px); font-weight: 800; }
.mini-stat small { font-size: clamp(12px, 1.6vh, 14px); color: var(--muted); margin-left: 2px; }
.mini-stat.accent b { color: var(--blue); }

.timer-pill {
  min-width: clamp(72px, 10vw, 96px);
  height: clamp(44px, 6.5vh, 56px);
  padding: 0 20px;
  border-radius: 980px;
  background: rgba(0, 122, 255, 0.12);
  color: var(--blue);
  font-size: clamp(28px, 5vh, 40px);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.timer-pill.urgent {
  background: rgba(255, 95, 87, 0.15);
  color: var(--red);
  animation: pulseHint 0.8s infinite;
}

/* 单词 — 合一界面（无手势） */
.view-words.active {
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.word-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 4px 0 0;
}

.word-kb-panel {
  flex: 0 0 auto;
  min-height: 0;
  max-height: none;
  overflow: visible;
  justify-content: center;
  align-self: center;
  width: fit-content;
  max-width: 100%;
  padding: 0;
  background: transparent;
}

.word-kb-panel.zone-keyboard {
  max-height: none;
  overflow: visible;
  background: transparent;
}

.word-kb-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(236, 244, 255, 0.92));
  border-radius: 12px;
  padding: 8px 14px 0;
  box-sizing: border-box;
  gap: 0;
}

.word-topbar {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 4px 0 8px;
  flex-shrink: 0;
  flex-wrap: nowrap;
  width: var(--word-kb-w, 100%);
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.word-kb-block > #wordKeyboard {
  align-self: center;
  width: fit-content;
  max-width: 100%;
  flex-shrink: 0;
  margin-top: 0;
}

.word-kb-block .type-queue {
  display: none !important;
}

.word-passage-panel {
  width: var(--word-kb-w, 100%);
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  --word-line-h: clamp(34px, 5.5vh, 48px);
  --word-line-step: calc(var(--word-line-h) * 1.42);
  height: calc(var(--word-line-step) * 2);
  overflow-x: hidden;
  overflow-y: auto;
  overflow-anchor: none;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 8px;
  padding: 0 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  margin: 6px 0 0;
}

.word-passage {
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  font-size: var(--word-line-h);
  line-height: 1.42;
  font-weight: 400;
  color: #334155;
  word-break: normal;
  overflow-wrap: normal;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-anchor: none;
  padding: 0;
  margin: 0;
}

.wp-word {
  display: inline-block;
  white-space: nowrap;
  vertical-align: top;
}

.wp-char {
  border-radius: 2px;
  font-weight: inherit;
}

.wp-char.done {
  color: #475569;
  background: rgba(148, 163, 184, 0.32);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.wp-char.active {
  color: #007aff;
  background: rgba(0, 122, 255, 0.14);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

#wordKeyboard .kb-key.highlight,
#wordKeyboard .kb-key.flash-correct,
#wordKeyboard .kb-key.flash-wrong {
  transform: none !important;
  animation: none !important;
  box-shadow: inset 0 0 0 2px #06b6d4 !important;
}

.wp-char.wp-space {
  display: inline-block;
  min-width: 0.35em;
  white-space: pre;
}

.wp-char.wp-space.done {
  background: rgba(148, 163, 184, 0.32);
  color: transparent;
}

.wp-char.wp-space.active {
  background: rgba(0, 122, 255, 0.35);
  color: transparent;
  box-shadow: none;
}

.word-course-pick {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: clamp(13px, 1.8vh, 15px);
  font-weight: 600;
  color: var(--muted);
  flex: 0 0 auto;
  min-width: 0;
}

.word-course-pick .mac-select {
  width: auto;
  min-width: 0;
  max-width: min(200px, 42vw);
  flex: 0 1 auto;
  padding-right: 28px;
}

.word-topbar .mac-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.word-dock {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2.5vw, 24px);
  flex-wrap: wrap;
  margin: 0 auto 4px;
  padding: clamp(10px, 1.8vh, 14px) clamp(14px, 3vw, 24px);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 18px rgba(30, 58, 95, 0.08);
  width: fit-content;
  max-width: 100%;
}

.dock-stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: clamp(13px, 1.8vh, 15px);
}

.dock-stat em {
  font-style: normal;
  color: var(--muted);
  font-weight: 600;
}

.dock-stat b {
  font-size: clamp(18px, 2.8vh, 24px);
  font-weight: 800;
  color: var(--text);
}

.dock-stat small {
  font-size: clamp(11px, 1.5vh, 13px);
  color: var(--muted);
}

.dock-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(118, 118, 128, 0.12);
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  margin-left: 8px;
  transition: background 0.15s;
}

.dock-btn:hover {
  background: rgba(118, 118, 128, 0.2);
}

.test-duration {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: clamp(14px, 2vh, 16px);
  font-weight: 600;
  color: var(--muted);
}

.bar-input {
  width: clamp(52px, 8vw, 64px);
  height: 36px;
  padding: 0 10px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  font-size: clamp(16px, 2.2vh, 18px);
  font-weight: 700;
  text-align: center;
  font-family: inherit;
  outline: none;
}

.bar-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.bar-input:disabled {
  opacity: 0.55;
}

/* 单词 — 旧 setup 样式（兼容） */

.word-setup { padding: 8px 4px; flex: 1; display: flex; flex-direction: column; justify-content: center; }
.hint-text { text-align: center; color: var(--muted); font-size: clamp(15px, 2.2vh, 18px); line-height: 1.6; }
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 20px 0 0;
  justify-content: center;
}
.tag-list li {
  padding: clamp(8px, 1.2vh, 10px) clamp(14px, 2vw, 18px);
  border-radius: 980px;
  background: rgba(118, 118, 128, 0.1);
  font-size: clamp(14px, 2vh, 17px);
  font-weight: 600;
}

.word-main { justify-content: flex-start; }
.word-head {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-shrink: 0;
}
.word-big {
  text-align: center;
  font-size: var(--word-size);
  font-weight: 800;
  letter-spacing: 2px;
  padding: clamp(16px, 4vh, 32px) 0;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.type-field {
  width: 100%;
  height: clamp(56px, 9vh, 80px);
  padding: 0 20px;
  border: 2px solid rgba(0,0,0,0.1);
  border-radius: 14px;
  background: rgba(255,255,255,0.95);
  font-size: clamp(26px, 4.5vh, 40px);
  text-align: center;
  font-family: inherit;
  outline: none;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.06);
  flex-shrink: 0;
}
.type-field:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.18);
}
.word-feedback {
  text-align: center;
  min-height: clamp(28px, 4vh, 36px);
  font-weight: 700;
  margin: 10px 0;
  font-size: clamp(16px, 2.5vh, 22px);
  flex-shrink: 0;
}
.word-feedback.ok { color: #16a34a; }
.word-feedback.bad { color: var(--red); }

.result-panel {
  text-align: center;
  padding: clamp(24px, 5vh, 40px) 24px;
  background: var(--panel);
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.85);
  box-shadow: 0 8px 24px rgba(30, 58, 95, 0.08);
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.result-panel h3 { margin: 0 0 20px; font-size: clamp(22px, 4vh, 32px); }
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.result-cell {
  padding: clamp(16px, 2.5vh, 22px);
  border-radius: 12px;
  background: rgba(118, 118, 128, 0.08);
}
.result-cell span { display: block; font-size: clamp(14px, 2vh, 16px); color: var(--muted); }
.result-cell b { font-size: clamp(32px, 5.5vh, 48px); }
.result-cell.hero b { font-size: clamp(40px, 7vh, 64px); color: var(--blue); }
.result-cell.accent b { color: var(--blue); }
.btn-row { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

.word-result-panel {
  max-width: 640px;
  margin: 0 auto;
  padding: clamp(28px, 5vh, 44px) clamp(20px, 4vw, 36px);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.98) 0%, rgba(236, 244, 255, 0.94) 100%);
  border: 1px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 16px 40px rgba(30, 58, 95, 0.12);
}

.word-result-header {
  margin-bottom: 22px;
}

.word-result-badge {
  width: clamp(52px, 8vh, 64px);
  height: clamp(52px, 8vh, 64px);
  margin: 0 auto 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(26px, 4vh, 32px);
  font-weight: 700;
  color: #fff;
  background: linear-gradient(145deg, #34d399, #059669);
  box-shadow: 0 8px 20px rgba(5, 150, 105, 0.28);
  animation: popIn 0.45s ease;
}

.word-result-panel h3 {
  margin: 0 0 6px;
  font-size: clamp(24px, 4.2vh, 34px);
  letter-spacing: 0.02em;
}

.word-result-sub {
  margin: 0;
  font-size: clamp(13px, 1.9vh, 15px);
  color: var(--muted);
  font-weight: 500;
}

.word-result-hero {
  margin-bottom: 22px;
  padding: clamp(18px, 3vh, 26px) clamp(16px, 3vw, 24px);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(0, 122, 255, 0.1) 0%, rgba(6, 182, 212, 0.08) 100%);
  border: 1px solid rgba(0, 122, 255, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.word-result-hero-label {
  display: block;
  font-size: clamp(13px, 1.9vh, 15px);
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.word-result-hero-value {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  line-height: 1;
}

.word-result-hero-value b {
  font-size: clamp(44px, 8vh, 72px);
  font-weight: 800;
  color: var(--blue);
  letter-spacing: -0.02em;
}

.word-result-hero-value small {
  font-size: clamp(16px, 2.4vh, 20px);
  font-weight: 600;
  color: #64748b;
}

.word-result-hero-meta {
  display: block;
  margin-top: 10px;
  font-size: clamp(13px, 1.9vh, 15px);
  color: #64748b;
}

.word-result-hero-meta em {
  font-style: normal;
  font-weight: 700;
  color: #334155;
  font-variant-numeric: tabular-nums;
}

.word-result-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 26px;
}

.word-result-grid .result-cell {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 2px 8px rgba(30, 58, 95, 0.04);
}

.word-result-grid .result-cell b {
  font-size: clamp(28px, 4.8vh, 40px);
}

.word-result-grid .result-cell.accent {
  background: rgba(0, 122, 255, 0.08);
  border-color: rgba(0, 122, 255, 0.12);
}

@media (min-width: 520px) {
  .word-result-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@keyframes popIn {
  from { transform: scale(0.65); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes pulseHint {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}
@keyframes queuePulse {
  0%, 100% { box-shadow: 0 3px 0 #0e7490, 0 0 20px rgba(6, 182, 212, 0.55), inset 0 2px 4px rgba(255, 255, 255, 0.35); }
  50% { box-shadow: 0 3px 0 #0e7490, 0 0 28px rgba(6, 182, 212, 0.75), inset 0 2px 4px rgba(255, 255, 255, 0.35); }
}
@keyframes keyGlowCyan {
  0%, 100% { box-shadow: 0 2px 0 #0e7490, 0 0 18px rgba(6, 182, 212, 0.65), inset 0 2px 4px rgba(255, 255, 255, 0.3); }
  50% { box-shadow: 0 2px 0 #0e7490, 0 0 26px rgba(6, 182, 212, 0.85), inset 0 2px 4px rgba(255, 255, 255, 0.3); }
}
@keyframes keyGlow {
  0%, 100% { box-shadow: 0 1px 0 #d97706, 0 0 0 3px rgba(255, 149, 0, 0.35), inset 0 2px 4px rgba(0,0,0,0.08); }
  50% { box-shadow: 0 1px 0 #d97706, 0 0 0 7px rgba(255, 149, 0, 0.15), inset 0 2px 4px rgba(0,0,0,0.08); }
}
@keyframes tipPulse {
  0%, 100% { opacity: 0.9; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
}
@keyframes ringPulse {
  0%, 100% { opacity: 0.95; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.12); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

@media (max-width: 720px) {
  .macos-desk {
    --layout-pad-x: 6px;
  }
  .mini-stats.four { grid-template-columns: repeat(2, 1fr); }
  .toolbar-inner {
    padding: 8px 10px;
  }
  .toolbar-right {
    right: 10px;
  }
  .nav-seg { overflow-x: auto; justify-content: flex-start; max-width: calc(100% - 88px); }
  .seg-btn { padding: 0 18px; font-size: 17px; }
  .content:has(#viewDrill.active, #viewTest.active, #viewWords.active) {
    padding: 4px var(--layout-pad-x) 6px;
  }
  .macos-desk {
    --key-h: calc(clamp(42px, 6.2vh, 54px) * var(--kb-scale));
    --key-font: calc(clamp(14px, 2vh, 18px) * var(--kb-scale));
    --queue-size: calc(clamp(44px, 6vh, 56px) * var(--kb-scale));
  }
}
