:root {
  --bg: #0e1116; --panel: #161b23; --panel2: #1d2430; --line: #2a3342;
  --text: #eef2f7; --muted: #8b97a8; --accent: #4f8cff; --accent-text: #fff;
  --ok: #3ecf8e; --tone: #f0b429; --bad: #ff6b6b;
  --slot-line: #5b6b85;
}
:root[data-theme="light"] {
  --bg: #f5f6f8; --panel: #ffffff; --panel2: #eef1f5; --line: #d9dee6;
  --text: #1a2230; --muted: #667085; --accent: #2f6fed; --accent-text: #fff;
  --ok: #12925a; --tone: #b77400; --bad: #d63c3c;
  --slot-line: #9aa6b8;
}
* { box-sizing: border-box; }
html { height: 100%; }
/* body 至少一屏高、内容多时跟着变高：底部按钮栏（sticky）才会贴在屏幕底边并在最后落到内容下方，不会一直盖住键盘 */
body { min-height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  display: flex; flex-direction: column;
}
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
kbd { font: 11px/1 ui-monospace, Consolas, monospace; padding: 2px 5px; border-radius: 4px; background: rgba(255,255,255,.18); margin-left: 4px; }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 18px; flex-wrap: wrap; }
.brand { font-size: 15px; color: var(--muted); }
.brand b { font-weight: 800; font-size: 17px; letter-spacing: .08em; color: var(--text); margin-right: 6px; }
.tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pick { display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; }
.pick span { color: var(--muted); font-size: 12px; }
.pick select { background: transparent; border: 0; outline: 0; }
.pick select option { background: var(--panel); color: var(--text); }
.tool, .foot button, .ghost { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; }
.tool:hover, .foot button:hover, .ghost:hover { border-color: var(--accent); }
.tone-btn.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.speed-btn { font-variant-numeric: tabular-nums; min-width: 4.2em; }
.speed-btn.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }   /* 不是 1× 时亮起 */
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: var(--panel); border: 0; padding: 6px 14px; }
.seg button.on { background: var(--accent); color: var(--accent-text); }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.progress { height: 3px; background: var(--line); }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s; }

