/* ==============================================================
   拆物 · 电子设备三维交互拆解演示系统  —— 界面样式
   --------------------------------------------------------------
   设计语言：深色工业风，以青色作为交互强调色，
   面板采用半透明玻璃质感，突出中间的三维视口。
   ============================================================== */

/* ---------------- 变量 ---------------- */
:root {
    --bg: #0b0e13;
    --bg-2: #11151c;
    --panel: rgba(20, 25, 34, 0.86);
    --panel-solid: #141922;
    --border: rgba(120, 145, 175, 0.16);
    --border-strong: rgba(120, 145, 175, 0.3);
    --text: #dfe6f0;
    --text-dim: #8b98ab;
    --text-faint: #5c6779;
    --accent: #38e0ff;
    --accent-dim: rgba(56, 224, 255, 0.14);
    --accent-2: #7c8cff;
    --warn: #ffb454;
    --ok: #4ade80;
    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
            "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --mono: "SF Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ---------------- 加载遮罩 ---------------- */
.loading {
    position: fixed; inset: 0; z-index: 999;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg);
    transition: opacity .5s ease, visibility .5s;
}
.loading.hide { opacity: 0; visibility: hidden; }

.loading-box { text-align: center; }

.loading-ring {
    width: 46px; height: 46px; margin: 0 auto 18px;
    border: 3px solid rgba(56, 224, 255, 0.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-box p { color: var(--text-dim); letter-spacing: .5px; }

/* ---------------- 总体布局 ---------------- */
.app {
    display: grid;
    grid-template-rows: 58px 1fr 62px;
    height: 100vh;
}

/* ---------------- 顶栏 ---------------- */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 18px;
    background: var(--bar-grad);
    border-bottom: 1px solid var(--border);
    z-index: 10;
}

.brand { display: flex; align-items: center; gap: 12px; }

/* 返回门户 */
.back-link {
    width: 30px; height: 30px; flex-shrink: 0;
    display: grid; place-items: center;
    border-radius: 8px;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 15px;
    text-decoration: none;
    transition: all .16s;
}
.back-link:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-dim);
}

.logo {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    font-size: 17px; color: #04121a;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-radius: 9px;
    box-shadow: 0 0 18px rgba(56, 224, 255, 0.35);
}

.brand-text h1 {
    font-size: 15px; font-weight: 600; letter-spacing: .6px;
    line-height: 1.2;
}
.brand-text h1 span {
    font-size: 11px; font-weight: 400; color: var(--text-faint);
    letter-spacing: 1.6px; margin-left: 5px; text-transform: uppercase;
}
.brand-text p { font-size: 11px; color: var(--text-faint); margin-top: 2px; }

.toolbar { display: flex; align-items: center; gap: 16px; }
.tool-group { display: flex; align-items: center; gap: 7px; }
.tool-label { font-size: 11px; color: var(--text-faint); letter-spacing: .5px; }

