/* ==========================================================
   EdClub 3D - 网页键盘打字练习
   浅色 / 深色双主题 · CSS 3D 虚拟键盘
   ========================================================== */

:root,
:root[data-theme="light"] {
  --bg: #eaf0f7;
  --bg-glow: #d7e7f6;
  --surface: #ffffff;
  --surface-2: #f5f8fc;
  --surface-3: #eef3f9;
  --border: #dde6f0;
  --border-strong: #cbd8e7;
  --text: #172a3c;
  --text-2: #5a7086;
  --text-3: #93a5b8;
  --brand: #14a37f;
  --brand-dark: #0d8a6a;
  --brand-soft: #e2f6ee;
  --blue: #3b82f6;
  --orange: #f2a33c;
  --red: #ee5f6d;
  --gold: #f5b83d;
  --key-top: #ffffff;
  --key-bottom: #eaf0f7;
  --key-side: #bcc9d9;
  --kb-base-1: #f8fbff;
  --kb-base-2: #cdd9e7;
  --kb-base-edge: #aebdcf;
  --hand-fill: #e9f0f8;
  --hand-line: #c9d6e5;
  --shadow-sm: 0 2px 8px rgba(28, 52, 80, .06);
  --shadow: 0 10px 30px rgba(28, 52, 80, .09);
  --shadow-lg: 0 22px 50px rgba(28, 52, 80, .16);
  --radius: 16px;
}

:root[data-theme="dark"] {
  --bg: #0d1520;
  --bg-glow: #16263a;
  --surface: #16212f;
  --surface-2: #1b2838;
  --surface-3: #223145;
  --border: #2a3a4f;
  --border-strong: #3a4d66;
  --text: #e8f1fa;
  --text-2: #a2b5c9;
  --text-3: #6f859c;
  --brand: #2cc596;
  --brand-dark: #1aa77d;
  --brand-soft: #173c34;
  --blue: #6aa5ff;
  --orange: #f5b455;
  --red: #f27582;
  --gold: #f7c45a;
  --key-top: #2b3b50;
  --key-bottom: #1c2a3b;
  --key-side: #101b29;
  --kb-base-1: #24344a;
  --kb-base-2: #162334;
  --kb-base-edge: #0d1724;
  --hand-fill: #25364b;
  --hand-line: #3a4d66;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .25);
  --shadow: 0 10px 30px rgba(0, 0, 0, .3);
  --shadow-lg: 0 22px 50px rgba(0, 0, 0, .45);
}

/* 手指配色 */
:root {
  --f-pinky: #ee7a9c;
  --f-ring: #f3a451;
  --f-middle: #e7c94b;
  --f-index: #4cc38d;
  --f-thumb: #6ba8f5;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 520px at 12% -8%, var(--bg-glow), transparent 65%),
    radial-gradient(900px 480px at 100% 0%, rgba(20, 163, 127, .08), transparent 60%),
    var(--bg);
  transition: background-color .25s, color .25s;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: 66px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 clamp(14px, 3vw, 34px);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: inherit; }
.brand-mark {
  position: relative;
  width: 40px; height: 40px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #23c79a, #0b8a6c);
  color: #fff; font-size: 23px; font-weight: 800; font-family: Arial, sans-serif;
  box-shadow: 0 5px 0 #087053, 0 9px 16px rgba(11, 138, 108, .3);
  transform: perspective(200px) rotateY(-8deg);
}
.brand-cube {
  position: absolute; right: -4px; top: -4px;
  width: 12px; height: 12px; border-radius: 3px;
  background: #ffd166; transform: rotate(18deg);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .2);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 18px; letter-spacing: .2px; }
.brand-text em { font-style: normal; color: var(--brand); font-size: 13px; }
.brand-text small { font-size: 11px; color: var(--text-3); letter-spacing: 2px; margin-top: 3px; }
.topbar-spacer { flex: 1; }
.env-chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 13px;
  border: 1px solid var(--border); border-radius: 99px;
  background: var(--surface-2); color: var(--text-2);
  font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.env-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); box-shadow: 0 0 0 3px rgba(147, 165, 184, .16); }