main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 14px 18px 24px; }
.meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }
.timer { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 2px 12px; font-variant-numeric: tabular-nums; transition: color .3s, border-color .3s; }
.timer b { font-weight: 600; }
.timer.on { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 60%, transparent); }   /* 正在走表 */
/* 底部：声波条 + 答对/答错/正确率 */
.foot-top { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.wave { display: flex; align-items: center; gap: 3px; height: 24px; }
.wave i { display: block; width: 3px; height: 4px; border-radius: 2px; background: var(--accent); opacity: .35; transition: height .25s, opacity .25s; }
.wave.on i { opacity: 1; animation: wave .9s ease-in-out infinite alternate; }
.wave.on i:nth-child(3n+1) { animation-duration: .7s; }
.wave.on i:nth-child(3n+2) { animation-duration: 1.1s; }
.wave.on i:nth-child(4n) { animation-delay: -.3s; }
.wave.on i:nth-child(5n+2) { animation-delay: -.55s; }
.wave.on i:nth-child(7n+3) { animation-delay: -.15s; }
.wave.right { transform: scaleX(-1); }   /* 右边那组左右镜像，两边对称 */
@keyframes wave { 0% { height: 4px; } 50% { height: 22px; } 100% { height: 9px; } }
@media (prefers-reduced-motion: reduce) { .wave.on i { animation: none; height: 14px; } }
@media (max-width: 640px) { .wave { display: none; } }

.prev { margin: 18px auto 0; text-align: center; color: var(--muted); font-size: 14px; }
.prev b { color: var(--ok); font-weight: 600; margin: 0 8px; }

.card { text-align: center; padding: 18px 0 10px; }
.focus { margin: 0 0 6px; color: var(--muted); font-size: 13px; min-height: 20px; }
.focus b { color: var(--accent); font-weight: 600; }
.prompt { margin: 16px 0 0; font-size: clamp(17px, 2.2vw, 22px); font-weight: 500; line-height: 1.4; }

.pic { margin: 0 auto 10px; height: 120px; display: flex; align-items: center; justify-content: center; }
.pic .emoji { font-size: 84px; line-height: 1; }
.pic img { max-height: 120px; max-width: 220px; border-radius: 14px; object-fit: cover; }
.slots { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: 22px 12px; margin-top: 18px; }
.slot { display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 64px; padding: 8px 8px 6px; border-radius: 12px; border: 1px solid transparent; }
.slot .top { min-height: 36px; color: var(--muted); font-size: 15px; display: flex; align-items: baseline; gap: 6px; }
.slot .top .han { font-size: 28px; font-weight: 600; color: var(--text); }
:root { --lp0: #f0b429; --lp1: #3ecf8e; --lp2: #ff7ab6; }
:root[data-theme="light"] { --lp0: #b77400; --lp1: #12925a; --lp2: #c2337b; }
.lp0 { --lp: var(--lp0); } .lp1 { --lp: var(--lp1); } .lp2 { --lp: var(--lp2); }
.slot.lp { background: color-mix(in srgb, var(--lp) 13%, transparent); border-color: color-mix(in srgb, var(--lp) 55%, transparent); }
.slot.lp .top .han { color: var(--lp); }
.legend { min-height: 26px; margin-top: 14px; display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; font-size: 13px; }
.lp-label { color: var(--muted); }
.lp-chip { color: var(--lp); border: 1px solid color-mix(in srgb, var(--lp) 55%, transparent); background: color-mix(in srgb, var(--lp) 13%, transparent); border-radius: 999px; padding: 2px 10px; cursor: help; }
.hide-hint .slot.lp:not(.graded) { background: transparent; border-color: transparent; }
.hide-hint .legend { visibility: hidden; }
.slot .chip { font-size: 11px; line-height: 1; padding: 3px 7px; border-radius: 999px; color: #fff; min-height: 17px; }
.slot .chip:empty { visibility: hidden; }
.slot input {
  background: transparent; border: 0; border-bottom: 2px solid var(--slot-line); outline: 0;
  text-align: center; font-size: 30px; font-weight: 600; padding: 2px 4px; width: 3ch; caret-color: var(--accent);
}
.slot input:focus { border-bottom-color: var(--accent); }
.slot .gloss { max-width: 150px; min-height: 20px; font-size: 13px; color: var(--muted); line-height: 1.3; }
.slot.head .gloss { color: var(--accent); }
.slot.ok input { color: var(--ok); border-bottom-color: var(--ok); }
.slot.tone input { color: var(--tone); border-bottom-color: var(--tone); }
.slot.wrong input, .slot.empty input { color: var(--bad); border-bottom-color: var(--bad); }
.slot.shown input { color: var(--muted); font-style: italic; }
.punct { font-size: 30px; font-weight: 600; padding-top: 74px; }
.hide-hint .slot:not(.graded) .chip, .hide-hint .slot:not(.graded) .gloss { visibility: hidden; }

.pos-n { background: #d6529a; } .pos-v, .pos-mv { background: #7a5cf0; } .pos-a { background: #e07b39; }
.pos-d { background: #2f9e8f; } .pos-r { background: #2c8fd6; } .pos-m, .pos-q { background: #6b8e23; }
.pos-p, .pos-c { background: #b0568f; } .pos-u, .pos-i, .pos-o { background: #6c7a91; } .pos-af, .pos-ci, .pos-x { background: #a0703c; }

.feedback { min-height: 24px; margin: 16px 0 8px; color: var(--muted); }
.feedback.ok { color: var(--ok); } .feedback.bad { color: var(--bad); } .feedback.tone { color: var(--tone); }
.mid { min-height: 36px; }
.ghost { color: var(--ok); border-color: var(--ok); }

.analysis { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 22px; margin-top: 8px; }
.analysis h3 { margin: 18px 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .08em; }
.analysis h3:first-child { margin-top: 0; }
.analysis .sent { font-size: 22px; font-weight: 600; }
.analysis .py { color: var(--muted); }
.analysis .tr { margin-top: 2px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { border: 1px solid var(--line); background: var(--panel2); border-radius: 999px; padding: 2px 10px; font-size: 13px; }
.struct { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.seg-box { text-align: center; }
.seg-box .w { font-size: 20px; font-weight: 600; padding: 2px 8px 4px; border-bottom: 3px solid var(--muted); }
.seg-box .r { font-size: 12px; margin-top: 4px; color: var(--muted); }
.seg-box.r-主语 .w { border-color: #2c8fd6; } .seg-box.r-谓语 .w { border-color: #7a5cf0; }
.seg-box.r-宾语 .w { border-color: #d6529a; } .seg-box.r-状语 .w { border-color: #2f9e8f; }
.seg-box.r-补语 .w { border-color: #e07b39; } .seg-box.r-能愿动词 .w { border-color: #6b8e23; }
.seg-box.r-语气词 .w { border-color: #6c7a91; }
.note { color: var(--muted); font-size: 12px; margin-top: 8px; }
.points { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px; }
.point { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.point .name { font-weight: 600; }
.point .name small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.point .form { color: var(--accent); font-size: 13px; margin: 2px 0; }
.point .desc { font-size: 13px; color: var(--muted); }
.point mark { background: transparent; color: var(--tone); font-weight: 600; margin-right: 4px; }
.words { width: 100%; border-collapse: collapse; font-size: 14px; }
.words td { padding: 5px 8px; border-top: 1px solid var(--line); vertical-align: top; }
.words td:first-child { font-size: 18px; font-weight: 600; white-space: nowrap; }
.words tr.head td:first-child { color: var(--accent); }
.words .chip { font-size: 11px; padding: 2px 7px; border-radius: 999px; color: #fff; white-space: nowrap; }

.done { text-align: center; padding: 60px 0; }
.done h2 { font-size: 26px; margin: 0 0 8px; }
.done p { color: var(--muted); }
.done button { margin: 14px 6px 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 16px; }

.foot { border-top: 1px solid var(--line); padding: 10px 18px 14px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.stats { display: flex; gap: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; font-size: 13px; color: var(--muted); }
.stats span { padding: 4px 14px; border-right: 1px solid var(--line); }
.stats span:last-child { border-right: 0; }
.stats b { color: var(--text); margin-left: 4px; font-variant-numeric: tabular-nums; }
.stats b.ok { color: var(--ok); } .stats b.bad { color: var(--bad); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.foot button.primary, dialog button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.foot button.on { color: var(--tone); border-color: var(--tone); }
.foot button.speed-btn.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }   /* 速度按钮亮起：蓝底白字（不用上面那条橙字规则） */
.foot button:disabled { opacity: .45; cursor: default; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 20px 24px; width: min(560px, 92vw); max-height: 90vh; }
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog h2 { margin: 0 0 10px; font-size: 18px; }
fieldset { border: 0; padding: 0; margin: 0 0 14px; }
legend { color: var(--muted); font-size: 12px; padding: 0; margin-bottom: 4px; }
fieldset label { display: block; padding: 3px 0; }
.help h3 { font-size: 13px; color: var(--muted); margin: 0 0 4px; }
.help p { font-size: 13px; margin: 0 0 6px; color: var(--muted); }
.help b { color: var(--text); }
.dialog-actions { display: flex; justify-content: space-between; margin-top: 14px; }
dialog button { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 16px; }
dialog button.danger { color: var(--bad); }

@media (max-width: 640px) {
  .slot input, .punct { font-size: 24px; }
  .card { padding-top: 20px; }
  .prompt { margin-bottom: 22px; }
}
@media (max-height: 700px) { .pic { height: 72px; } .pic .emoji { font-size: 54px; } .pic img { max-height: 72px; } }

/* 不会时出现的提示 */
.slot.hinted:not(.graded) .top { color: #ffc542; animation: hint-in .35s ease-out; }
@keyframes hint-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 句末标点不占宽度，这样词块这一行和下面的整句翻译都以同一条中线居中 */
.slots > .slot-break { flex-basis: 100%; height: 0; }   /* 长句分两段 */
.slot-grp { display: flex; align-items: flex-start; gap: 2px; }   /* 词块 + 句中标点，不拆开换行 */
.slots > .punct:last-child { width: 0; margin-left: -12px; position: relative; left: 10px; white-space: nowrap; overflow: visible; }

/* ---------- 逐词实时判分 ---------- */
.slot input { caret-color: #2fbf71; }                 /* 打对时光标是绿色 */
.slot.bad input { caret-color: #ff8f8f; color: var(--bad); border-bottom: 2px solid var(--bad); }   /* 打错：光标微红、红下划线 */
.slot.done input { color: var(--ok); border-bottom-color: var(--ok); }
.slot.shake { animation: slot-shake .34s; }
@keyframes slot-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}
/* 先听后打：打对一个词才显示它的注释；整句打完才显示词性、语言点和本题词 */
.hide-hint .slot.done .gloss { visibility: visible; }
.hide-hint .card.finished .legend { visibility: visible; }
.hide-hint .card:not(.finished) .focus { visibility: hidden; }
/* 整句翻译：最下方小字 */
.prompt { font-size: clamp(14px, 1.5vw, 16px); font-weight: 400; color: var(--muted); }

/* ---------- 手机 / 平板 / 电视 ---------- */
.foot button { min-height: 38px; }
@media (max-width: 640px) {
  .foot { padding: 8px 8px calc(10px + env(safe-area-inset-bottom)); }
  .actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: 100%; }
  .actions button { padding: 8px 2px; font-size: 13px; min-height: 42px; }
  .slots { gap: 14px 6px; }
  .slot { min-width: 48px; padding: 6px 4px; }
}
@media (min-width: 641px) and (max-width: 1100px) { .actions { flex-wrap: wrap; } .actions button { padding: 9px 12px; white-space: nowrap; } }   /* 平板：按钮好点一些；一行放不下（如韩语、8 个按钮）就换到第二行，不超出屏幕 */
@media (min-width: 1900px) { body { zoom: 1.5; } }    /* 电视、大屏：整体放大，远处也看得清 */
@media (min-width: 2500px) { body { zoom: 2; } }
/* 底部两行（统计、按钮）始终贴在屏幕底部 */
.foot { position: sticky; bottom: 0; background: var(--bg); z-index: 5; }

/* 母语句子是题目：放在横线上方、字大一些，用户看着它、听着中文来打 */
.prompt { margin: 4px 0 0; font-size: clamp(19px, 2.6vw, 26px); font-weight: 500; color: var(--text); }

/* 从右到左的界面（阿拉伯语）：中文句子和拼音仍然从左到右 */
[dir=rtl] .slots, [dir=rtl] .slot input, [dir=rtl] .prev b, [dir=rtl] .analysis .sent, [dir=rtl] .analysis .py, [dir=rtl] .analysis .segs { direction: ltr; }

/* 整句拼音提示：在横线上方 */
.sent-hint-row { min-height: 34px; margin-top: 6px; display: flex; justify-content: center; align-items: center; }
.hint-btn { font-size: 12px; padding: 4px 10px; opacity: .75; }
.hint-btn:hover { opacity: 1; }
.sent-hint { margin: 0; font-size: clamp(16px, 2vw, 20px); color: #ffc542; letter-spacing: .02em; animation: hint-in .35s ease-out; }

/* 用户自己调的字体大小：练习区和底部两行一起放大缩小（顶栏不变，按钮位置不会跳） */
#stage, .foot { zoom: var(--scale, 1); }
.font-size { align-items: center; }
.font-size button { padding: 6px 10px; font-weight: 600; }
.font-size button:disabled { opacity: .4; cursor: default; }
.font-size span { min-width: 3.4em; text-align: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- 模式菜单 ---------- */
.view-pick { position: relative; }
.view-btn { font-weight: 600; color: var(--accent); border-color: var(--accent); }
.view-btn .caret { font-size: 10px; opacity: .7; }
.view-menu { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; min-width: 180px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 32px rgba(0,0,0,.35); }
[dir=rtl] .view-menu { left: auto; right: 0; }
.view-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font-size: 15px; text-align: start; }
.view-menu button:hover { background: var(--panel2); }
.view-menu button.on { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); font-weight: 600; }
.view-menu .vi { width: 1.4em; text-align: center; }
.view-menu .vn { flex: 1; }
.view-menu i { font-style: normal; }

/* 各模式显示哪些部分 */
body:not([data-view=dict]) .sent-hint-row, body:not([data-view=dict]) .kb { display: none; }
body[data-view=puzzle] #slots, body[data-view=speak] #slots { display: none; }
.alt { margin-top: 14px; }
.alt-tip { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.slot.study input { color: var(--text); border-bottom-color: var(--line); }

/* ---------- 拼图 ---------- */
.pz-answer { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 10px; min-height: 92px; }
.pz-gap { min-width: 64px; min-height: 76px; padding: 6px 10px; border-bottom: 3px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px; transition: border-color .2s; }
.pz-gap b { font-size: 30px; font-weight: 600; }
.pz-gap small { font-size: 14px; color: var(--muted); }
.pz-gap .gl { font-size: 12px; color: var(--muted); }
.pz-gap.done { border-bottom-color: var(--ok); }
.pz-gap.bad { border-bottom-color: var(--bad); }
.pz-answer .punct { padding-top: 0; padding-bottom: 8px; }
.pz-pool { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 22px; }
.pz-tile { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 64px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); cursor: pointer; box-shadow: 0 3px 0 var(--line); transition: transform .1s; }
.pz-tile b { font-size: 26px; font-weight: 600; }
.pz-tile small { font-size: 13px; color: var(--muted); }
.pz-tile:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-2px); }
.pz-tile:disabled, .pz-tile.used { visibility: hidden; }
.pz-tile.shake { animation: slot-shake .34s; border-color: var(--bad); }
.pz-tile.pulse { border-color: #ffc542; box-shadow: 0 0 0 3px rgba(255,197,66,.35); animation: tile-pulse 1s infinite; }
@keyframes tile-pulse { 50% { transform: scale(1.06); } }

/* ---------- 口语 ---------- */
.sp-sent { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 6px 12px; }
.sp-w { display: flex; flex-direction: column; align-items: center; padding: 4px 6px; border-radius: 10px; border-bottom: 3px solid transparent; }
.sp-w small { font-size: 15px; color: var(--muted); }
.sp-w b { font-size: 32px; font-weight: 600; }
.sp-w.ok { border-bottom-color: var(--ok); } .sp-w.ok b { color: var(--ok); }
.sp-w.bad { border-bottom-color: var(--bad); } .sp-w.bad b { color: var(--bad); }
.sp-sent .punct { padding-top: 0; font-size: 30px; }
.sp-mic { margin-top: 22px; display: inline-flex; align-items: center; gap: 10px; padding: 14px 26px; border-radius: 999px; border: 0; background: var(--accent); color: var(--accent-text); font-size: 16px; font-weight: 600; cursor: pointer; }
.sp-mic .ico { font-size: 22px; }
.sp-mic.on { background: var(--bad); animation: mic-pulse 1.2s infinite; }
@keyframes mic-pulse { 0% { box-shadow: 0 0 0 0 rgba(255,107,107,.55); } 100% { box-shadow: 0 0 0 18px rgba(255,107,107,0); } }
.sp-heard { min-height: 22px; margin: 12px 0 0; color: var(--muted); font-size: 15px; }
.sp-note { margin: 18px auto 10px; max-width: 520px; color: var(--muted); font-size: 14px; }
.sp-self { display: flex; justify-content: center; gap: 10px; }
.sp-self button { padding: 10px 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.sp-self button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* ---------- 键盘提示 ---------- */
.kb { margin: 18px auto 0; max-width: 620px; padding: 10px 14px 12px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); }
.kb-head { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.kb-title { font-size: 14px; font-weight: 600; color: var(--muted); }
.kb-tog { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel2); color: var(--muted); line-height: 1; }
.kb.closed .kb-body { display: none; }
.kb-body { margin-top: 10px; }
.kb-board { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 10px; border-radius: 14px; background: var(--panel2); direction: ltr; }
.kb-row { display: flex; gap: 5px; }
.kb-row.r2 { margin-left: 18px; } .kb-row.r3 { margin-left: -6px; }
.kb-key { position: relative; width: 38px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); border-bottom-width: 3px; font-size: 14px; font-weight: 600; color: var(--muted); transition: background .15s, color .15s, transform .15s; }
.kb-row.r0 .kb-key { height: 28px; font-size: 12px; }
.kb-key.space { width: 230px; }
.kb-key.back { width: 54px; }
.kb-key.home::after { content: ''; position: absolute; bottom: 5px; width: 10px; height: 2px; border-radius: 2px; background: var(--muted); }
/* 每根手指一种淡色，方便记住指法 */
.kb-key.f-fLP, .kb-f.f-fLP { --fc: #c084fc; } .kb-key.f-fLR, .kb-f.f-fLR { --fc: #60a5fa; }
.kb-key.f-fLM, .kb-f.f-fLM { --fc: #34d399; } .kb-key.f-fLI, .kb-f.f-fLI { --fc: #fbbf24; }
.kb-key.f-fTH, .kb-f.f-fTH { --fc: #94a3b8; }
.kb-key.f-fRI, .kb-f.f-fRI { --fc: #fb923c; } .kb-key.f-fRM, .kb-f.f-fRM { --fc: #f472b6; }
.kb-key.f-fRR, .kb-f.f-fRR { --fc: #22d3ee; } .kb-key.f-fRP, .kb-f.f-fRP { --fc: #a3e635; }
.kb-key { box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--fc) 45%, transparent); }
.kb-key.next { background: #f97316; border-color: #f97316; color: #fff; transform: translateY(-2px); animation: key-pulse 1s infinite; }
@keyframes key-pulse { 50% { box-shadow: 0 0 0 5px rgba(249,115,22,.3); } }
.kb-fingers { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; margin-top: 8px; direction: ltr; }
.kb-f { font-size: 11px; padding: 3px 7px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--fc) 50%, transparent); color: var(--muted); }
.kb-f.on { background: var(--fc); border-color: var(--fc); color: #111; font-weight: 600; }
.kb-next { min-height: 20px; margin: 8px 0 0; font-size: 14px; color: #f97316; font-weight: 600; }
@media (max-width: 640px) { .kb { display: none; } }
/* 屏幕不高（笔记本、字号放大）时：键盘和配图收紧一些，让提示句、横线、键盘尽量一屏放下 */
@media (max-height: 820px) {
  .kb { margin-top: 10px; padding: 6px 12px 8px; }
  .kb-body { margin-top: 6px; }
  .kb-board { gap: 3px; padding: 6px; }
  .kb-row { gap: 4px; }
  .kb-key { height: 28px; font-size: 13px; }
  .kb-row.r0 .kb-key { height: 22px; }
  .kb-fingers { margin-top: 5px; }
  .kb-next { margin-top: 4px; min-height: 18px; }
  .pic { height: 56px; margin-bottom: 6px; } .pic .emoji { font-size: 42px; } .pic img { max-height: 56px; }
}
/* 手机：顶栏只留模式、级别和「⋯」，其余设置点「⋯」展开，把屏幕留给题目 */
.more-btn { display: none; }
@media (max-width: 640px) {
  .bar { padding: 8px 10px; gap: 6px; }
  .brand span { display: none; }
  .brand b { font-size: 15px; }
  .more-btn { display: inline-block; font-size: 18px; line-height: 1; padding: 6px 12px; }
  .bar:not(.open) .tools > :not(.keep) { display: none; }
  .bar.open .more-btn { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
  .tools { gap: 6px; flex: 1 1 auto; }
  .tools > .pick.keep > span { display: none; }
  .tools > .pick.keep select { max-width: 9em; }
  .seg button { padding: 6px 10px; }
  .pic { height: 64px; margin-bottom: 4px; } .pic .emoji { font-size: 48px; } .pic img { max-height: 64px; }
}   /* 手机用屏幕键盘，不显示键盘提示 */

/* 电脑、平板：顶栏一行放不下时，app.js 的 fitBars() 逐级加 fold / fold2 / fold3，
   把不常用的（f1：界面语言、字号、主题；f2：范围）收进「⋯」，再去掉前缀小字；点「⋯」展开 */
@media (min-width: 641px) {
  .bar.fold .more-btn { display: inline-block; font-size: 18px; line-height: 1; padding: 6px 12px; }
  .bar.fold:not(.open) .tools > .f1 { display: none; }
  .bar.fold2:not(.open) .tools > .f2 { display: none; }
  .bar.fold3 .brand span, .bar.fold3 .tools > .pick > span:first-child { display: none; }
  .bar.fold3 .tools select { max-width: 11em; }
  .bar.fold4 .brand { display: none; }
  .bar.fold6:not(.open) .tools > .f3 { display: none; }
  .bar.fold7:not(.open) .tools > .f4 { display: none; }
  .bar.fold4 .tools { flex: 1 1 auto; justify-content: center; }
  .bar.fold.open .more-btn { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
  .bar.fold .tools { flex-wrap: nowrap; }
  .bar.fold.open .tools { flex-wrap: wrap; }
  /* 底部按钮栏一行放不下时逐级收紧，保持一行 */
  .actions.tight button { padding: 8px 10px; font-size: 14px; }
  .actions.tighter { gap: 5px; }
  .actions.tighter button { padding: 7px 7px; font-size: 13px; }
  .actions.tightest button { padding: 6px 5px; font-size: 12px; }
  .actions.tight, .actions.tighter, .actions.tightest { flex-wrap: nowrap; }
  /* 按钮里的字不折行（否则阿拉伯语等长标签会把一个按钮撑成两行高） */
  .tools button, .tools .pick, .tools .seg span, .actions button { white-space: nowrap; }
  .bar.fold5 .tools button, .bar.fold5 .tools select { font-size: 13px; }
  .bar.fold5 .tools .tool, .bar.fold5 .seg button { padding: 5px 7px; }
  .bar.fold5 .tools { gap: 4px; }
}
.hint-btn kbd { margin-inline-start: 4px; padding: 0 5px; border: 1px solid currentColor; border-radius: 4px; font-size: 10px; opacity: .8; }

/* ---------- 账号：登录、注册、付费解锁（account.js） ---------- */
html.acct-lock, html.acct-lock body { overflow: hidden; }
.acct { position: fixed; inset: 0; z-index: 1000; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.acct-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px 24px 18px; box-shadow: 0 10px 40px rgba(0,0,0,.25); margin: auto; }
.acct-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.acct-brand { font-size: 18px; letter-spacing: .04em; }
.acct-top select { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; }
.acct h2 { font-size: 22px; margin: 10px 0 14px; }
.acct p { color: var(--muted); line-height: 1.6; margin: 0 0 12px; }
.acct-field { display: block; margin: 0 0 12px; }
.acct-field > span:first-child { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.acct-field small { opacity: .8; }
.acct-input { display: flex; align-items: center; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; }
.acct-input:focus-within { border-color: var(--accent); }
.acct-input input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--text); font-size: 16px; padding: 10px 12px; }
.acct-eye { background: none; border: 0; color: var(--muted); font-size: 13px; padding: 0 12px; cursor: pointer; }
.acct-check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; color: var(--text); margin: 0 0 10px; line-height: 1.45; cursor: pointer; }
.acct-check input { margin-top: 3px; flex: none; }
.acct-check a, .acct-links a { color: var(--accent); }
.acct-sub { margin-inline-start: 24px; }
.acct-err { color: var(--bad) !important; min-height: 1.2em; font-size: 14px; margin: 4px 0 10px !important; }
.acct-err:empty { min-height: 0; margin: 0 !important; }
.acct-primary, .acct-secondary { width: 100%; padding: 11px 14px; border-radius: 10px; font-size: 16px; cursor: pointer; border: 1px solid var(--accent); }
.acct-primary { background: var(--accent); color: var(--accent-text); }
.acct-secondary { background: transparent; color: var(--accent); }
.acct-primary:disabled, .acct-secondary:disabled { opacity: .6; cursor: default; }
.acct-links { text-align: center; font-size: 14px; margin: 12px 0 0 !important; }
.acct-or { display: flex; align-items: center; gap: 10px; margin: 14px 0 !important; font-size: 13px; }
.acct-or::before, .acct-or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.acct-code { display: flex; gap: 8px; align-items: flex-end; }
.acct-code .acct-field { flex: 1; margin: 0; }
.acct-code .acct-secondary { width: auto; padding: 10px 16px; }
.acct-code input { text-transform: uppercase; letter-spacing: .05em; }
.acct-busy { text-align: center; padding: 24px 0; }
#acctBox .acct-me { margin: 0 0 10px; }
#acctBox .acct-check { font-size: 14px; }
#acctBox .acct-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
dialog.acct-fb { width: min(480px, calc(100% - 32px)); }
dialog.acct-fb h2 { margin-top: 0; }
.acct-fb-types { display: flex; gap: 16px; margin: 0 0 10px; }
dialog.acct-fb textarea { width: 100%; box-sizing: border-box; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; resize: vertical; }
.acct-code .acct-primary { width: auto; padding: 10px 18px; white-space: nowrap; }

/* ---------- 句子解析：弹出卡片（电脑居中，手机从底部滑上来） ---------- */
.analysis:not([hidden]) {
  position: fixed; z-index: 60; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(760px, calc(100vw - 32px)); max-height: min(82vh, 820px); overflow-y: auto; margin: 0;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .5), 0 14px 44px rgba(0, 0, 0, .45);
  animation: anaIn .18s ease-out;
}
@keyframes anaIn { from { transform: translate(-50%, -47%); } }
.ana-close { position: sticky; top: 0; float: right; margin: -6px -10px 0 8px; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel2); color: var(--text); font-size: 20px; line-height: 1; cursor: pointer; z-index: 1; }
[dir=rtl] .ana-close { float: left; margin: -6px 8px 0 -10px; }
@media (max-width: 640px) {
  .analysis:not([hidden]) { top: auto; bottom: 0; left: 0; transform: none; width: 100%; max-height: 78vh;
    border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); animation: anaUp .22s ease-out; }
  @keyframes anaUp { from { transform: translateY(30%); } }
}
@media (prefers-reduced-motion: reduce) { .analysis:not([hidden]) { animation: none; } }

/* ---------- 单词解析：点打对的词弹出的小卡片 ---------- */
.slots .slot { cursor: default; }
.slot:has(input[readonly]) { cursor: pointer; }
.word-pop { position: fixed; z-index: 70; min-width: 140px; max-width: min(320px, calc(100vw - 16px));
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35); animation: wpIn .14s ease-out; }
@keyframes wpIn { from { transform: translateY(-4px); } }
.word-pop .wp-hz { font-size: 30px; font-weight: 700; line-height: 1.2; }
.word-pop .wp-py { color: var(--tone); font-size: 17px; margin-top: 2px; }
.word-pop .wp-row { margin: 8px 0 4px; }
.word-pop .wp-row:empty { display: none; }
.word-pop .wp-gloss { font-size: 15px; line-height: 1.5; }