/* 分段控件 */
.seg {
    display: inline-flex;
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px;
    gap: 2px;
}
.seg button {
    padding: 5px 11px;
    font-size: 12px;
    color: var(--text-dim);
    border-radius: 5px;
    transition: all .16s;
    white-space: nowrap;
}
.seg button:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.seg button.on {
    color: #04121a;
    background: linear-gradient(135deg, var(--accent), #4fc8ff);
    font-weight: 600;
    box-shadow: 0 0 12px rgba(56, 224, 255, 0.28);
}
.seg-sm button { padding: 4px 9px; font-size: 11px; }

/* 按钮 */
.btn {
    padding: 6px 13px;
    font-size: 12px;
    color: var(--text-dim);
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all .16s;
    white-space: nowrap;
}
.btn:hover { color: var(--text); border-color: var(--border-strong); background: rgba(255, 255, 255, 0.06); }
.btn.on {
    color: #04121a; font-weight: 600;
    background: linear-gradient(135deg, var(--accent), #4fc8ff);
    border-color: transparent;
}
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn-primary {
    background: linear-gradient(135deg, var(--accent), #4fc8ff);
    color: #04121a; font-weight: 600; border-color: transparent;
}
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 11.5px; }

/* ---------------- 主区 ---------------- */
.stage {
    display: grid;
    grid-template-columns: 258px 1fr 322px;
    /* ⚠ 行必须显式约束住容器高度。默认的隐式行是 auto ⇒ 按**内容**撑开：
       侧栏内容一旦比行高还高（1366×768 这类笔记本上很常见），侧栏就被撑到 728px，
       而 .stage 只有 648px —— 多出来的部分被 .side 的 overflow:hidden 裁掉，
       「开始实训」按钮正好落在裁掉的那一截里、还被底栏压住：**看得见但点不到**
       （实测 elementFromPoint 命中的是底栏的滑块）。minmax(0,1fr) 让它严格等于容器高度，
       侧栏内部再由 .practice-body 自己滚动。 */
    grid-template-rows: minmax(0, 1fr);
    min-height: 0;
}

/* 侧栏 */
.side {
    display: flex; flex-direction: column;
    background: var(--panel);
    backdrop-filter: blur(14px);
    min-height: 0;
    overflow: hidden;
}
.side-left { border-right: 1px solid var(--border); }
.side-right { border-left: 1px solid var(--border); }

.side-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px 9px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.side-head h2 {
    font-size: 11.5px; font-weight: 600;
    letter-spacing: 1.4px; color: var(--text-dim);
    text-transform: uppercase;
}
.side-head-sub { margin-top: 2px; border-top: 1px solid var(--border); }
.side-sub { font-size: 10.5px; color: var(--text-faint); font-family: var(--mono); }
.side-foot {
    padding: 8px 14px; border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.hint { font-size: 10.5px; color: var(--text-faint); line-height: 1.6; }

/* ---------------- 结构树 ---------------- */
.tree { flex: 1; overflow-y: auto; padding: 8px 6px 14px; }

.tree-node { user-select: none; }

.tree-row {
    display: flex; align-items: center; gap: 5px;
    padding: 4px 7px;
    border-radius: 5px;
    cursor: pointer;
    transition: background .14s, color .14s;
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.5;
}
.tree-row:hover { background: var(--hover-bg); color: var(--text); }
.tree-row.sel {
    background: var(--accent-dim);
    color: var(--accent);
    box-shadow: inset 2px 0 0 var(--accent);
}
.tree-row.is-group { color: var(--text); font-weight: 500; }

.tree-toggle {
    width: 13px; height: 13px; flex-shrink: 0;
    display: grid; place-items: center;
    font-size: 8px; color: var(--text-faint);
    transition: transform .16s;
}
.tree-toggle.open { transform: rotate(90deg); }
.tree-toggle.leaf { visibility: hidden; }

.tree-dot {
    width: 5px; height: 5px; border-radius: 50%;
    flex-shrink: 0; background: var(--text-faint);
}
.tree-row.is-group .tree-dot { background: var(--accent-2); }
.tree-row.sel .tree-dot { background: var(--accent); }

.tree-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-children { margin-left: 11px; border-left: 1px solid var(--border); padding-left: 3px; }
.tree-children.collapsed { display: none; }

/* ---------------- 三维视口 ---------------- */
.viewport { position: relative; min-width: 0; background: var(--viewport-bg); }
#view { display: block; width: 100%; height: 100%; }

/* 拖动旋转视角时不要把页面文字选中。
   症状：按住左键拖模型，结果选中了右侧面板/提示条上的文字，相机一动不动 ——
   一旦浏览器进入"选择文本"状态，后续 mousemove 都归选区所有，画布收不到。
   对策：① 视口与整个应用外壳默认禁止选择（输入框与可复制片段除外）；
        ② 指针按下时给 body 加 .dragging（scene.js 里加/remove），
           拖动过程中连面板文字也不可选。 */
.viewport, #view, .app-shell, .topbar, .side, .panel-stack, .bottom-bar {
    -webkit-user-select: none;
    user-select: none;
}
#view { touch-action: none; -webkit-user-drag: none; }
body.dragging, body.dragging * {
    -webkit-user-select: none !important;
    user-select: none !important;
    cursor: grabbing !important;
}
/* 这些地方仍要能选中/复制：口令提示、成绩单文本、输入框 */
input, textarea, select, [contenteditable="true"], .selectable, .res-formula, .res-meta, .pr-hint-text {
    -webkit-user-select: text;
    user-select: text;
}

.hud { position: absolute; pointer-events: none; }
.hud-tl { top: 14px; left: 14px; display: flex; gap: 8px; }

.hud-item {
    display: flex; flex-direction: column; align-items: center;
    padding: 6px 11px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    backdrop-filter: blur(8px);
    min-width: 58px;
}
.hud-item b { font-family: var(--mono); font-size: 13px; color: var(--accent); font-weight: 600; }
.hud-item span { font-size: 9.5px; color: var(--text-faint); letter-spacing: .8px; margin-top: 1px; }

.hud-br { bottom: 14px; right: 16px; }
.hud-tip {
    font-size: 10.5px; color: var(--text-faint);
    background: var(--panel);
    padding: 5px 11px; border-radius: 20px;
    border: 1px solid var(--border);
    backdrop-filter: blur(8px);
}

/* 剖切条 */
.clipbar {
    position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
    display: none; align-items: center; gap: 11px;
    padding: 8px 14px;
    background: var(--panel);
    border: 1px solid var(--border-strong);
    border-radius: 24px;
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
}
.clipbar.show { display: flex; }
.clipbar > span { font-size: 11px; color: var(--text-dim); }
.clipbar #clip-val { font-family: var(--mono); font-size: 11px; color: var(--accent); min-width: 34px; }
.clipbar input[type=range] { width: 130px; }

/* ---------------- 信息面板 ---------------- */
.info { flex: 1; overflow-y: auto; padding: 13px 14px; min-height: 120px; }

.empty { text-align: center; padding: 26px 10px; color: var(--text-faint); }
.empty-sm { padding: 14px 10px; }
.empty-icon { font-size: 26px; opacity: .3; margin-bottom: 9px; }
.empty p { font-size: 12px; color: var(--text-dim); margin-bottom: 5px; }
.empty span { font-size: 10.5px; line-height: 1.7; display: block; }

.info-title {
    display: flex; align-items: baseline; gap: 8px;
    padding-bottom: 9px; margin-bottom: 11px;
    border-bottom: 1px solid var(--border);
}
.info-title h3 { font-size: 15px; font-weight: 600; color: var(--text); }
.info-id {
    font-family: var(--mono); font-size: 10px;
    color: var(--text-faint); background: var(--code-bg);
    padding: 2px 6px; border-radius: 4px;
}

.info-field { margin-bottom: 13px; }
.info-field label {
    display: block; font-size: 10px; letter-spacing: 1.2px;
    color: var(--text-faint); text-transform: uppercase;
    margin-bottom: 5px;
}
.info-field p { font-size: 12.5px; line-height: 1.75; color: var(--text); }
.info-field.spec p { font-family: var(--mono); font-size: 11.5px; color: var(--accent); }
.info-field.tip {
    background: rgba(255, 180, 84, 0.07);
    border-left: 2px solid var(--warn);
    padding: 9px 11px; border-radius: 0 6px 6px 0;
}
.info-field.tip p { font-size: 11.5px; color: #ffd9a8; line-height: 1.7; }

.info-actions { display: flex; gap: 7px; margin-top: 15px; }

/* ---------------- 引导面板 ---------------- */
.guide { flex: 1; overflow-y: auto; padding: 12px 14px; min-height: 90px; }

.guide-step {
    display: flex; gap: 10px; margin-bottom: 9px;
    padding: 9px 10px; border-radius: var(--radius-sm);
    background: var(--code-bg);
    border: 1px solid transparent;
    transition: all .2s;
}
.guide-step.cur {
    background: var(--accent-dim);
    border-color: rgba(56, 224, 255, 0.3);
}
.guide-step.done { opacity: .42; }

.guide-num {
    width: 20px; height: 20px; flex-shrink: 0;
    display: grid; place-items: center;
    font-family: var(--mono); font-size: 10.5px; font-weight: 600;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-dim);
}
.guide-step.cur .guide-num { background: var(--accent); color: #04121a; }
.guide-step.done .guide-num { background: rgba(74, 222, 128, 0.2); color: var(--ok); }

.guide-body h4 { font-size: 12px; font-weight: 600; margin-bottom: 3px; color: var(--text); }
.guide-body p { font-size: 11px; line-height: 1.72; color: var(--text-dim); }
.guide-step.cur .guide-body p { color: #b9c6d6; }

.guide-actions {
    display: flex; gap: 7px; padding: 10px 14px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.guide-actions .btn { flex: 1; text-align: center; }
.guide-actions #btn-guide-start { flex: 1.5; }

/* ---------------- 底栏 ---------------- */
.bottombar {
    display: flex; align-items: center; gap: 20px;
    padding: 0 20px;
    background: var(--bar-grad-up);
    border-top: 1px solid var(--border);
    z-index: 10;
}

.play {
    display: flex; align-items: center; gap: 9px;
    padding: 9px 20px;
    background: linear-gradient(135deg, var(--accent), #4fc8ff);
    color: #04121a; font-weight: 600; font-size: 13px;
    border-radius: 22px;
    box-shadow: 0 0 20px rgba(56, 224, 255, 0.3);
    transition: transform .14s, box-shadow .14s;
    flex-shrink: 0;
}
.play:hover { transform: translateY(-1px); box-shadow: 0 0 26px rgba(56, 224, 255, 0.45); }
.play:active { transform: translateY(0); }
.play.playing { background: linear-gradient(135deg, var(--warn), #ffcf7a); }
.play-icon { font-size: 11px; }

.slider-wrap { display: flex; align-items: center; gap: 12px; flex: 1; }
/* 实训模式下这两个是浏览工具的：置灰并拦住指针，免得学生拖了以为「零件装不回去」 */
.slider-wrap.is-disabled { opacity: .4; pointer-events: none; }
.play:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; transform: none; }
.slider-label { font-size: 11.5px; color: var(--text-dim); white-space: nowrap; letter-spacing: .5px; }
.slider-val {
    font-family: var(--mono); font-size: 12.5px;
    color: var(--accent); min-width: 42px; text-align: right;
    font-weight: 600;
}

/* 滑块统一风格 */
input[type=range] {
    -webkit-appearance: none; appearance: none;
    flex: 1; height: 4px; border-radius: 2px;
    background: rgba(120, 145, 175, 0.22);
    outline: none; cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 15px; height: 15px; border-radius: 50%;
    background: var(--accent);
    border: 2px solid #0b0e13;
    box-shadow: 0 0 10px rgba(56, 224, 255, 0.7);
    transition: transform .14s;
}
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.18); }
input[type=range]::-moz-range-thumb {
    width: 13px; height: 13px; border-radius: 50%;
    background: var(--accent); border: 2px solid #0b0e13;
    box-shadow: 0 0 10px rgba(56, 224, 255, 0.7);
}

/* ---------------- 滚动条 ---------------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(120, 145, 175, 0.22);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(120, 145, 175, 0.4); background-clip: content-box; }

/* ==============================================================
   实训模式新增样式
   ============================================================== */

/* 主模式切换（顶栏居中） */
.seg-mode {
    background: var(--code-bg);
    border-color: var(--border-strong);
    padding: 3px;
}
.seg-mode button { padding: 7px 20px; font-size: 12.5px; }

/* 面板堆叠容器 */
.panel-stack {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}
.hidden { display: none !important; }

/* ---------------- 实训状态条 ---------------- */
.practice-hud {
    position: absolute;
    top: 14px; left: 50%; transform: translateX(-50%);
    display: none;
    gap: 4px;
    padding: 7px 8px;
    background: var(--panel);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
}
.practice-hud.show { display: flex; }

.ph-item {
    display: flex; flex-direction: column; align-items: center;
    padding: 3px 16px;
    border-right: 1px solid var(--border);
}
.ph-item:last-child { border-right: none; }
.ph-label { font-size: 9.5px; color: var(--text-faint); letter-spacing: 1px; }
.ph-item b {
    font-family: var(--mono); font-size: 16px; font-weight: 600;
    color: var(--accent); line-height: 1.25;
}
.ph-item b.warn { color: var(--warn); }
.ph-item b.bad { color: #ff6b6b; }

/* ---------------- 操作反馈气泡 ---------------- */
.feedback {
    position: absolute;
    bottom: 78px; left: 50%; transform: translateX(-50%) translateY(12px);
    max-width: 70%;
    padding: 11px 20px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.6;
    background: var(--panel-solid);
    border: 1px solid var(--border-strong);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s, transform .22s;
    text-align: center;
}
.feedback.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.feedback.ok {
    border-color: rgba(74, 222, 128, 0.5);
    color: #9ff0bd;
    box-shadow: 0 0 24px rgba(74, 222, 128, 0.16);
}
.feedback.err {
    border-color: rgba(255, 107, 107, 0.5);
    color: #ffb3b3;
    box-shadow: 0 0 24px rgba(255, 107, 107, 0.16);
}
.feedback .fb-hint {
    display: block; margin-top: 5px;
    font-size: 11.5px; color: var(--text-dim);
}

/* ---------------- 实训面板 ---------------- */
.practice-body { flex: 1; overflow-y: auto; padding: 12px 14px; min-height: 0; }

.pr-task {
    padding: 11px 12px;
    background: rgba(56, 224, 255, 0.06);
    border: 1px solid rgba(56, 224, 255, 0.18);
    border-radius: var(--radius-sm);
    margin-bottom: 11px;
}
.pr-task-title {
    font-size: 10px; letter-spacing: 1.2px; color: var(--accent);
    text-transform: uppercase; margin-bottom: 5px;
}
.pr-task p { font-size: 12px; line-height: 1.72; color: var(--text-dim); }

.pr-hint {
    display: flex; gap: 9px; align-items: flex-start;
    padding: 9px 11px; margin-bottom: 11px;
    background: rgba(255, 180, 84, 0.09);
    border-left: 2px solid var(--warn);
    border-radius: 0 6px 6px 0;
}
.pr-hint-label {
    font-size: 10px; color: var(--warn); flex-shrink: 0;
    padding-top: 2px; letter-spacing: 1px;
}
.pr-hint p { font-size: 11.5px; line-height: 1.7; color: #ffd9a8; }

.pr-list-head {
    display: flex; justify-content: space-between;
    font-size: 10.5px; color: var(--text-faint);
    letter-spacing: 1px; margin-bottom: 7px;
    padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.pr-list-head span:last-child { font-family: var(--mono); color: var(--accent); }

.pr-item {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 9px; margin-bottom: 3px;
    border-radius: 6px;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-left: 2px solid var(--text-faint);
    color: var(--text-dim);
    transition: all .2s;
}
.pr-item.done {
    border-left-color: var(--ok);
    color: var(--text-faint);
    text-decoration: line-through;
    opacity: .6;
}
.pr-item.next {
    border-left-color: var(--accent);
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 600;
}
.pr-item .pr-idx {
    font-family: var(--mono); font-size: 10px;
    color: var(--text-faint); min-width: 16px;
}
.pr-item.done .pr-idx { color: var(--ok); }

/* ---------------- 成绩单弹窗 ---------------- */
.modal {
    position: fixed; inset: 0; z-index: 500;
    display: none;
    align-items: center; justify-content: center;
    background: rgba(5, 8, 12, 0.78);
    backdrop-filter: blur(6px);
    padding: 20px;
}
.modal.show { display: flex; }

.modal-box {
    width: min(480px, 100%);
    max-height: 88vh; overflow-y: auto;
    background: var(--modal-bg);
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    animation: modalIn .26s cubic-bezier(.2,.9,.3,1.1);
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(16px) scale(.97); }
    to   { opacity: 1; transform: none; }
}

.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 15px; font-weight: 600; }
.modal-close {
    width: 26px; height: 26px; border-radius: 7px;
    color: var(--text-faint); font-size: 13px;
    display: grid; place-items: center;
    transition: all .15s;
}
.modal-close:hover { background: rgba(255,255,255,.08); color: var(--text); }

/* 总分 */
.res-score { display: flex; align-items: center; gap: 20px; padding: 20px; }
.res-total {
    display: flex; flex-direction: column; align-items: center;
    padding-right: 20px; border-right: 1px solid var(--border);
    flex-shrink: 0;
}
.res-total b {
    font-family: var(--mono); font-size: 44px; font-weight: 700;
    line-height: 1;
    background: linear-gradient(135deg, var(--accent), #7c8cff);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
.res-total span { font-size: 10.5px; color: var(--text-faint); letter-spacing: 1.4px; margin-top: 6px; }

.res-bars { flex: 1; display: flex; flex-direction: column; gap: 11px; }
.res-bar { display: flex; align-items: center; gap: 9px; }
.res-bar label { font-size: 11px; color: var(--text-dim); width: 68px; flex-shrink: 0; }
.res-bar .bar {
    flex: 1; height: 6px; border-radius: 3px;
    background: rgba(120, 145, 175, 0.18);
    overflow: hidden;
}
.res-bar .bar i {
    display: block; height: 100%; width: 0;
    background: linear-gradient(90deg, var(--accent), #7c8cff);
    border-radius: 3px;
    transition: width .8s cubic-bezier(.2,.9,.3,1);
}
.res-bar span {
    font-family: var(--mono); font-size: 12px;
    color: var(--accent); width: 42px; text-align: right;
}

.res-meta {
    display: flex; gap: 8px; padding: 0 20px 16px;
    flex-wrap: wrap;
}
.res-meta .chip {
    font-size: 11px; padding: 4px 10px; border-radius: 20px;
    background: rgba(255,255,255,.05);
    border: 1px solid var(--border);
    color: var(--text-dim);
}
.res-meta .chip b { color: var(--text); font-family: var(--mono); }

/* 失误记录 */
.res-errors { padding: 0 20px 16px; }
.res-errors-head {
    font-size: 10.5px; letter-spacing: 1.2px; color: var(--text-faint);
    text-transform: uppercase; margin-bottom: 8px;
    padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.res-err {
    display: flex; gap: 9px; align-items: flex-start;
    padding: 8px 0; border-bottom: 1px dashed rgba(120,145,175,.14);
    font-size: 11.5px; line-height: 1.65;
}
.res-err:last-child { border-bottom: none; }
.res-err .n {
    font-family: var(--mono); font-size: 10px; color: #ff8b8b;
    flex-shrink: 0; padding-top: 1px; min-width: 18px;
}
.res-err .txt { color: var(--text-dim); }
.res-err .txt b { color: #ffb3b3; font-weight: 600; }
.res-err .txt i { color: var(--ok); font-style: normal; font-weight: 600; }

.res-perfect {
    padding: 4px 0 14px; text-align: center;
    font-size: 12.5px; color: var(--ok);
}

/* 计分口径：把总分是怎么算出来的写清楚，学生与教师都看得懂 */
.res-formula {
    margin: 10px 20px 0;
    padding: 9px 12px;
    border-radius: 9px;
    font-size: 11.5px; line-height: 1.75;
    color: var(--text-dim);
    background: var(--code-bg);
    border: 1px solid var(--border);
}
.res-formula b { color: var(--accent); font-variant-numeric: tabular-nums; }
.res-formula b.bad { color: #ff7b7b; }

.modal-actions {
    display: flex; gap: 10px; padding: 16px 20px 20px;
    border-top: 1px solid var(--border);
}
.modal-actions .btn { flex: 1; text-align: center; padding: 10px; }

/* ---------------- 实训面板：本机最好成绩 ---------------- */
.pr-best {
    display: flex; align-items: baseline; gap: 8px;
    margin: 0 14px 10px;
    padding: 8px 11px;
    border-radius: 9px;
    font-size: 11px; color: var(--text-faint);
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-left: 2px solid var(--text-faint);
}
.pr-best b {
    margin-left: auto;
    font-family: var(--mono); font-size: 16px; font-weight: 700;
    color: var(--text); font-variant-numeric: tabular-nums;
}
.prb-times { font-size: 10.5px; }
.pr-best.is-good { border-left-color: var(--ok); }
.pr-best.is-good b { color: var(--ok); }
.pr-best.is-mid { border-left-color: var(--warn); }
.pr-best.is-mid b { color: var(--warn); }
.pr-best.is-low { border-left-color: #ff7b7b; }
.pr-best.is-low b { color: #ff7b7b; }

/* ---------------- 成绩单：历史记录 ---------------- */
.res-history {
    margin: 0 20px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--code-bg);
    overflow: hidden;
}
.res-history-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 9px 12px;
    font-size: 11.5px; color: var(--text-faint);
    border-bottom: 1px solid var(--border);
    letter-spacing: .3px;
}
.res-best { color: var(--accent); font-variant-numeric: tabular-nums; }
.res-history-list { max-height: 176px; overflow-y: auto; }
.res-empty { padding: 14px 12px; font-size: 11.5px; color: var(--text-faint); text-align: center; }
.res-row {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: 'time score' 'meta meta';
    gap: 2px 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}
.res-row:last-child { border-bottom: none; }
.res-row.is-best { background: var(--accent-dim); }
.rr-time { grid-area: time; font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.rr-score {
    grid-area: score;
    font-family: var(--mono); font-size: 15px; font-weight: 700;
    color: var(--accent); font-variant-numeric: tabular-nums;
}
.rr-meta { grid-area: meta; font-size: 11px; color: var(--text-dim); }
.res-more { padding: 7px 12px; font-size: 10.5px; color: var(--text-faint); text-align: center; }

/* 分成上下两组：上面是导出类操作（数量会变），下面是主操作（右对齐） */
.modal-actions-split { flex-direction: column; align-items: stretch; gap: 9px; }
.modal-actions-split .ma-left { display: flex; gap: 8px; flex-wrap: wrap; }
.modal-actions-split .ma-right { display: flex; gap: 8px; justify-content: flex-end; }
.modal-actions-split .btn { flex: 0 0 auto; padding: 9px 15px; }

/* ---------------- 快捷键浮层 ---------------- */
.hotkeys { position: fixed; inset: 0; z-index: 950; pointer-events: none; }
.hotkeys.show { pointer-events: auto; }
.hk-mask {
    position: absolute; inset: 0;
    background: rgba(4, 7, 11, 0.5);
    backdrop-filter: blur(3px);
    opacity: 0; transition: opacity .22s;
}
.hotkeys.show .hk-mask { opacity: 1; }
.hk-box {
    position: absolute; left: 50%; top: 50%;
    transform: translate(-50%, -46%) scale(.97);
    width: min(460px, 92vw);
    background: var(--panel-solid);
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.45);
    opacity: 0; transition: opacity .22s, transform .22s;
}
.hotkeys.show .hk-box { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.hk-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 15px 18px 12px;
    border-bottom: 1px solid var(--border);
}
.hk-head h3 { font-size: 14.5px; font-weight: 600; letter-spacing: .5px; }
.hk-close {
    width: 26px; height: 26px; border-radius: 7px;
    color: var(--text-faint); font-size: 12px;
    display: grid; place-items: center;
    background: none; border: none; cursor: pointer;
    transition: all .15s;
}
.hk-close:hover { background: var(--hover-bg); color: var(--text); }
.hk-list { list-style: none; padding: 10px 18px 6px; }
.hk-list li {
    display: flex; align-items: center; gap: 12px;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12.5px;
}
.hk-list li:last-child { border-bottom: none; }
.hk-keys { display: flex; gap: 4px; flex: 0 0 118px; }
.hk-keys kbd {
    display: inline-block; min-width: 24px;
    padding: 3px 7px;
    font-family: var(--mono); font-size: 10.5px; line-height: 1.3;
    text-align: center; color: var(--text);
    background: var(--code-bg);
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 5px;
}
.hk-label { color: var(--text-dim); }
.hk-foot {
    padding: 11px 18px 15px;
    font-size: 11px; color: var(--text-faint);
    border-top: 1px solid var(--border);
    line-height: 1.7;
}

/* ---------------- 响应式补充 ---------------- */
@media (max-width: 1180px) {
    .stage { grid-template-columns: 210px 1fr 286px; }
    .tool-label { display: none; }
    .seg-mode button { padding: 6px 13px; font-size: 11.5px; }
}

@media (max-width: 940px) {
    /* ⚠ 窄屏必须放开整页滚动，并给三维视口一个真实高度。
       原因：手机上顶栏会折成好几行（品牌 / 模式 / 方向 / 工具各占一行），
       而 .app 锁死 100vh、body 又 overflow:hidden —— 剩下给 .stage 的空间
       被侧栏（max-height:44vh）吃掉，三维视口实测只剩约 90px 高的一条缝。
       学生主要在手机上练，视口一条缝等于不能练。 */
    html, body { overflow: auto; }
    .app { height: auto; min-height: 100vh; grid-template-rows: auto auto auto; }
    .topbar { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px 14px; }
    .toolbar { flex-wrap: wrap; gap: 10px; }
    .seg-mode { order: -1; }
    .stage { grid-template-columns: 1fr; grid-template-rows: auto auto; }
    /* 视口给固定视口高度：既不依赖剩余空间，也不会被侧栏挤扁 */
    .viewport { height: 54vh; min-height: 300px; }
    .side { overflow: visible; }
    .side-left { display: none; }
    .side-right {
        border-left: none; border-top: 1px solid var(--border);
        max-height: none;
        /* ⚠ 此前这里是「限高 44vh + 整列可滚」。限高是必要的（否则「开始实训」
           整行被裁在视口外、怎么点都点不到），但配合 100vh 的 .app 会把三维
           视口压成一条缝。整页可滚之后限高就不需要了：面板按内容自然排开，
           按钮永远在文档流里，滚一下必到。 */
        overflow: visible;
    }
    .side-right .panel-stack { flex: none; }
    .bottombar { flex-wrap: wrap; gap: 12px; padding: 12px 14px; }
    .slider-wrap { order: 3; width: 100%; }

    .practice-hud { top: auto; bottom: 12px; }
    .ph-item { padding: 3px 11px; }
    .ph-item b { font-size: 14px; }
    .feedback { bottom: 76px; }

    .modal-actions-split { flex-direction: column; align-items: stretch; }
    .modal-actions-split .ma-right { margin-left: 0; }
    .modal-actions-split .btn { flex: 1; }
}

/* ---------------- 打印：只出成绩单 ---------------- */
/*
 * 教师常要把成绩单打出来存档。默认直接 Ctrl+P 会把三维视口、结构树
 * 一起打进去，既费墨又没用。这里只保留弹窗内容。
 */
@media print {
    body * { visibility: hidden !important; }
    #result-modal, #result-modal * { visibility: visible !important; }
    #result-modal {
        position: absolute !important; inset: 0 !important;
        background: #fff !important;
        display: block !important;
    }
    #result-modal .modal-box {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        background: #fff !important;
        color: #000 !important;
        max-height: none !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
    }
    #result-modal .modal-actions,
    #result-modal .modal-close { display: none !important; }
    #result-modal .res-history { border-color: #ccc !important; background: #fff !important; }
    #result-modal .res-history-list { max-height: none !important; }
}


/* ==============================================================
   在线考核（assess.js）
   --------------------------------------------------------------
   与离线练习共用右侧面板，新增：任务信息条 / 交卷区 /
   拖拽偏差读数 / 登录与任务选择弹窗。
   ============================================================== */

/* ---- 顶栏「在线考核」按钮 ---- */
.btn-assess {
    border-color: rgba(56, 224, 255, 0.45);
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 600;
}
.btn-assess:hover { background: rgba(56, 224, 255, 0.22); color: var(--accent); }
.btn-assess.is-on { border-color: rgba(74, 222, 128, 0.5); background: rgba(74, 222, 128, 0.14); color: var(--ok); }

/* ---- 任务信息条 ---- */
.as-task {
    margin: 0 0 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(56, 224, 255, 0.05);
}
.as-task-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.as-task-row b { font-size: 12.5px; font-weight: 600; }
.as-badge {
    flex: 0 0 auto; padding: 1px 7px; border-radius: 20px;
    font-size: 10px; letter-spacing: .04em;
    background: var(--accent-dim); color: var(--accent);
    border: 1px solid rgba(56, 224, 255, 0.3);
}
.as-badge.asm { background: rgba(74,222,128,.14); color: var(--ok); border-color: rgba(74,222,128,.35); }
.as-task-meta { font-size: 10.5px; color: var(--text-dim); line-height: 1.7; }
.as-task-meta span + span::before { content: ' · '; color: var(--text-faint); }

/* ---- 交卷区 ---- */
.as-submit { margin-top: 10px; }
.btn-block { width: 100%; text-align: center; padding: 10px; }
.as-submit-note { margin-top: 6px; font-size: 10px; color: var(--text-faint); text-align: center; line-height: 1.6; }

/* ---- 拖拽实时偏差读数 ---- */
.dev-hud {
    position: absolute; left: 50%; bottom: 66px; transform: translateX(-50%) translateY(6px);
    min-width: 220px; padding: 9px 14px;
    border: 1px solid var(--border-strong); border-radius: var(--radius);
    background: var(--panel); backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
    opacity: 0; pointer-events: none; transition: opacity .16s, transform .16s;
    z-index: 6;
}
.dev-hud.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.dev-row { display: flex; align-items: baseline; justify-content: center; gap: 6px; }
.dev-label { font-size: 10.5px; color: var(--text-dim); }
.dev-row b { font-family: var(--mono); font-size: 19px; font-weight: 700; color: var(--accent); }
.dev-hud.near .dev-row b { color: var(--ok); }
.dev-unit { font-size: 10px; color: var(--text-faint); }
.dev-tol { height: 3px; margin: 7px 0 5px; border-radius: 3px; background: rgba(255,255,255,.08); overflow: hidden; }
.dev-tol i { display: block; height: 100%; width: 0%; background: var(--accent); transition: width .08s linear; }
.dev-hud.near .dev-tol i { background: var(--ok); }
.dev-note { font-size: 10px; color: var(--text-faint); text-align: center; }

/* ---- 登录弹窗 ---- */
.modal-sm { max-width: 400px; }
.lg-body { padding: 4px 0 2px; }
.lg-note { font-size: 11.5px; color: var(--text-dim); line-height: 1.8; margin-bottom: 14px; }
.lg-note b { color: var(--text); }
.lg-field { display: block; margin-bottom: 12px; }
.lg-field span { display: block; font-size: 11px; color: var(--text-dim); margin-bottom: 5px; }
.lg-field input {
    width: 100%; padding: 9px 11px; font-size: 13px;
    color: var(--text); background: rgba(0, 0, 0, 0.22);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-family: inherit; outline: none; transition: border-color .15s;
}
.lg-field input:focus { border-color: rgba(56, 224, 255, 0.5); }
.lg-error { min-height: 16px; font-size: 11.5px; color: var(--err, #ff6b6b); margin-top: 2px; }

/* ---- 任务选择弹窗 ---- */
.tm-body { max-height: 56vh; overflow-y: auto; }
.tm-user {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 11px; margin-bottom: 12px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
    font-size: 11.5px; color: var(--text-dim);
}
.tm-user b { color: var(--text); }
.tm-list { display: flex; flex-direction: column; gap: 8px; }
.tm-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 13px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.025);
    cursor: pointer; transition: border-color .15s, background .15s;
}
.tm-item:hover { border-color: var(--border-strong); background: rgba(255, 255, 255, 0.055); }
.tm-item-main { flex: 1 1 auto; min-width: 0; }
.tm-item-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.tm-item-meta { font-size: 10.5px; color: var(--text-dim); }
.tm-item-meta span + span::before { content: ' · '; color: var(--text-faint); }
.tm-item-score { flex: 0 0 auto; text-align: right; font-family: var(--mono); }
.tm-item-score b { display: block; font-size: 17px; color: var(--accent); }
.tm-item-score span { font-size: 9.5px; color: var(--text-faint); }
.tm-item-score.done b { color: var(--ok); }
.tm-tag {
    display: inline-block; padding: 1px 6px; margin-left: 6px;
    font-size: 9.5px; border-radius: 20px; vertical-align: 1px;
    background: rgba(255, 180, 84, 0.16); color: var(--warn);
}
.tm-tag.exam { background: rgba(255, 107, 107, 0.16); color: #ff8a8a; }
.tm-tag.ok { background: rgba(74, 222, 128, 0.16); color: var(--ok); }
.tm-note { margin-top: 14px; font-size: 10.5px; color: var(--text-faint); line-height: 1.8; }

@media (max-width: 940px) {
    .dev-hud { bottom: 58px; min-width: 180px; padding: 7px 11px; }
    .dev-row b { font-size: 16px; }
}
/* 拖拽时让反馈气泡让位，避免与偏差读数叠在视口底部中央 */
.feedback.dim { opacity: 0 !important; transform: translateX(-50%) translateY(8px); }
/* 初始化失败时不要继续转圈（转圈会让用户以为还在加载） */
.loading.failed .loading-ring { display: none; }
.loading.failed #loading-text { line-height: 1.9; max-width: 460px; }
/* ==============================================================
   提示功能
   ============================================================== */
.btn-hint {
    border-color: rgba(255, 180, 84, 0.42);
    background: rgba(255, 180, 84, 0.10);
    color: var(--warn);
}
.btn-hint:hover:not(:disabled) { background: rgba(255, 180, 84, 0.2); color: var(--warn); }
.btn-hint:disabled { opacity: .32; }

.hint-cost {
    margin: 7px 0 0;
    font-size: 10.5px;
    line-height: 1.7;
    color: var(--text-faint);
    text-align: center;
}

/* 被提示标亮的部件：树行与进度项脉冲 */
@keyframes hintPulse {
    0%, 100% { background: rgba(255, 180, 84, 0); box-shadow: none; }
    12%      { background: rgba(255, 180, 84, 0.26); box-shadow: 0 0 0 1px rgba(255,180,84,.55) inset; }
    50%      { background: rgba(255, 180, 84, 0.10); box-shadow: 0 0 0 1px rgba(255,180,84,.25) inset; }
}
.hint-pulse { animation: hintPulse 1.3s ease-in-out 2; border-radius: var(--radius-sm); }

.pr-hint .hint-why { color: var(--text-dim); font-size: 11px; }
.pr-hint .hint-cost-inline { color: var(--warn); font-size: 10.5px; }