.env-chip.ok .env-dot { background: var(--brand); box-shadow: 0 0 0 3px rgba(20, 163, 127, .18); animation: breathe 2.4s infinite; }
.env-chip.warn .env-dot { background: var(--orange); box-shadow: 0 0 0 3px rgba(242, 163, 60, .18); }
.icon-btn {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text-2);
  transition: .16s;
}
.icon-btn:hover { color: var(--brand); border-color: var(--brand); transform: translateY(-1px); }
.icon-btn:active { transform: translateY(0); }
.icon-btn svg { width: 18px; height: 18px; }
#btn-sound .ico-mute, .ico-sun { display: none; }
#btn-sound[aria-pressed="false"] .ico-sound { display: none; }
#btn-sound[aria-pressed="false"] .ico-mute { display: block; }
[data-theme="dark"] .ico-moon { display: none; }
[data-theme="dark"] .ico-sun { display: block; }
.menu-toggle { display: none; }

/* ---------------- 布局 ---------------- */
.workspace {
  max-width: 1560px; margin: 0 auto;
  display: grid; grid-template-columns: 282px minmax(0, 1fr);
  align-items: start;
}
.sidebar {
  position: sticky; top: 66px;
  height: calc(100vh - 66px);
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 20px 16px;
}
.side-head h2 { margin: 0; font-size: 16px; }
.side-head p { margin: 5px 0 0; font-size: 11.5px; color: var(--text-3); }
.ring {
  --p: 0;
  width: 50px; height: 50px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--surface-3) 0);
  position: relative;
}
.ring::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--surface); }
.ring span { position: relative; font-size: 11px; font-weight: 700; color: var(--brand); }
.unit-list { flex: 1; overflow-y: auto; padding: 0 12px 16px; scrollbar-width: thin; }
.unit-list::-webkit-scrollbar { width: 6px; }
.unit-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
.unit { margin-bottom: 8px; }
.unit-head {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; font-size: 13px; font-weight: 700;
}
.unit-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.unit-head small { margin-left: auto; font-size: 10px; font-weight: 500; color: var(--text-3); letter-spacing: .5px; }
.unit-lessons { display: flex; flex-direction: column; gap: 2px; }
.lesson-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 8px 10px 8px 8px;
  border: 1px solid transparent; border-radius: 9px;
  background: transparent; color: var(--text-2); text-align: left;
  font-size: 12.5px; transition: .15s;
}
.lesson-item:hover { background: var(--surface-2); color: var(--text); }
.lesson-item.active { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 30%, transparent); color: var(--brand-dark); font-weight: 700; }
.lesson-num {
  width: 24px; height: 24px; flex: none; border-radius: 7px;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-3);
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.lesson-item.active .lesson-num { background: var(--brand); color: #fff; }
.lesson-item.done .lesson-num { background: var(--brand-soft); color: var(--brand-dark); }
.lesson-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-stars { font-size: 10px; letter-spacing: -.5px; color: var(--gold); white-space: nowrap; }
.lesson-item.done .lesson-stars { color: var(--gold); }
.side-foot { padding: 14px 18px 20px; border-top: 1px solid var(--border); }
.tip-card { padding: 12px 13px; border-radius: 11px; background: var(--surface-2); border: 1px dashed var(--border-strong); }
.tip-card strong { font-size: 12px; color: var(--brand-dark); }
.tip-card p { margin: 6px 0 0; font-size: 11.5px; line-height: 1.6; color: var(--text-2); }
.credit { margin: 12px 0 0; text-align: center; font-size: 10.5px; color: var(--text-3); }
.sidebar-mask { display: none; }

.main { min-width: 0; padding: 24px clamp(16px, 2.6vw, 34px) 40px; display: flex; flex-direction: column; gap: 17px; }

/* ---------------- 课程标题 ---------------- */
.lesson-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.crumb { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--brand); }
.lesson-meta h1 { margin: 7px 0 5px; font-size: clamp(20px, 2.2vw, 27px); letter-spacing: -.4px; }
.lesson-meta p { margin: 0; font-size: 13px; color: var(--text-2); line-height: 1.6; max-width: 720px; }
.lesson-actions { display: flex; gap: 9px; flex: none; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 16px; border-radius: 10px;
  font-size: 13px; font-weight: 700; white-space: nowrap;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  transition: .16s;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn.primary { background: linear-gradient(160deg, #21b98e, #0d8a6a); border-color: transparent; color: #fff; box-shadow: 0 4px 0 #087053, 0 8px 16px rgba(13, 138, 106, .22); }
.btn.primary:hover { box-shadow: 0 5px 0 #087053, 0 10px 20px rgba(13, 138, 106, .3); }
.btn.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #087053; }

/* ---------------- 统计卡片 ---------------- */
.stats-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 11px; }
.stat {
  position: relative; overflow: hidden;
  padding: 12px 15px 13px; border-radius: 13px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--c, var(--brand)); opacity: .85; }
.stat:nth-child(1) { --c: var(--brand); }
.stat:nth-child(2) { --c: var(--blue); }
.stat:nth-child(3) { --c: var(--f-ring); }
.stat:nth-child(4) { --c: #9b7bf0; }
.stat:nth-child(5) { --c: var(--red); }
.stat-label { font-size: 11px; color: var(--text-3); letter-spacing: .5px; }
.stat div { display: flex; align-items: baseline; gap: 5px; margin-top: 4px; }
.stat strong { font-size: clamp(21px, 2.3vw, 28px); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat small { font-size: 10.5px; color: var(--text-3); }
.stat.flash strong { animation: pop .3s ease; }
.spark { position: absolute; right: 12px; top: 15px; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); opacity: 0; }
.spark.on { animation: pip .45s ease; }

/* ---------------- 打字区 ---------------- */
.typing-panel {
  position: relative;
  padding: 16px 20px 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.focus-keys { font-size: 11.5px; color: var(--text-3); }
.focus-keys b { display: inline-block; margin-left: 4px; padding: 3px 8px; border-radius: 6px; background: var(--brand-soft); color: var(--brand-dark); letter-spacing: 2px; font-family: Consolas, monospace; }
.live-hint { font-size: 11.5px; color: var(--text-2); }
.stream-wrap { position: relative; min-height: 152px; }
.text-stream {
  position: relative;
  max-height: 152px; overflow: hidden;
  font-family: Consolas, "SF Mono", "JetBrains Mono", Menlo, monospace;
  font-size: clamp(20px, 2.1vw, 26px); line-height: 1.85; letter-spacing: .4px;
  white-space: pre-wrap; word-break: break-word;
  color: var(--text-3); user-select: none;
  transition: filter .2s;
}
.text-stream .ch { position: relative; border-radius: 4px; transition: color .1s, background .1s; }
.text-stream .ch.done { color: var(--brand-dark); }
.text-stream .ch.done.space { background: color-mix(in srgb, var(--brand) 12%, transparent); }
.text-stream .ch.current { background: var(--brand); color: #fff; box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 30%, transparent); animation: caret 1.05s step-end infinite; }
.text-stream .ch.current.wrong { background: var(--red); box-shadow: 0 0 0 2px color-mix(in srgb, var(--red) 30%, transparent); animation: shake .22s ease; }
.text-stream .ch.err-mark { color: var(--red); text-decoration: underline wavy var(--red); }
.text-stream.blurred { filter: blur(3px); }
.start-overlay, .pause-overlay {
  position: absolute; inset: 0; z-index: 3;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--surface-2);
  background: color-mix(in srgb, var(--surface-2) 78%, transparent);
  backdrop-filter: blur(2px);
  cursor: pointer;
}
.start-card { display: flex; align-items: center; gap: 14px; padding: 12px 20px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.start-card strong { display: block; font-size: 14px; }
.start-card span { display: block; margin-top: 4px; font-size: 11.5px; color: var(--text-3); }
.start-copy { display: flex; flex-direction: column; }
.home-row-hint { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.home-row-hint .hr-label { display: inline; margin: 0; font-size: 10px; color: var(--text-3); white-space: nowrap; }
.hr-keys { display: flex; align-items: center; gap: 4px; }
.hr-keys kbd {
  width: 24px; height: 26px; display: grid; place-items: center;
  border-radius: 6px; background: var(--surface-2);
  border: 1px solid var(--border-strong); border-bottom-width: 3px;
  font: 700 12px Consolas, monospace; color: var(--text);
}
.hr-keys kbd.hr-pinky { border-bottom-color: var(--f-pinky); }
.hr-keys kbd.hr-ring { border-bottom-color: var(--f-ring); }
.hr-keys kbd.hr-middle { border-bottom-color: var(--f-middle); }
.hr-keys kbd.hr-index { border-bottom-color: var(--f-index); }
.hr-keys i { width: 10px; }
.start-key {
  width: 48px; height: 48px; flex: none; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(180deg, var(--key-top), var(--key-bottom));
  border: 1px solid var(--border-strong);
  box-shadow: 0 5px 0 var(--key-side), 0 8px 12px rgba(0, 0, 0, .14);
  font: 800 21px Consolas, monospace; color: var(--brand);
  animation: bob 1.8s ease-in-out infinite;
}
.pause-overlay { background: var(--surface); background: color-mix(in srgb, var(--surface) 84%, transparent); }
.pause-card { text-align: center; }
.pause-card strong { display: block; font-size: 18px; }
.pause-card span { display: block; margin-top: 6px; font-size: 12px; color: var(--text-2); }
.progress-track { height: 7px; margin: 12px 0 0; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress-fill { height: 100%; width: 0%; border-radius: 99px; background: linear-gradient(90deg, var(--brand), #6ee0b7); transition: width .18s ease; box-shadow: 0 0 12px rgba(20, 163, 127, .5); }
.panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0 13px; font-size: 11px; color: var(--text-3); }
.kbd-legend kbd {
  display: inline-block; padding: 2px 6px; margin: 0 1px; border-radius: 5px;
  background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px;
  font: 10.5px Consolas, monospace; color: var(--text-2);
}
.capture { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; pointer-events: none; }

/* ---------------- 目标键 + 手指引导 ---------------- */
.guide-row { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 14px; }
.next-key-card, .hands-card {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 18px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.next-key {
  width: 62px; height: 62px; flex: none; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(180deg, #dcfaee, #a5e8ca);
  border: 1px solid #55c99e; color: #0a6d54;
  font: 800 26px Consolas, monospace;
  box-shadow: 0 6px 0 #35a47c, 0 10px 18px rgba(20, 163, 127, .28), 0 0 0 5px rgba(20, 163, 127, .1);
  animation: bob 1.6s ease-in-out infinite;
}
[data-theme="dark"] .next-key { background: linear-gradient(180deg, #1f5b4a, #144236); border-color: #2cc596; color: #b9ffe4; box-shadow: 0 6px 0 #0c5b43, 0 10px 18px rgba(0, 0, 0, .35), 0 0 0 5px rgba(44, 197, 150, .12); }
.next-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.next-meta > span { font-size: 11px; color: var(--text-3); }
.next-meta strong { font-size: 17px; }
.next-meta small { font-size: 11px; color: var(--text-2); }
.hands-card { position: relative; justify-content: center; padding-top: 26px; }
.hands-title { position: absolute; top: 9px; left: 18px; font-size: 11px; color: var(--text-3); }
.hands { display: flex; align-items: flex-end; gap: 34px; height: 78px; }
.hand { position: relative; width: 104px; height: 78px; flex: none; }
.hand.mirrored { transform: scaleX(-1); }
.hand .palm {
  position: absolute; bottom: 0; left: 12px; width: 80px; height: 42px;
  border-radius: 16px 16px 9px 9px;
  background: var(--hand-fill); border: 1px solid var(--hand-line);
  box-shadow: inset 0 3px 8px rgba(255, 255, 255, .35);
}
[data-theme="dark"] .hand .palm { box-shadow: none; }
.finger {
  position: absolute; bottom: 36px; width: 16px;
  border-radius: 9px 9px 3px 3px;
  background: var(--fc); border: 1px solid rgba(0, 0, 0, .1);
  opacity: .42; transition: .16s ease;
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, .35);
}
.f-pinky  { left: 4px;  height: 30px; }
.f-ring   { left: 23px; height: 43px; }
.f-middle { left: 42px; height: 49px; }
.f-index  { left: 61px; height: 44px; }
.f-thumb  { left: 82px; bottom: 6px; height: 34px; transform: rotate(36deg); transform-origin: bottom center; }
.finger.active { opacity: 1; filter: drop-shadow(0 0 7px var(--fc)); transform: translateY(-5px) scale(1.1); }
.f-thumb.active { transform: rotate(36deg) translateY(-5px) scale(1.1); }
.f-pinky { --fc: var(--f-pinky); }
.f-ring { --fc: var(--f-ring); }
.f-middle { --fc: var(--f-middle); }
.f-index { --fc: var(--f-index); }
.f-thumb { --fc: var(--f-thumb); }

/* ---------------- 3D 键盘 ---------------- */
.keyboard-panel {
  padding: 15px 18px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.kb-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.kb-title { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 700; }
.kb-title small { font-weight: 400; font-size: 11px; color: var(--text-3); }
.badge-3d {
  padding: 3px 7px; border-radius: 6px; font-size: 10px; font-weight: 800; letter-spacing: .5px;
  color: #fff; background: linear-gradient(140deg, #7d6bf2, #4a8cf7);
  box-shadow: 0 3px 0 #3f5fc0;
}
.kb-controls { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.legend { display: flex; align-items: center; gap: 10px; font-size: 10.5px; color: var(--text-3); }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.switch { display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-2); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-ui { position: relative; width: 32px; height: 18px; border-radius: 99px; background: var(--border-strong); transition: .2s; }
.switch-ui::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: .2s; }
.switch input:checked + .switch-ui { background: var(--brand); }
.switch input:checked + .switch-ui::after { transform: translateX(14px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--blue); outline-offset: 2px; }
.kb-stage {
  perspective: 1500px; perspective-origin: 50% 12%;
  padding: 34px 16px 24px; margin-top: 4px;
  border-radius: 12px;
  background: radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--brand) 8%, transparent), transparent 68%);
  overflow: hidden;
}
.keyboard {
  position: relative;
  --rx: 0deg; --ry: 0deg;
  transform: rotateX(calc(17deg + var(--rx))) rotateY(var(--ry));
  transform-style: preserve-3d;
  padding: 13px; border-radius: 16px;
  background: linear-gradient(165deg, var(--kb-base-1), var(--kb-base-2));
  border: 1px solid color-mix(in srgb, var(--kb-base-edge) 60%, transparent);
  box-shadow:
    0 12px 0 -4px var(--kb-base-edge),
    0 22px 0 -8px color-mix(in srgb, var(--kb-base-edge) 60%, transparent),
    0 34px 44px -16px rgba(18, 40, 65, .45),
    inset 0 2px 0 rgba(255, 255, 255, .55);
  transition: transform .22s ease-out;
}
/* 双手叠层：俯视手位，十指落在基准键上 */
.hands-overlay {
  position: absolute; inset: 13px;
  pointer-events: none;
  transform: translateZ(14px);
  transform-style: preserve-3d;
}
.hands-overlay.hidden { display: none; }
.overlay-hand { position: absolute; bottom: -4%; left: 1.5%; width: 41%; height: 100%; }
.overlay-hand.right { left: auto; right: 1.5%; transform: scaleX(-1); }
.oh-palm {
  position: absolute; bottom: 0; left: 9%; width: 74%; height: 28%;
  border-radius: 40% 40% 22% 22% / 30% 30% 14% 14%;
  background: var(--hand-fill); border: 1.5px solid var(--hand-line);
  opacity: .38; box-shadow: inset 0 8px 16px rgba(255, 255, 255, .3);
}
[data-theme="dark"] .oh-palm { box-shadow: none; }
.oh-finger {
  position: absolute; bottom: 28%; width: 11%;
  border-radius: 50% 50% 26% 26% / 26% 26% 12% 12%;
  background: var(--hand-fill);
  border: 1.5px solid var(--hand-line);
  opacity: .55;
  transition: opacity .18s ease, transform .18s ease, filter .18s ease, background .18s ease;
}
.oh-finger::after {
  content: ""; position: absolute; left: 16%; right: 16%; bottom: 8%;
  height: 20%; border-radius: 99px;
  background: var(--fc); opacity: .9;
}
.oh-finger.active {
  opacity: .9; background: var(--fc); border-color: var(--fc);
  filter: drop-shadow(0 0 8px var(--fc)); transform: translateY(-7px);
}
.oh-finger.active::after { background: rgba(255, 255, 255, .85); }
.oh-pinky  { left: 5%;  height: 20%; }
.oh-ring   { left: 23%; height: 27%; }
.oh-middle { left: 41%; height: 30%; }
.oh-index  { left: 59%; height: 28%; }
.oh-thumb  { left: 77%; bottom: 8%; height: 24%; transform-origin: bottom center; transform: rotate(36deg); }
.oh-thumb.active { transform: rotate(36deg) translateY(-7px); }

.kb-row { display: flex; gap: 5px; margin-bottom: 5px; transform-style: preserve-3d; }
.kb-row:last-child { margin-bottom: 0; }
.key {
  position: relative;
  flex: var(--u, 1) 1 0; min-width: 0; height: 48px;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--key-top), var(--key-bottom));
  border: 1px solid color-mix(in srgb, var(--key-side) 65%, transparent);
  box-shadow:
    0 5px 0 var(--key-side),
    0 7px 9px rgba(18, 40, 65, .2),
    inset 0 1px 0 rgba(255, 255, 255, .85);
  transform: translateZ(6px);
  transition: transform .07s ease, box-shadow .07s ease, background .12s ease;
  cursor: pointer; user-select: none;
  color: var(--text);
}
[data-theme="dark"] .key { box-shadow: 0 5px 0 var(--key-side), 0 7px 9px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .06); }
.key:hover { filter: brightness(1.04); }
.key.key-fn { color: var(--text-3); font-size: 9.5px; }
.key-main {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font: 700 14px Consolas, "SF Mono", monospace;
  pointer-events: none;
}
.key-shift {
  position: absolute; top: 4px; left: 7px;
  font: 600 9.5px Consolas, monospace; color: var(--text-3);
  pointer-events: none;
}
.key.key-wide .key-main { justify-content: start; padding-left: 10px; font: 600 10px "Segoe UI", sans-serif; letter-spacing: .2px; }
.key.key-wide.key-right .key-main { justify-content: end; padding: 0 10px 0 0; }
.finger-bar {
  position: absolute; left: 22%; right: 22%; bottom: 4px; height: 3px;
  border-radius: 3px; background: var(--fc, transparent); opacity: .8;
  transition: opacity .2s;
}
.keyboard.no-guide .finger-bar { opacity: 0; }
.homing { position: absolute; left: 50%; bottom: 9px; transform: translateX(-50%); width: 9px; height: 2px; border-radius: 2px; background: var(--text-3); opacity: .7; }
.key.target {
  z-index: 2; transform: translateZ(13px);
  background: linear-gradient(180deg, #ddfbef, #a2e7c7);
  border-color: #4bc495; color: #075e48;
  box-shadow:
    0 5px 0 #2ea179,
    0 0 0 3px rgba(20, 163, 127, .22),
    0 12px 20px rgba(20, 163, 127, .35),
    inset 0 1px 0 rgba(255, 255, 255, .8);
  animation: targetGlow 1.5s ease-in-out infinite;
}
[data-theme="dark"] .key.target { background: linear-gradient(180deg, #226b53, #16513e); border-color: #2cc596; color: #d3ffee; }
.key.target.pressed { transform: translateZ(4px); }
.key.pressed {
  transform: translateZ(0);
  box-shadow: 0 1px 0 var(--key-side), 0 2px 3px rgba(18, 40, 65, .22), inset 0 1px 0 rgba(255, 255, 255, .6);
  filter: brightness(.97);
}
.key.wrong-hit { animation: shake .22s ease; background: linear-gradient(180deg, #ffdfe3, #ffb3bc); border-color: var(--red); }
.kb-foot { display: flex; justify-content: space-between; gap: 10px; padding-top: 10px; border-top: 1px dashed var(--border); font-size: 10.5px; color: var(--text-3); }
.site-foot { display: flex; justify-content: space-between; gap: 10px; padding: 4px 4px 0; font-size: 10.5px; color: var(--text-3); }

/* ---------------- 弹窗 ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center; padding: 20px;
  background: rgba(10, 24, 40, .52); backdrop-filter: blur(5px);
  animation: fadeIn .2s ease;
}
.modal {
  position: relative; width: min(460px, 100%);
  padding: 30px 30px 24px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); text-align: center;
  animation: rise .28s cubic-bezier(.2, .9, .3, 1.2);
}
.modal-close {
  position: absolute; top: 12px; right: 14px;
  width: 30px; height: 30px; border: 0; border-radius: 8px;
  background: var(--surface-2); color: var(--text-3); font-size: 21px; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.result-badge { display: inline-block; padding: 5px 13px; border-radius: 99px; background: var(--brand-soft); color: var(--brand-dark); font-size: 11px; font-weight: 700; letter-spacing: 1px; }
.result-modal h2 { margin: 12px 0 6px; font-size: 25px; }
.stars { display: flex; justify-content: center; gap: 8px; margin: 10px 0 18px; font-size: 38px; color: var(--border-strong); }
.stars span { transition: .3s; }
.stars span.lit { color: var(--gold); text-shadow: 0 4px 12px rgba(245, 184, 61, .45); animation: starPop .4s backwards; }
.stars span.lit:nth-child(2) { animation-delay: .13s; }
.stars span.lit:nth-child(3) { animation-delay: .26s; }
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.result-grid div { padding: 12px 4px; border-radius: 11px; background: var(--surface-2); }
.result-grid strong { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.result-grid span { font-size: 10.5px; color: var(--text-3); }
.result-note { margin: 16px 0 0; font-size: 12.5px; color: var(--text-2); line-height: 1.6; }
.result-actions { display: flex; gap: 10px; margin-top: 18px; }
.result-actions .btn { flex: 1; }
.sync-note { margin: 13px 0 0; min-height: 14px; font-size: 10.5px; color: var(--text-3); }
.help-modal { width: min(620px, 100%); text-align: left; }
.help-modal h2 { margin: 0 0 6px; font-size: 22px; }
.help-lead { margin: 0 0 18px; font-size: 12.5px; color: var(--text-2); }
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.help-box { padding: 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.help-box h3 { margin: 0 0 8px; font-size: 13px; }
.help-box p { margin: 0 0 8px; font-size: 11.8px; line-height: 1.8; color: var(--text-2); }
.help-box p:last-child { margin-bottom: 0; }
.help-box b { color: var(--brand-dark); font-family: Consolas, monospace; }
.fchip { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 4px; }
.fchip.pinky { background: var(--f-pinky); }
.fchip.ring { background: var(--f-ring); }
.fchip.middle { background: var(--f-middle); }
.fchip.index { background: var(--f-index); }
.help-sub { margin: 18px 0 10px; font-size: 13px; }
.help-keys { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 11.5px; color: var(--text-2); }
.help-keys kbd { display: inline-block; padding: 2px 7px; margin-right: 3px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; font: 10.5px Consolas, monospace; }
.help-note { margin: 18px 0 0; padding: 11px 13px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-dark); font-size: 11.5px; line-height: 1.7; }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; background: #fff; color: #172a3c; font-size: 16px; z-index: 999; }

/* ---------------- 动画 ---------------- */
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes caret { 0%, 100% { box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 30%, transparent); } 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--brand) 12%, transparent); } }
@keyframes targetGlow { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.09); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
@keyframes pop { 0% { transform: scale(1); } 50% { transform: scale(1.18); color: var(--brand); } 100% { transform: scale(1); } }
@keyframes pip { 0% { opacity: 1; transform: scale(.5); } 100% { opacity: 0; transform: scale(2.4); } }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes starPop { from { opacity: 0; transform: scale(.3) rotate(-30deg); } to { opacity: 1; transform: none; } }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1180px) {
  .workspace { grid-template-columns: 240px minmax(0, 1fr); }
  .kb-stage { padding: 26px 8px 18px; }
  .key { height: 42px; }
  .legend { display: none; }
}
@media (max-width: 940px) {
  .workspace { display: block; }
  .menu-toggle { display: grid; }
  .sidebar {
    position: fixed; left: 0; top: 66px; z-index: 60;
    width: 282px; transform: translateX(-102%);
    background: var(--surface); box-shadow: var(--shadow-lg);
    transition: transform .25s ease;
  }
  .sidebar.open { transform: none; }
  .sidebar-mask { display: block; position: fixed; inset: 66px 0 0; z-index: 50; background: rgba(10, 24, 40, .4); opacity: 0; pointer-events: none; transition: opacity .25s; }
  .sidebar-mask.show { opacity: 1; pointer-events: auto; }
  .main { padding-top: 18px; }
  .guide-row { grid-template-columns: 1fr; }
  .hands-card { padding-top: 26px; }
}
@media (max-width: 680px) {
  .topbar { height: 58px; padding: 0 12px; gap: 8px; }
  .sidebar { top: 58px; height: calc(100vh - 58px); }
  .sidebar-mask { top: 58px; }
  .brand-text small { display: none; }
  .brand-text strong { font-size: 16px; }
  .env-chip { display: none; }
  .lesson-bar { flex-direction: column; align-items: stretch; gap: 12px; }
  .lesson-actions .btn { flex: 1; }
  .stats-row { grid-template-columns: repeat(3, 1fr); }
  .stat { padding: 10px 12px; }
  .typing-panel { padding: 13px 14px 0; }
  .text-stream { font-size: 19px; line-height: 1.7; max-height: 130px; }
  .stream-wrap, .text-stream { min-height: 130px; }
  .kbd-legend { display: none; }
  .start-card { flex-direction: column; text-align: center; padding: 12px 16px; }
  .kb-stage { padding: 18px 4px 14px; }
  .keyboard { padding: 7px; border-radius: 10px; }
  .hands-overlay { inset: 7px; }
  .oh-palm { opacity: .26; }
  .oh-finger { opacity: .42; }
  .oh-finger.active { opacity: .85; }
  .kb-row { gap: 3px; margin-bottom: 3px; }
  .key { height: 33px; border-radius: 5px; box-shadow: 0 3px 0 var(--key-side), 0 4px 5px rgba(18, 40, 65, .2); }
  .key-main { font-size: 10px; }
  .key-shift { font-size: 7px; top: 2px; left: 3px; }
  .key.key-wide .key-main { font-size: 7px; padding-left: 4px; }
  .finger-bar { height: 2px; left: 25%; right: 25%; }
  .homing { display: none; }
  .kb-controls { gap: 8px; }
  .kb-title small { display: none; }
  .help-cols { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
  .modal { padding: 26px 18px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
