/* 鹤练 design.md 实现：深夜书法房 —— 墨色底、一点朱砂 */
:root {
  --ink: #101014;
  --ink-depth: #0c0c0f;
  --surface: #17171C;
  --surface-card: #181820;
  --surface-card-hover: #1e1e27;
  --raised: #22222B;
  --line: rgba(255, 255, 255, 0.08);
  --line-subtle: rgba(255, 255, 255, 0.04);
  --bone: #EDEDEF;
  --ash: #8B8B93;
  --ash-muted: #62626B;
  --cinnabar: #D96C4F;
  --cinnabar-glow: rgba(217, 108, 79, 0.25);
  --cinnabar-subtle: rgba(217, 108, 79, 0.12);
  --bamboo: #7FA98C;
  --bamboo-glow: rgba(127, 169, 140, 0.22);
  --rust: #C4574E;
  --rust-glow: rgba(196, 87, 78, 0.25);
  --sans: "Outfit", "PingFang SC", "Microsoft YaHei", sans-serif;
  --serif: "Source Han Serif SC", "Noto Serif SC", "SimSun", serif;
  --mono: "JetBrains Mono", Consolas, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: dark; }

body {
  background-color: var(--ink);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(217, 108, 79, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(127, 169, 140, 0.03) 0%, transparent 70%);
  color: var(--bone);
  font-family: var(--sans);
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 自定义滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--ink); }
::-webkit-scrollbar-thumb { background: var(--raised); border-radius: 4px; border: 2px solid var(--ink); }
::-webkit-scrollbar-thumb:hover { background: var(--ash-muted); }

main { max-width: 1100px; margin: 0 auto; padding: 20px 24px 60px; }
h1 { font-size: 1.65rem; font-weight: 700; letter-spacing: -0.015em; margin-bottom: 8px; color: var(--bone); }
h2 { font-size: 1.12rem; font-weight: 600; margin: 28px 0 12px; color: var(--bone); letter-spacing: -0.01em; }
.sub { color: var(--ash); font-size: 0.92rem; max-width: 65ch; line-height: 1.65; }
.hidden { display: none !important; }

/* ---- 顶栏 ---- */
.topbar {
  height: 56px; display: flex; align-items: center; gap: 32px;
  padding: 0 28px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(16, 16, 20, 0.88);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  z-index: 20; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}
