/* ============================================================
 * 显微镜课件 · 教具操作台布局（lab-hud-ui-style 范式 2+）
 * 顶栏 + 左场景(悬浮工具族) + 右工作台(观察+编号控制Tab+参考工具)
 * 令牌：单蓝 #1677FF / 等宽数字 / 发丝线 / 磨砂玻璃
 * ============================================================ */
:root {
  --color-primary: #1677FF;
  --color-primary-deep: #0E5FD8;
  --color-base-tint: #E8F3FF;
  --color-glass-bg: rgba(255, 255, 255, 0.9);
  --color-glass-border: rgba(255, 255, 255, 0.78);
  --color-text-title: #233240;
  --color-text-body: #5A6B7C;
  --color-text-label: #8A94A3;
  --color-text-value: #1F2937;
  --color-hairline: rgba(148, 163, 184, 0.28);
  --color-success: #22C55E;
  --color-amber-text: #B97F24;
  --font-cn: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "IBM Plex Mono", Consolas, monospace;
  --shadow-panel: 0 10px 28px rgba(31, 60, 90, 0.1);
  --shadow-button: 0 2px 8px rgba(31, 60, 90, 0.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font: 14px/1.6 var(--font-cn);
  color: var(--color-text-title);
  background: #E9F0FA url("../bg-lab.jpg?v=5") center/cover no-repeat fixed;
  overflow: hidden;
}
body[data-mode="experiment"] { background-color: #E7EEF9; }
button { font: inherit; cursor: pointer; background: #fff; color: inherit; border: 1px solid #C9D8EE; border-radius: 8px; padding: 8px 13px; transition: background .16s, box-shadow .16s; }
button:hover { background: #EAF2FF; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid #8FB4EE; outline-offset: 2px; }
.hidden, [hidden] { display: none !important; }
.mono-value, output { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--color-text-value); }
small { font-weight: 400; color: var(--color-text-label); font-size: 11px; }
.tip { font-size: 12px; line-height: 1.7; color: var(--color-text-label); margin: 9px 0 0; }

/* ---------- 顶栏 ---------- */
header {
  height: 64px; padding: 0 22px; display: flex; align-items: center; gap: 20px;
  background: rgba(252, 253, 255, 0.82); backdrop-filter: blur(20px) saturate(1.15); -webkit-backdrop-filter: blur(20px) saturate(1.15);
  border-bottom: 1px solid #D9E6F8; position: relative; z-index: 40;
}
.brand { display: flex; gap: 11px; align-items: center; text-decoration: none; color: inherit; }
.brand-icon {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(180deg, #1677FF, #0E5FD8); color: #fff; font: 26px Georgia, serif;
}
.brand-text strong { font-size: 17px; letter-spacing: 1px; display: block; }
.brand-text small { font-size: 10px; letter-spacing: 1px; }
#modeNav { display: flex; background: #E8F3FF; padding: 4px; border-radius: 12px; gap: 4px; }
#modeNav button { border: 0; background: transparent; padding: 9px 22px; border-radius: 9px; font-weight: 500; }
#modeNav button.active { background: #1677FF; color: #fff; }
.header-actions { margin-left: auto; display: flex; gap: 8px; }
.header-actions button { font-size: 13px; padding: 7px 13px; }

/* P3 背景虚化层（REALISM.backgroundBlur 开关，默认关；开时教学文字不受影响——只虚背景） */
#bgBlur { position: fixed; inset: 0; z-index: -1; backdrop-filter: blur(2.5px) brightness(1.02); -webkit-backdrop-filter: blur(2.5px) brightness(1.02); pointer-events: none; }

/* ---------- 主体双列 ---------- */
main { display: grid; grid-template-columns: minmax(0, 1fr) 460px; height: calc(100dvh - 64px); }

/* ---------- 场景列 ---------- */
.scene { position: relative; overflow: hidden; background: linear-gradient(160deg, rgba(246,250,255,0.42), rgba(228,238,252,0.58)); }  /* 白蓝薄雾透出 6475 底板 */
#stage3d { position: absolute; inset: 0; }
#stage3d canvas { width: 100%; height: 100%; display: block; touch-action: none; }
#toast {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 30;
  background: rgba(18, 38, 70, 0.92); color: #DCEAFF; padding: 8px 16px; border-radius: 999px;
  font-size: 13px; max-width: 86%; text-align: center;
}
#toast.danger { background: rgba(150, 60, 30, 0.92); }
#loading { position: absolute; top: 42%; left: 40%; color: var(--color-text-label); }

.scene-title {
  position: absolute; top: 22px; left: 26px; z-index: 5; pointer-events: none;
  /* 垫板：白蓝玻璃渐变，防亮底板吃字 */
  background: linear-gradient(90deg, rgba(250,252,255,0.92) 62%, rgba(250,252,255,0.55));
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-radius: 12px; padding: 14px 30px 14px 16px;
}
.scene-title .eyebrow { font-size: 10px; letter-spacing: 2.5px; font-weight: 700; color: #7A93B8; }
.scene-title h1 { font-size: 25px; letter-spacing: 1px; margin: 8px 0 4px; color: #1C3A5E; }
.scene-title p { font-size: 13px; color: #7A93B8; }

.view-tools { position: absolute; top: 152px; left: 26px; display: flex; gap: 6px; z-index: 6; flex-wrap: wrap; max-width: calc(100% - 130px); }
.view-tools button { font-size: 12px; padding: 6px 11px; background: rgba(244, 249, 255, 0.78); backdrop-filter: blur(8px); }
.view-tools button.active { background: #1677FF; color: #fff; border-color: #1677FF; }

#parts {
  position: absolute; z-index: 7; left: 26px; top: 190px; width: 252px;
  max-height: 56%; overflow: auto; padding: 12px;
  background: rgba(250, 252, 255, 0.96); border: 1px solid #D9E6F8; border-radius: 12px;
  box-shadow: var(--shadow-panel);
}
#partsGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
#parts button { font-size: 12px; padding: 7px 5px; text-align: left; }
#parts button em { display: block; font-style: normal; font-family: var(--font-mono); font-size: 9px; color: var(--color-text-label); }
#parts button.active { background: #1677FF; color: #fff; border-color: #1677FF; }

.camera-tools { position: absolute; right: 14px; top: 180px; z-index: 6; display: flex; flex-direction: column; gap: 6px; width: 74px; }
.camera-tools button { min-height: 37px; padding: 7px 4px; font-size: 13px; background: rgba(244, 249, 255, 0.85); }
.camera-tools button:first-child, .camera-tools button:nth-child(2) { font-size: 22px; padding: 2px; }

.part-card {
  position: absolute; left: 26px; bottom: 24px; width: min(330px, 46%); z-index: 6; pointer-events: none;
  border-left: 3px solid #1677FF; padding: 4px 0 4px 16px;
  background: linear-gradient(90deg, rgba(240, 246, 255, 0.88), transparent);
}
.part-card .eyebrow { font-size: 10px; letter-spacing: 2px; font-weight: 700; color: #4A6FA5; }
.part-card h2 { font-size: 24px; margin: 7px 0; color: #1C3A5E; }
.part-card p { line-height: 1.75; font-size: 13.5px; color: #3A5A85; }
.part-card #partAction { display: block; font-size: 12px; color: var(--color-amber-text); margin-top: 9px; }

#activity {
  position: absolute; right: 18px; bottom: 22px; width: 284px; max-height: 62%; overflow: auto; z-index: 8;
  background: rgba(250, 252, 255, 0.96); border: 1px solid #D9E6F8; border-radius: 12px;
  padding: 16px; box-shadow: var(--shadow-panel);
}
#activity > div:first-child { display: flex; justify-content: space-between; align-items: center; }
#activity .eyebrow { font-size: 10px; letter-spacing: 2px; font-weight: 700; color: #7A93B8; }
#closeActivity { border: 0; background: none; font-size: 19px; padding: 0 4px; }
#activity h3 { font-size: 16px; margin: 8px 0 12px; }
#activitySteps { list-style: none; counter-reset: st; }
#activitySteps li { counter-increment: st; padding: 6px 0; font-size: 12.5px; display: flex; gap: 10px; align-items: center; color: #6E82A8; }
#activitySteps li::before { content: counter(st); display: grid; place-items: center; width: 21px; height: 21px; border-radius: 50%; background: #E3EDFC; font-size: 10px; flex-shrink: 0; font-family: var(--font-mono); }
#activitySteps li.done { color: #1667CC; }
#activitySteps li.done::before { content: "✓"; background: #CCE2FB; }
#activitySteps li.current { font-weight: 700; color: #16345C; }
#activitySteps li.current::before { background: #0E5FD8; color: #fff; }
#activityHint { font-size: 11.5px; color: #8A6D2F; line-height: 1.7; margin: 8px 0; }
#restartActivity { font-size: 11.5px; }

/* ---------- 工作台 ---------- */
.workbench {
  display: flex; flex-direction: column; gap: 12px; padding: 16px 20px 12px;
  background: rgba(251, 253, 255, 0.97); border-left: 1px solid #D9E6F8; overflow: auto;
}
.panel-heading { display: flex; align-items: center; justify-content: space-between; }
.panel-heading h2 { font-size: 17px; }
.panel-heading strong { font: 34px/1 var(--font-mono); font-weight: 600; color: #1677FF; }
.panel-heading strong span { font-size: 19px; }

.observation-body { display: grid; grid-template-columns: 208px minmax(0, 1fr); gap: 16px; align-items: center; margin-top: 10px; }
.scope-wrap {
  position: relative; width: 208px; aspect-ratio: 1; border-radius: 50%;
  border: 9px solid #9FB2C6;                                     /* 浅银金属目镜圈（替代深蓝黑） */
  overflow: hidden; background: #1B242C;
  box-shadow:
    0 0 0 1px #6E8299,                                           /* 圈外暗缘线 */
    0 0 0 4px #E6EEF8,                                           /* 银圈亮肩 */
    0 10px 24px rgba(18, 36, 70, 0.18);
}
.scope-wrap::after {                                             /* 内缘高光（压在视野上方的镜筒口反光） */
  content: ''; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.32), inset 0 -4px 10px rgba(20, 36, 60, 0.30);
}
#scope { width: 100%; height: 100%; display: block; touch-action: none; }
.scope-cross { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); opacity: .32; pointer-events: none; font: 24px var(--font-mono); color: #2A4A78; }
.scope-meta { min-width: 0; display: flex; flex-direction: column; gap: 9px; }
#scopeMessage {
  text-align: center; font-size: 12px; padding: 6px 9px; border-radius: 7px;
  background: #EDF4FF; color: #1C3A5E; border: 1px solid #D6E4FA;
}
#scopeMessage[data-quality="poor"] { background: #fdeee3; color: #a3562b; border-color: #f0d9c2; }
#scopeMessage[data-quality="near"] { background: #fbf4dd; color: #97803a; border-color: #eee1bb; }
.readings { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.readings span { padding: 4px 10px; border-radius: 999px; background: #EDF4FF; color: #4A6FA5; border: 1px solid #D6E4FA; }
.readings span[data-quality="good"] { background: #E0EEFF; color: #1677FF; border-color: #BBD8FA; }
.readings span[data-quality="poor"] { background: #fdeee3; color: #a3562b; border-color: #f0d9c2; }
.readings span[data-quality="near"] { background: #fbf4dd; color: #97803a; border-color: #eee1bb; }
.observation-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; color: #2A4A78; font-weight: 600; }
.observation-footer button { font-size: 11.5px; padding: 5px 10px; }

/* ---------- 控制区 ---------- */
.controls { flex: 1; min-height: 0; display: flex; flex-direction: column; border-top: 1px solid #D9E6F8; padding-top: 4px; overflow-y: auto; scrollbar-width: thin; }  /* 内容自滚：防溢出被参考区叠压点不到 */
.control-tabs { display: flex; gap: 6px; padding: 10px 0; position: sticky; top: 0; background: rgba(251, 253, 255, 0.98); z-index: 3; }
.control-tabs button { flex: 1; font-size: 13px; padding: 9px 6px; min-height: 40px; border: 0; background: #E8F1FE; border-radius: 9px; }
.control-tabs button.active { background: #1677FF; color: #fff; font-weight: 600; }
.control-panel { padding: 2px 0 10px; }
.field { margin: 7px 0 10px; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }  /* 亮度+光圈并排：保对光面板不溢出可点 */
.field label, .ctl-label { display: block; font-size: 13px; font-weight: 600; margin: 4px 0 7px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row label { margin: 0; }
.row output { font-size: 11.5px; }
.segmented { display: flex; gap: 6px; }
.segmented button { flex: 1; padding: 8px 4px; }
.segmented button.active { background: #1677FF; color: #fff; border-color: #1677FF; }
.lens-controls { display: grid; grid-template-columns: 1fr 104px; gap: 13px; }
.lens-controls select { width: 100%; }
select, .select-full {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid #C9D8EE;
  color: #1C3A5E; background: #fff; font: inherit;
}
input[type="range"] { accent-color: #1677FF; width: 100%; cursor: pointer; height: 22px; }
.range-labels { display: flex; justify-content: space-between; font-size: 10.5px; color: #7A93B8; }
.fine-buttons { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.fine-buttons button { font-size: 11.5px; padding: 5px 11px; }
.text-button { padding: 0; border: 0; background: none; font-size: 11px; color: var(--color-amber-text); }
.dpad { text-align: center; margin: 8px auto 4px; }
.dpad button { min-width: 44px; padding: 6px; margin: 2px; }
.slide-preview { margin: 12px 0; text-align: center; }
.slide-preview canvas { display: block; width: 100%; height: auto; border-radius: 6px; background: #E2EAF6; }
.slide-preview small { display: block; margin-top: 5px; }
#specimenCredit { display: block; margin-top: 5px; }

/* 教学面板 */
.teaching-panel .lesson-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0; }
.teaching-panel .lesson-choices button { font-size: 12px; padding: 8px 4px; }
.teaching-panel .lesson-choices button.active { background: #1677FF; color: #fff; border-color: #1677FF; }
.teaching-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.teaching-buttons button { font-size: 12px; flex: 1; min-width: 100px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg .seg-btn, .seg-btn { font-size: 12px; padding: 7px 10px; background: #fff; border: 1px solid #C9D8EE; border-radius: 8px; cursor: pointer; }
.seg .seg-btn.active, .seg-btn.active { background: #1677FF; color: #fff; border-color: #1677FF; }
#challenge h3 { font-size: 14.5px; margin: 10px 0; }
.answer-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.answer-choices button { flex: 1 1 40%; font-size: 12.5px; }
#choiceFeedback { min-height: 18px; font-size: 12.5px; margin: 6px 0; }
#choiceFeedback[data-result="correct"] { color: #2e9e6b; }
#choiceFeedback[data-result="wrong"] { color: #d9773f; }
#teachAnswer { margin-top: 6px; padding: 9px 11px; border-radius: 8px; background: #EDF4FF; font-size: 12.5px; line-height: 1.8; color: #1C3A5E; }

/* ---------- 参考工具 / notice ---------- */
.reference-tools { flex: none; border-top: 1px solid #D9E6F8; padding-top: 7px; }
.reference-tools > div { display: flex; gap: 6px; }
.reference-tools button { font-size: 12px; padding: 5px 9px; min-height: 30px; flex: 1; }
.reference-tools #bestView { background: #E3F0FF; border-color: #8FB4EE; font-weight: 600; }
.reference-tools p { font-size: 11px; line-height: 1.5; margin: 4px 0 2px; color: #5F7BA6; }
#notice { flex: none; font-size: 12px; line-height: 1.6; padding: 9px 0 2px; border-top: 1px solid #DDE8F8; color: #5F7BA6; }

/* ---------- selftest ---------- */
#selftestOverlay {
  position: fixed; inset: 10% 12%; z-index: 90; background: rgba(251, 253, 255, 0.98);
  border: 1px solid #C9D8EE; border-radius: 14px; padding: 22px; overflow: auto;
  font: 12.5px/1.9 var(--font-mono); color: #1C3A5E;
}
#selftestOverlay .pass { color: #2e9e6b; }
#selftestOverlay .fail { color: #d9773f; }
#selftestOverlay h2 { font-size: 16px; margin-bottom: 10px; }
#selftestOverlay .perf { margin-top: 8px; color: #5F7BA6; }

/* 选中部件大标签（HeModel 投影定位：left/top 由 JS 每帧计算，相对 #stage3d） */
#partLabel {
  position: absolute; z-index: 25; pointer-events: none; left: 0; top: 0;
  color: #fff; font: 800 17px/1.4 var(--font-cn); letter-spacing: 1px; white-space: nowrap;
  background: linear-gradient(135deg, #1677FF, #4C9AFF);
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 999px; padding: 7px 20px;
  box-shadow: 0 6px 22px rgba(22, 119, 255, 0.45), 0 1px 0 rgba(255, 255, 255, 0.4) inset;
}
#partLabel::after {
  content: ''; position: absolute; left: 50%; bottom: -6px; width: 11px; height: 11px;
  background: #2b83ff; transform: translateX(-50%) rotate(45deg); border-radius: 2px;
}

/* ---------- 响应式 ---------- */
@media (min-width: 1500px) { main { grid-template-columns: minmax(0, 1fr) 540px; } .observation-body { grid-template-columns: 232px 1fr; } .scope-wrap { width: 232px; } }
@media (max-width: 1150px) { main { grid-template-columns: minmax(0, 1fr) 392px; } .observation-body { grid-template-columns: 168px 1fr; } .scope-wrap { width: 168px; } }
/* 矮窗口：压缩目镜视野与表头，保右侧控制区完整可点（点不到滑杆的教训） */
@media (max-height: 920px) {
  .scope-wrap { width: 172px; }
  .observation-body { grid-template-columns: 172px minmax(0, 1fr); gap: 12px; margin-top: 6px; }
  .panel-heading strong { font: 28px/1 var(--font-mono); }
  .workbench { padding: 12px 20px 10px; gap: 8px; }
}
@media (max-width: 900px) {
  body { overflow: auto; }
  header { height: auto; min-height: 60px; flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  #modeNav { order: 3; width: 100%; justify-content: center; }
  main { display: block; height: auto; }
  .scene { height: 640px; }
  .workbench { border-left: 0; overflow: visible; }
  .observation-body { grid-template-columns: 232px 1fr; }
  .scope-wrap { width: 232px; }
  .part-card { max-width: 74%; }
}

/* ---------- 结构索引头部（标题 + 关闭） ---------- */
#parts { top: 190px; }
.parts-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: -6px -6px 8px; padding: 0 2px 6px;
  border-bottom: 1px solid var(--color-hairline, rgba(148,163,184,0.28));
}
.parts-title { font-size: 12px; font-weight: 700; color: var(--color-text-title, #233240); letter-spacing: 1px; }
#partsClose {
  border: 0; background: transparent; font-size: 18px; line-height: 1;
  color: var(--color-text-label, #8A94A3); padding: 0 4px; cursor: pointer;
}
#partsClose:hover { color: var(--color-text-title, #233240); background: transparent; }