.brand {
  font-weight: 700; font-size: 1.1rem; letter-spacing: 0.04em;
  white-space: nowrap; display: flex; align-items: center;
}
.brand .dot { color: var(--cinnabar); text-shadow: 0 0 8px var(--cinnabar-glow); margin: 0 2px; }
.brand small {
  color: var(--ash); font-weight: 400; font-size: 0.78rem;
  margin-left: 8px; letter-spacing: 0.05em; padding-left: 8px;
  border-left: 1px solid var(--line);
}
.nav { display: flex; gap: 4px; overflow-x: auto; }
.nav a {
  color: var(--ash); text-decoration: none; font-size: 0.9rem;
  font-weight: 500; padding: 6px 14px; border-radius: 9px; min-height: 44px;
  display: inline-flex; align-items: center; white-space: nowrap;
  transition: all 0.15s var(--ease);
}
.nav a:hover { color: var(--bone); background: rgba(255, 255, 255, 0.05); }
.nav a.on {
  color: var(--bone); background: var(--raised);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.streak {
  margin-left: auto; color: var(--bamboo); font-size: 0.85rem;
  font-family: var(--mono); white-space: nowrap; font-weight: 600;
  background: rgba(127, 169, 140, 0.08); border: 1px solid rgba(127, 169, 140, 0.2);
  padding: 4px 12px; border-radius: 20px; letter-spacing: 0.02em;
}
.streak:empty { display: none; }

/* ---- 练习模式切换与提示栏 ---- */
.modes {
  display: flex; gap: 4px; flex-wrap: wrap; justify-content: center;
  margin: 8px auto 8px; padding: 4px; background: rgba(23, 23, 28, 0.75);
  border: 1px solid var(--line); border-radius: 12px; max-width: fit-content;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.modes button {
  background: transparent; color: var(--ash); border: 1px solid transparent;
  padding: 6px 14px; border-radius: 8px; cursor: pointer; font-family: var(--sans);
  font-size: 0.88rem; font-weight: 500; min-height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.15s var(--ease);
}
.modes button:hover { color: var(--bone); background: rgba(255, 255, 255, 0.04); }
.modes button.on {
  color: var(--bone); border-color: rgba(217, 108, 79, 0.4);
  background: var(--raised);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.hintseg {
  color: var(--ash); font-size: 0.85rem; display: flex; gap: 16px;
  align-items: center; justify-content: center; margin-bottom: 10px;
}
.hintseg label {
  display: inline-flex; gap: 6px; align-items: center; cursor: pointer;
  min-height: 36px; padding: 0 4px; border-radius: 6px;
  transition: color 0.15s var(--ease);
}
.hintseg label:hover { color: var(--bone); }
.hintseg input[type="radio"] {
  appearance: none; -webkit-appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid var(--ash-muted); background: var(--surface);
  cursor: pointer; position: relative; outline: none;
  transition: all 0.15s var(--ease);
}
.hintseg input[type="radio"]:checked {
  border-color: var(--cinnabar); background: var(--cinnabar);
  box-shadow: 0 0 6px var(--cinnabar-glow);
}
.hintseg input[type="radio"]:checked::after {
  content: ""; position: absolute; inset: 3px;
  background: var(--ink); border-radius: 50%;
}

/* ---- 练习主区（舞台与仪表） ---- */
.stage {
  text-align: center; padding: 10px 0 6px; max-width: 880px; margin: 0 auto;
}
.word {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(4rem, 11vw, 6.2rem); line-height: 1.1;
  letter-spacing: 0.04em; color: var(--bone);
  text-shadow: 0 4px 28px rgba(0, 0, 0, 0.7);
  min-height: 1.15em; display: flex; align-items: center; justify-content: center;
  transition: opacity 0.06s var(--ease), transform 0.06s var(--ease);
}
.word.fade {
  opacity: 0; transform: translateY(-8px);
}
.hint {
  margin-top: 6px; color: var(--ash); font-size: 1rem; min-height: 1.6em;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.hint b {
  color: var(--bone); font-family: var(--mono); font-weight: 600;
  letter-spacing: 0.1em; background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line); padding: 2px 8px; border-radius: 6px;
}
.guide {
  margin-top: 4px; font-size: 0.92rem; color: var(--ash); min-height: 1.6em;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px;
}
.guide .g1 {
  color: var(--cinnabar); font-family: var(--mono); font-weight: 600;
  background: var(--cinnabar-subtle); border: 1px solid rgba(217, 108, 79, 0.25);
  padding: 1px 7px; border-radius: 5px;
}
.guide .g2 {
  color: var(--bamboo); font-family: var(--mono); font-weight: 600;
  background: rgba(127, 169, 140, 0.12); border: 1px solid rgba(127, 169, 140, 0.25);
  padding: 1px 7px; border-radius: 5px;
}
.guide .sub2 { color: var(--ash); font-size: 0.84rem; }
.guide .roothint { /* 五笔 86 兜底形态：当前键字根候选表（§4.2），独占一行 */
  flex-basis: 100%; margin-top: 2px; color: var(--ash); font-size: 0.84rem;
}

.inbox {
  display: block; margin: 14px auto 0; width: min(340px, 86vw);
  background: transparent; border: none;
  border-bottom: 2px solid var(--line); border-radius: 6px 6px 0 0;
  color: var(--bone); font-family: var(--mono); font-size: 26px; letter-spacing: 0.35em;
  text-align: center; padding: 6px 12px; outline: none;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.inbox:focus {
  border-bottom-color: var(--cinnabar);
  background: rgba(217, 108, 79, 0.04);
  box-shadow: 0 4px 16px rgba(217, 108, 79, 0.15);
}
.inbox.shake { animation: shake 0.13s var(--ease); }
@keyframes shake {
  20% { transform: translateX(-5px); }
  60% { transform: translateX(5px); }
  85% { transform: translateX(-2px); }
}
.fb {
  min-height: 1.5em; margin-top: 6px; font-size: 0.9rem; color: var(--rust);
  font-weight: 500; letter-spacing: 0.02em; display: flex; align-items: center; justify-content: center;
}

.statusrow {
  display: flex; justify-content: center; gap: 10px; flex-wrap: wrap;
  color: var(--ash); font-size: 0.85rem; margin-top: 12px;
}
.statusrow span {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 9px; padding: 5px 12px; display: inline-flex;
  align-items: center; gap: 6px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
.statusrow b {
  color: var(--bone); font-family: var(--mono); font-weight: 600; font-size: 0.92rem;
}
.prog {
  height: 3px; background: var(--line); margin: 10px auto 14px;
  max-width: 500px; border-radius: 2px; overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}
.prog div {
  height: 100%; width: 0; background: linear-gradient(90deg, var(--bamboo) 0%, #9fcbb0 100%);
  box-shadow: 0 0 8px var(--bamboo-glow); border-radius: 2px;
  transition: width 0.15s var(--ease);
}

/* ---- 键盘图与键帽质感 ---- */
.kb {
  display: flex; flex-direction: column; gap: 6px; align-items: center; user-select: none;
  padding: 10px 16px;
  background: rgba(16, 16, 20, 0.75); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-radius: 16px; border: 1px solid var(--line);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  max-width: fit-content; margin: 0 auto;
}
.kbrow { display: flex; gap: 6px; }
.key {
  width: 48px; height: 48px; border-radius: 10px; position: relative;
  background: linear-gradient(180deg, #1f1f27 0%, #16161c 100%);
  border: 1px solid rgba(255, 255, 255, 0.08); border-bottom: 2px solid rgba(0, 0, 0, 0.6);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: background 0.12s var(--ease), border-color 0.12s var(--ease),
              transform 0.08s var(--ease), box-shadow 0.08s var(--ease);
}
.key .sm {
  font-family: var(--mono); font-weight: 600; font-size: 17.5px; line-height: 1;
  color: var(--bone); margin-top: -2px;
}
.key .ym {
  font-size: 9px; color: var(--ash); line-height: 1.15; max-width: 44px;
  text-align: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  margin-top: 2px; font-weight: 400;
}

/* 键帽交互态 */
.key.special {
  border-color: rgba(217, 108, 79, 0.35);
  background: linear-gradient(180deg, #241e23 0%, #18151a 100%);
}
.key.smhi {
  background: linear-gradient(180deg, #e47a5f 0%, #d96c4f 100%);
  border-color: #d96c4f; border-bottom-color: #b8543a;
  box-shadow: 0 0 14px var(--cinnabar-glow), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.key.smhi .sm, .key.smhi .ym { color: var(--ink); font-weight: 700; }
.key.smhi::after, .key.ymhi::after {
  position: absolute; top: 2px; right: 3px; font-size: 10px; font-weight: 700;
}
.key.smhi::after { content: attr(data-n); color: var(--ink); }
.key.ymhi {
  border-color: var(--bamboo); border-bottom-color: #658c71;
  background: linear-gradient(180deg, #242f28 0%, #17201b 100%);
  box-shadow: 0 0 12px var(--bamboo-glow), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.key.ymhi .sm { color: var(--bamboo); font-weight: 700; }
.key.ymhi .ym { color: #a4cca8; font-weight: 600; }
.key.ymhi::after { content: attr(data-n); color: var(--bamboo); }
.key.pressed {
  transform: translateY(2px) scale(0.98); background: var(--raised);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  border-bottom-width: 1px;
}
.key.key-impact {
  animation: keyImpact 0.16s var(--ease);
}
@keyframes keyImpact {
  0% { transform: translateY(0) scale(1); }
  30% { transform: translateY(3px) scale(0.92); filter: brightness(1.2); }
  65% { transform: translateY(-1.5px) scale(1.05); }
  100% { transform: translateY(0) scale(1); }
}
.key.errflash {
  background: linear-gradient(180deg, #d86258 0%, #c4574e 100%) !important;
  border-color: #c4574e !important; box-shadow: 0 0 14px var(--rust-glow) !important;
}
.key.errflash .sm, .key.errflash .ym { color: #fff !important; }

/* ---- 注音大千 41 键布局（v3 #4，T4-Q5）：弹性键宽 + 空格声调宽键 ---- */
.kb.wide { max-width: 660px; width: 100%; }
.kb.wide .kbrow { width: 100%; }
.kb.wide .key { width: auto; flex: 1 1 0; min-width: 30px; height: 46px; }
.kb.wide .key .sm { font-size: 15px; }
.kb.wide .key .ym { max-width: none; }
.kb .key[data-key=" "] { flex: 7 1 0; max-width: 320px; }
.drillgroup { width: 100%; margin-top: 10px; color: var(--ash); font-size: 0.85rem; }
.drillgroup:first-child { margin-top: 0; }

/* 舞台击键反冲震荡 */
.stage.recoil {
  animation: stageRecoil 0.08s ease-out;
}
@keyframes stageRecoil {
  0% { transform: translateY(0); }
  40% { transform: translateY(1.2px); }
  100% { transform: translateY(0); }
}

/* 全屏打击粒子层 */
.impact-canvas {
  position: fixed; inset: 0; width: 100vw; height: 100vh;
  pointer-events: none; z-index: 15;
}

/* 热力图键盘 */
.kb.heat { background: transparent; backdrop-filter: none; box-shadow: none; border: none; padding: 6px 0; }
.kb.heat .key .ym { display: none; }
.kb.heat .key { cursor: default; }

/* ---- 结算结果弹窗 ---- */
.result {
  position: fixed; inset: 0; background: rgba(12, 12, 16, 0.85);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px;
  z-index: 50; animation: fadeIn 0.2s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.result h2 { margin: 0; font-size: 1.5rem; letter-spacing: -0.01em; color: var(--bone); }
.resgrid {
  display: flex; gap: 28px; flex-wrap: wrap; justify-content: center;
  background: var(--surface-card); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px 36px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.resgrid div { text-align: center; opacity: 0; animation: rise 0.3s var(--ease) forwards; }
.resgrid div:nth-child(1) { animation-delay: 0.04s; }
.resgrid div:nth-child(2) { animation-delay: 0.10s; }
.resgrid div:nth-child(3) { animation-delay: 0.16s; }
.resgrid div:nth-child(4) { animation-delay: 0.22s; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.resgrid b { display: block; font-family: var(--mono); font-size: 2.1rem; font-weight: 600; color: var(--bone); }
.resgrid span { color: var(--ash); font-size: 0.86rem; margin-top: 4px; display: block; }

/* ---- 按钮系统 ---- */
.btn {
  font-family: var(--sans); font-size: 0.95rem; font-weight: 500; cursor: pointer;
  padding: 10px 24px; border-radius: 12px; min-height: 44px;
  border: 1px solid var(--line); background: var(--surface); color: var(--bone);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: all 0.15s var(--ease);
}
.btn:hover { background: var(--raised); border-color: rgba(255, 255, 255, 0.14); }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn.primary {
  background: linear-gradient(180deg, #e47a5f 0%, #d96c4f 100%);
  border-color: #d96c4f; color: #fff; font-weight: 600;
  box-shadow: 0 4px 14px var(--cinnabar-glow), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn.primary:hover {
  background: linear-gradient(180deg, #eb846a 0%, #e07255 100%);
  box-shadow: 0 6px 18px rgba(217, 108, 79, 0.4);
}
.btn.ghost {
  background: transparent; border-color: var(--line); color: var(--ash); box-shadow: none;
}
.btn.ghost:hover {
  color: var(--bone); border-color: rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.04);
}
.rowbtns { display: flex; gap: 12px; margin: 20px 0; }

/* ---- 课程视图 ---- */
.coursewrap { display: grid; grid-template-columns: 240px 1fr; gap: 28px; margin-top: 20px; }
.stages {
  list-style: none; display: flex; flex-direction: column; gap: 8px;
  background: var(--surface-card); border: 1px solid var(--line);
  border-radius: 16px; padding: 12px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.stages li {
  padding: 12px 16px; border-radius: 10px; cursor: pointer; color: var(--ash);
  border-left: 3px solid transparent; font-size: 0.94rem; min-height: 48px;
  display: flex; align-items: center; transition: all 0.15s var(--ease);
}
.stages li:hover { color: var(--bone); background: rgba(255, 255, 255, 0.04); }
.stages li.on {
  color: var(--bone); background: var(--raised); border-left-color: var(--cinnabar);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06); font-weight: 500;
}
.stages li small { display: block; color: var(--ash); font-size: 0.78rem; margin-top: 2px; }
.stagebody {
  background: var(--surface-card); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px; min-height: 340px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.stagebody h3 { font-size: 1.15rem; margin-bottom: 10px; color: var(--bone); }
.stagebody p { color: var(--ash); font-size: 0.94rem; max-width: 65ch; line-height: 1.65; }
.stagebody .btn { margin-top: 20px; }
.finalkeys { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.finalkeys button {
  font-family: var(--mono); background: linear-gradient(180deg, #22222b 0%, #191920 100%);
  color: var(--bone); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px;
  cursor: pointer; min-height: 44px; font-size: 0.92rem; font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: all 0.15s var(--ease);
}
.finalkeys button:hover { border-color: rgba(217, 108, 79, 0.4); background: var(--raised); }
.finalkeys button.on {
  border-color: var(--cinnabar); background: var(--cinnabar-subtle); color: var(--cinnabar);
  box-shadow: 0 0 10px var(--cinnabar-glow);
}
.finalkeys button small { color: var(--ash); margin-left: 6px; font-family: var(--sans); font-weight: 400; font-size: 0.8rem; }
.kbmap { margin-top: 20px; }
.kbmap .key { cursor: pointer; }
.kbmap .key:hover { border-color: rgba(255, 255, 255, 0.25); transform: translateY(-1px); }
.legend { display: flex; gap: 20px; margin-top: 16px; color: var(--ash); font-size: 0.84rem; flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---- 形码字根认知（#5：字母详情 + 四类分区 + 例字）---- */
.rootdetail {
  margin-top: 16px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px;
  background: linear-gradient(180deg, #1b1b22 0%, #17171d 100%);
}
.rootdetail h4 { color: var(--bone); font-size: 1.02rem; margin-bottom: 6px; }
.rootdetail h4 small { color: var(--ash); font-weight: 400; margin-left: 6px; font-size: 0.8rem; }
.rootdetail p { margin-top: 4px; font-size: 0.9rem; }
.rootcats { margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }
.rootcat b { color: var(--bone); font-size: 0.92rem; }
.rootcat .sub { margin-left: 8px; font-size: 0.82rem; }
.rootrow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.rootchip {
  font-family: var(--mono); background: linear-gradient(180deg, #22222b 0%, #191920 100%);
  color: var(--bone); border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px;
  cursor: pointer; min-height: 44px; font-size: 0.9rem; font-weight: 600;
  transition: all 0.15s var(--ease);
}
.rootchip small { color: var(--ash); margin-left: 6px; font-family: var(--sans); font-weight: 400; font-size: 0.8rem; }
.rootchip:hover { border-color: rgba(217, 108, 79, 0.4); background: var(--raised); transform: translateY(-1px); }
.rootexwrap { margin-top: 6px; }
.rootex {
  display: inline-block; margin-right: 10px; color: var(--bone);
  font-family: var(--serif); font-size: 1.05rem;
}
.rootex small { font-family: var(--mono); color: var(--cinnabar); margin-left: 4px; font-size: 0.78rem; }
.formnote { /* 降级形态边界空态说明（五笔 86 字根总表页，issue #6） */
  margin-top: 18px; color: var(--ash); font-size: 0.86rem;
}
#goFree { margin-top: 12px; }

/* ---- 导入视图 ---- */
.fmtgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 20px 0; }
.fmt {
  background: var(--surface-card); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px 20px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: border-color 0.15s var(--ease);
}
.fmt:hover { border-color: rgba(255, 255, 255, 0.14); }
.fmt.big {
  grid-row: span 2; display: flex; flex-direction: column; justify-content: center;
  border-color: rgba(217, 108, 79, 0.3);
  background: linear-gradient(180deg, rgba(217, 108, 79, 0.04) 0%, var(--surface-card) 100%);
}
.fmt b { font-family: var(--mono); font-size: 0.98rem; color: var(--bone); }
.fmt span { display: block; color: var(--ash); font-size: 0.85rem; margin-top: 6px; line-height: 1.5; }
.drop {
  border: 2px dashed rgba(255, 255, 255, 0.12); border-radius: 16px; padding: 44px 24px;
  text-align: center; color: var(--ash); background: rgba(23, 23, 28, 0.4);
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease), box-shadow 0.15s var(--ease);
  margin: 18px 0;
}
.drop.over {
  border-color: var(--cinnabar); background: var(--cinnabar-subtle);
  box-shadow: 0 0 24px var(--cinnabar-glow);
}
.linklike {
  color: var(--cinnabar); cursor: pointer; text-decoration: underline;
  text-underline-offset: 4px; font-weight: 500;
}
.report { margin-top: 18px; }
.report .line {
  padding: 10px 14px; border-top: 1px solid var(--line-subtle); font-size: 0.9rem;
  color: var(--ash); background: rgba(23, 23, 28, 0.4); border-radius: 8px; margin-bottom: 4px;
}
.report .line b { color: var(--bone); font-family: var(--mono); }
.report .bad { color: var(--rust); }
.liblist { margin-top: 24px; }
.liblist .lib {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  padding: 14px 18px; border-radius: 12px; background: var(--surface-card);
  border: 1px solid var(--line); margin-bottom: 8px; font-size: 0.92rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.liblist .lib span { color: var(--ash); font-family: var(--mono); font-size: 0.84rem; }

/* ---- 统计视图 ---- */
.totals {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 18px 0 28px;
}
.totals div {
  background: linear-gradient(180deg, #1e1e26 0%, #17171c 100%);
  border: 1px solid var(--line); border-radius: 16px; padding: 22px 24px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.totals b {
  display: block; font-family: var(--mono); font-size: 2.1rem; font-weight: 600;
  color: var(--bone); letter-spacing: -0.02em;
}
.totals span { color: var(--ash); font-size: 0.85rem; font-weight: 500; margin-top: 4px; display: block; }
.spark {
  background: var(--surface-card); border: 1px solid var(--line); border-radius: 16px;
  padding: 20px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.spark svg { width: 100%; height: 120px; display: block; overflow: visible; }
.spark svg path { filter: drop-shadow(0 2px 8px var(--bamboo-glow)); }
.spark .no { color: var(--ash); font-size: 0.92rem; padding: 32px 0; text-align: center; }
.sesslist { margin-top: 12px; }
.sesslist .sess {
  display: flex; gap: 20px; padding: 12px 18px; border-radius: 10px; margin-bottom: 6px;
  background: rgba(23, 23, 28, 0.6); border: 1px solid rgba(255, 255, 255, 0.04);
  font-family: var(--mono); font-size: 0.86rem; color: var(--ash); align-items: center;
}
.sesslist .sess b { color: var(--bamboo); font-weight: 600; margin-left: auto; }

/* ---- 错词本视图 ---- */
.mklist { margin-top: 12px; }
.mklist .mk {
  display: flex; align-items: center; gap: 20px; padding: 14px 20px;
  background: var(--surface-card); border: 1px solid var(--line); border-radius: 14px;
  margin-bottom: 8px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: transform 0.12s var(--ease), border-color 0.12s var(--ease);
}
.mklist .mk:hover {
  transform: translateX(4px); border-color: rgba(255, 255, 255, 0.14);
}
.mklist .mk .w {
  font-family: var(--serif); font-size: 1.3rem; font-weight: 600; color: var(--bone); min-width: 100px;
}
.mklist .mk .c {
  font-family: var(--mono); color: var(--ash); font-size: 0.92rem; letter-spacing: 0.12em; font-weight: 600;
}
.mklist .mk .n {
  margin-left: auto; color: var(--rust); font-family: var(--mono); font-size: 0.84rem; font-weight: 600;
  background: rgba(196, 87, 78, 0.12); border: 1px solid rgba(196, 87, 78, 0.25);
  padding: 3px 10px; border-radius: 20px;
}
.empty {
  padding: 56px 0; text-align: center; color: var(--ash); font-size: 0.94rem;
}
.empty svg {
  display: block; margin: 0 auto 16px; opacity: 0.8;
  filter: drop-shadow(0 4px 12px rgba(217, 108, 79, 0.15));
}

/* ---- 设置视图 ---- */
.setgroup {
  background: var(--surface-card); border: 1px solid var(--line); border-radius: 16px;
  padding: 24px; margin-top: 18px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.setgroup h2 { margin: 0 0 14px; font-size: 1.1rem; }
.chk {
  display: flex; gap: 10px; align-items: center; padding: 8px 6px;
  cursor: pointer; min-height: 44px; color: var(--bone); font-size: 0.94rem;
  transition: color 0.12s var(--ease);
}
.chk:hover { color: #fff; }
.chk input[type="radio"],
.chk input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 17px; height: 17px; border: 1.5px solid var(--ash-muted);
  background: var(--surface); cursor: pointer; position: relative; outline: none;
  transition: all 0.15s var(--ease);
}
.chk input[type="radio"] { border-radius: 50%; }
.chk input[type="checkbox"] { border-radius: 5px; }
.chk input[type="radio"]:checked,
.chk input[type="checkbox"]:checked {
  border-color: var(--cinnabar); background: var(--cinnabar);
  box-shadow: 0 0 6px var(--cinnabar-glow);
}
.chk input[type="radio"]:checked::after {
  content: ""; position: absolute; inset: 4px;
  background: var(--ink); border-radius: 50%;
}
.chk input[type="checkbox"]:checked::after {
  content: "✓"; position: absolute; inset: 0;
  color: var(--ink); font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.setgroup.danger {
  border-color: rgba(196, 87, 78, 0.35);
  background: linear-gradient(180deg, rgba(196, 87, 78, 0.04) 0%, var(--surface-card) 100%);
}
.setgroup.danger .btn { margin-top: 14px; }

/* ---- 帮助卡片 ---- */
.help {
  margin: 32px auto 0; max-width: 680px; border-top: 1px solid var(--line); padding-top: 14px;
}
.help summary {
  cursor: pointer; color: var(--ash); font-size: 0.9rem; min-height: 44px;
  display: flex; align-items: center; user-select: none; font-weight: 500;
  transition: color 0.15s var(--ease);
}
.help summary:hover { color: var(--bone); }
.helpbody {
  color: var(--ash); font-size: 0.92rem; padding: 14px 18px; margin-top: 8px;
  max-width: 65ch; background: rgba(23, 23, 28, 0.5); border-radius: 12px;
  border: 1px solid var(--line-subtle); line-height: 1.7;
}
.helpbody p { margin-bottom: 12px; }
.helpbody p:last-child { margin-bottom: 0; }
.helpbody b { color: var(--bone); font-family: var(--mono); font-weight: 600; }

/* ---- 页脚 ---- */
.foot {
  border-top: 1px solid var(--line); color: var(--ash-muted); font-size: 0.82rem;
  text-align: center; padding: 22px 16px 32px; letter-spacing: 0.02em;
}

/* ---- 响应式适配（桌面优先） ---- */
@media (max-width: 768px) {
  main { padding: 20px 16px 48px; }
  .topbar { gap: 14px; padding: 0 16px; }
  .coursewrap { grid-template-columns: 1fr; gap: 16px; }
  .fmtgrid { grid-template-columns: 1fr; }
  .fmt.big { grid-row: auto; }
  .totals { grid-template-columns: 1fr; gap: 10px; }
  .resgrid { grid-template-columns: 1fr 1fr; gap: 16px; padding: 20px; }
  /* v4 #12（T3-D1/D5/D7）：移动端保留可点按键盘 —— 768px 单断点，历史互斥的
     「.kb{display:none} / 后置 .kb{display:flex}」两处合并为单一规则，行为不变。
     所有键盘形态（练习 #kb / 课程 #kbmap / 热力 #kbheat，26 键与 41 键同权）：
     弹性键宽 + 行宽 100% + 行隙 4px，禁分行禁横滚；键高 ≥44（触控基准按「高」执行，
     键宽下限为键盘矩阵成文例外，SPEC-0004 §4-D1）。kbmini 预览不受影响。 */
  .kb, .kbmap { display: flex; flex-direction: column; align-items: center; width: 100%; max-width: none; gap: 4px; padding: 8px; }
  .kb:not(.kbmini) .kbrow, .kbmap .kbrow { width: 100%; gap: 2px; flex-wrap: nowrap; }
  .kb:not(.kbmini) .key, .kbmap .key { width: auto; flex: 1 1 0; min-width: 0; height: 46px; }
  /* 注音大千窄屏下调：.kb.wide 键宽下限 30px → ~24px 容 11 键（vw 上限兜极窄屏不溢出）；
     字号下限：注音主显 ≥13px、角标 ≥8px（T3-D7） */
  .kb.wide .key { min-width: min(24px, 6.5vw); }
  .kb.wide .key .sm { font-size: 13px; }
  .kb.wide .key .ym { font-size: 8px; }
  /* 形码角标键宽内省略号截断（复用现有 ellipsis，T3-D3；五笔全列同纪律） */
  .kb:not(.kbmini) .key .ym, .kbmap .key .ym { max-width: 100%; }
}

/* v4 #12（T3-D3）：键宽 <28px 隐角标保主字母；键图 title/详情提供兜底。 */
.key .ym.compact-hidden { display: none; }

/* ---- V2 组件 ---- */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(20px);
  background: var(--raised); color: var(--bone); border: 1px solid var(--line);
  padding: 10px 22px; border-radius: 12px; font-size: 0.9rem; opacity: 0;
  pointer-events: none; transition: opacity 0.2s var(--ease), transform 0.2s var(--ease); z-index: 40;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.badges { display: flex; gap: 10px; flex-wrap: wrap; }
.badge {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 16px; text-align: center; opacity: 0.45;
}
.badge.got { opacity: 1; border-color: var(--bamboo); }
.badge b { display: block; font-size: 0.95rem; }
.badge span { color: var(--ash); font-size: 0.75rem; }
.calendar { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 12px); gap: 3px; overflow-x: auto; padding: 4px 0; }
.calendar i { width: 12px; height: 12px; border-radius: 3px; background: var(--surface); }
.calendar i.cal1 { background: rgba(127, 169, 140, 0.35); }
.calendar i.cal2 { background: rgba(127, 169, 140, 0.65); }
.calendar i.cal3 { background: var(--bamboo); }
.custombox {
  width: 100%; background: var(--surface); color: var(--bone); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; font-family: var(--mono); font-size: 0.9rem; margin: 8px 0 12px;
}
.sel {
  background: var(--raised); color: var(--bone); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; font-family: var(--sans); margin-left: 10px;
}
.due-dot { color: var(--cinnabar); font-size: 0.7rem; vertical-align: top; }
.stages li.challenge { border-left-color: var(--bamboo); }
