/* ============================================================================
   lab.css — 3D 互动实验室样式
   设计约束（给孩子用）：
     · 所有可点控件触摸目标 ≥ 44px
     · 滑块轨道加粗，拇指加大
     · 桌面：左 3D / 右面板；手机：上 3D / 下面板
   ========================================================================== */

:root {
  --primary: #3b5bdb;
  --primary-dark: #2f49af;
  --primary-soft: #e7ecfd;
  --accent: #0ca678;
  --warn: #e8590c;
  --danger: #e03131;
  --text: #1c2530;
  --text-soft: #5a6a7d;
  --muted: #8494a8;
  --border: #d9e0ea;
  --surface: #ffffff;
  --surface-2: #f5f7fb;
  --shadow: 0 4px 16px rgba(24, 40, 70, .08);
  --shadow-lg: 0 12px 34px rgba(24, 40, 70, .14);
  --r: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #7a95f5;
    --primary-dark: #5f7ce8;
    --primary-soft: #1e2740;
    --text: #e8edf5;
    --text-soft: #a9b6c8;
    --muted: #7d8a9c;
    --border: #2b3648;
    --surface: #151c27;
    --surface-2: #1b232f;
    --shadow: 0 4px 16px rgba(0, 0, 0, .35);
    --shadow-lg: 0 12px 34px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--surface-2);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

a { color: var(--primary); }

/* --------------------------------------------------------------- 顶栏 */

.lb-top {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
  min-height: 58px;
}
.lb-brand {
  display: flex; align-items: center; gap: 9px;
  text-decoration: none; color: var(--text); font-weight: 800;
  margin-right: auto; min-width: 0;
}
.lb-brand b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-brand span { font-size: 20px; line-height: 1; }
.lb-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.lb-nav a {
  text-decoration: none; color: var(--text-soft); font-weight: 650; font-size: 14px;
  padding: 9px 12px; border-radius: 10px; white-space: nowrap;
}
.lb-nav a:hover { background: var(--surface-2); color: var(--text); }
.lb-nav a.active { background: var(--primary-soft); color: var(--primary); }

.lb-lang { display: flex; gap: 2px; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.lb-lang button {
  border: 0; background: transparent; color: var(--text-soft);
  font: inherit; font-weight: 700; font-size: 13px;
  padding: 8px 11px; border-radius: 8px; cursor: pointer; min-height: 36px;
}
.lb-lang button.on { background: var(--primary); color: #fff; }

/* ------------------------------------------------------------- 主布局 */

.lb-shell { display: flex; flex-direction: column; height: calc(100dvh - 58px); }
.lb-main { display: flex; flex: 1; min-height: 0; }

.lb-stage {
  position: relative; flex: 1; min-width: 0; min-height: 0;
  background: #eef2f7;
}
.lb-stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }

/* 舞台浮层 */
.lb-hud {
  position: absolute; left: 12px; top: 12px; right: 12px;
  display: flex; gap: 8px; flex-wrap: wrap; pointer-events: none; z-index: 5;
}
.lb-hud > * { pointer-events: auto; }
.lb-chip {
  background: rgba(255, 255, 255, .93);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; font-weight: 700;
  box-shadow: var(--shadow); backdrop-filter: blur(6px);
  display: inline-flex; align-items: center; gap: 6px;
}
.lb-chip.ok { color: #087f5b; border-color: #9fe0c4; background: rgba(230, 250, 241, .95); }
.lb-chip.warn { color: var(--warn); border-color: #ffd8a8; background: rgba(255, 244, 230, .95); }
.lb-chip.bad { color: var(--danger); border-color: #ffc9c9; background: rgba(255, 240, 240, .95); }
.lb-chip.btn { cursor: pointer; }
.lb-chip.btn:hover { background: #fff; }

.lb-hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  background: rgba(28, 37, 48, .86); color: #fff;
  padding: 9px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 650;
  z-index: 6; pointer-events: none; max-width: 92%; text-align: center;
  opacity: 0; transition: opacity .28s;
}
.lb-hint.show { opacity: 1; }

.lb-toast {
  position: absolute; left: 50%; top: 66px; transform: translateX(-50%) translateY(-8px);
  padding: 10px 18px; border-radius: 12px; font-weight: 750; font-size: 14px;
  z-index: 8; pointer-events: none; opacity: 0; transition: all .25s;
  box-shadow: var(--shadow-lg);
}
.lb-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.lb-toast.good { background: #0ca678; color: #fff; }
.lb-toast.bad { background: #e03131; color: #fff; }
.lb-toast.info { background: #3b5bdb; color: #fff; }

/* WebGL 不可用时的提示条（不阻断实验，只少了 3D 画面） */
.lb-nogl {
  position: absolute; left: 12px; right: 12px; top: 12px; z-index: 7;
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  background: #fff4e6; border: 1px solid #ffd8a8; color: #b35309;
  border-radius: 12px; padding: 10px 14px; font-size: 13px;
  box-shadow: var(--shadow);
}
.lb-nogl b { font-size: 13.5px; }
@media (prefers-color-scheme: dark) {
  .lb-nogl { background: #2c1e0c; border-color: #7a4a12; color: #ffc078; }
}

/* 载入 / 报错遮罩 */
.lb-veil {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: var(--surface-2); z-index: 20; text-align: center; padding: 24px;
}
.lb-veil.hide { display: none; }
.lb-spin {
  width: 34px; height: 34px; margin: 0 auto 12px;
  border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------- 控制面板 */

.lb-panel {
  width: 372px; flex: 0 0 372px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 16px 16px 40px;
}
.lb-panel-head { margin-bottom: 14px; }
.lb-panel-head h1 { font-size: 19px; margin: 0 0 4px; letter-spacing: -.2px; }
.lb-panel-head .en { color: var(--muted); font-size: 12.5px; font-weight: 650; letter-spacing: .3px; }
.lb-panel-head p { color: var(--text-soft); font-size: 13.5px; margin: 8px 0 0; }

/* 面板内部 */
.lp { display: flex; flex-direction: column; gap: 14px; }
.lp-sec {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 12px 13px;
}
.lp-sec-t {
  font-weight: 800; font-size: 13.5px; letter-spacing: .2px;
  margin-bottom: 10px; color: var(--text);
}
.lp-sec-b { display: flex; flex-direction: column; gap: 12px; }

/* 滑块 */
.ctl { display: flex; flex-direction: column; gap: 5px; }
.ctl-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; }
.ctl-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ctl-l { font-size: 13.5px; font-weight: 650; color: var(--text-soft); }
.ctl-v {
  font: 700 13.5px/1 ui-monospace, Menlo, Consolas, monospace;
  color: var(--primary); white-space: nowrap;
  background: var(--primary-soft); padding: 4px 8px; border-radius: 7px;
}
.rng {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 30px; background: transparent; cursor: pointer; margin: 0;
}
.rng::-webkit-slider-runnable-track {
  height: 8px; border-radius: 99px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary) var(--pct, 50%), var(--border) var(--pct, 50%));
}
.rng::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: #fff; border: 3px solid var(--primary);
  box-shadow: 0 2px 7px rgba(0, 0, 0, .22);
  margin-top: -9px; cursor: grab;
}
.rng::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.06); }
.rng::-moz-range-track { height: 8px; border-radius: 99px; background: var(--border); }
.rng::-moz-range-progress { height: 8px; border-radius: 99px; background: var(--primary); }
.rng::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 3px solid var(--primary); box-shadow: 0 2px 7px rgba(0, 0, 0, .22);
}

/* 开关 */
.sw {
  width: 54px; height: 31px; border-radius: 99px; border: 1px solid var(--border);
  background: var(--border); position: relative; cursor: pointer; padding: 0;
  transition: background .2s; flex: 0 0 auto;
}
.sw .sw-k {
  position: absolute; top: 2px; left: 2px; width: 25px; height: 25px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
  transition: transform .2s;
}
.sw.on { background: var(--accent); border-color: var(--accent); }
.sw.on .sw-k { transform: translateX(23px); }

/* 分段 */
.seg { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.seg-b {
  flex: 1; border: 0; background: transparent; color: var(--text-soft);
  font: inherit; font-weight: 700; font-size: 13px; padding: 9px 6px;
  border-radius: 8px; cursor: pointer; min-height: 38px;
}
.seg-b.on { background: var(--primary); color: #fff; }

/* 按钮 */
.lp-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.lp-btn {
  flex: 1 1 auto; min-height: 44px; padding: 10px 14px;
  border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 750; font-size: 14px; cursor: pointer;
}
.lp-btn:hover { background: var(--surface-2); }
.lp-btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.lp-btn.primary:hover { background: var(--primary-dark); }
.lp-btn.danger { color: var(--danger); border-color: #ffc9c9; }
.lp-btn:disabled { opacity: .45; cursor: not-allowed; }

/* 读数 */
.ro { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ro-c {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 11px; padding: 9px 11px; transition: all .25s;
}
.ro-c.wide { grid-column: 1 / -1; }
.ro-c.acc { border-color: var(--primary); background: var(--primary-soft); }
.ro-c.hit { transform: scale(1.045); border-color: var(--accent); box-shadow: 0 0 0 3px rgba(12, 166, 120, .18); }
.ro-k { font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: .2px; }
.ro-v { font: 800 19px/1.25 ui-monospace, Menlo, Consolas, monospace; color: var(--text); }
.ro-v i { font-style: normal; font-size: 12px; color: var(--muted); font-weight: 700; }

/* 提示条 */
.lp-note {
  font-size: 13px; color: var(--text-soft); line-height: 1.5;
  background: var(--surface); border: 1px dashed var(--border);
  border-radius: 11px; padding: 10px 12px;
}
.lp-note.ok { border-color: #9fe0c4; background: #f2fbf7; color: #087f5b; }
.lp-note.warn { border-color: #ffd8a8; background: #fff8ef; color: #b35309; }
@media (prefers-color-scheme: dark) {
  .lp-note.ok { background: #0e2a20; color: #63e6be; }
  .lp-note.warn { background: #2c1e0c; color: #ffc078; }
}

/* 图例 */
.lg { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; font-weight: 700; color: var(--text-soft); }
.lg-i { display: inline-flex; align-items: center; gap: 5px; }
.lg-i i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* 图表 */
.ch { background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 8px; }
.ch-c { width: 100%; height: 132px; display: block; }
.ch-lg { margin-top: 6px; padding-left: 4px; }

/* 条形对比 */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-r { display: grid; grid-template-columns: 82px 1fr 72px; align-items: center; gap: 8px; }
.bar-k { font-size: 12px; font-weight: 700; color: var(--text-soft); }
.bar-t { height: 16px; background: var(--surface); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.bar-t i { display: block; height: 100%; transition: width .25s; }
.bar-v { font: 700 12.5px/1 ui-monospace, Menlo, monospace; text-align: right; color: var(--text); }

/* -------------------------------------------------------- 实验室首页 */

.lb-home { max-width: 1080px; margin: 0 auto; padding: 22px 18px 60px; }
.lb-hero {
  background: linear-gradient(135deg, #3b5bdb, #0ca678);
  color: #fff; border-radius: 20px; padding: 26px 24px; margin-bottom: 22px;
  box-shadow: var(--shadow-lg);
}
.lb-hero h1 { margin: 0 0 8px; font-size: clamp(23px, 4vw, 32px); letter-spacing: -.4px; }
.lb-hero p { margin: 0; opacity: .95; font-size: 15px; max-width: 62ch; }
.lb-hero .lb-hero-b { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.lb-hero .lb-hero-b a, .lb-hero .lb-hero-b span {
  background: rgba(255, 255, 255, .2); border: 1px solid rgba(255, 255, 255, .35);
  color: #fff; text-decoration: none; padding: 9px 15px; border-radius: 999px;
  font-weight: 700; font-size: 13.5px;
}

.lb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); gap: 15px; }
.lb-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 17px;
  padding: 17px; text-decoration: none; color: inherit; display: flex; flex-direction: column;
  box-shadow: var(--shadow); transition: transform .16s, box-shadow .16s, border-color .16s;
}
.lb-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--primary); }
.lb-card .ic { font-size: 30px; line-height: 1; margin-bottom: 10px; }
.lb-card h3 { margin: 0 0 3px; font-size: 16.5px; }
.lb-card .en { color: var(--muted); font-size: 12px; font-weight: 650; margin-bottom: 8px; }
.lb-card p { margin: 0 0 12px; color: var(--text-soft); font-size: 13.5px; flex: 1; }
.lb-card .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.lb-card .tag {
  font-size: 11.5px; font-weight: 700; color: var(--primary);
  background: var(--primary-soft); padding: 3px 9px; border-radius: 999px;
}
.lb-card.soon { opacity: .62; }
.lb-card.soon .tag { color: var(--muted); background: var(--surface-2); }

/* 移动端 */
@media (max-width: 900px) {
  .lb-nav { display: none; }
  .lb-main { flex-direction: column; }
  .lb-stage { flex: 0 0 46vh; min-height: 300px; }
  .lb-panel {
    width: auto; flex: 1 1 auto; border-left: 0; border-top: 1px solid var(--border);
    padding: 14px 14px 60px;
  }
  .lb-shell { height: auto; min-height: calc(100dvh - 58px); }
}
@media (max-width: 520px) {
  .lb-stage { flex-basis: 40vh; min-height: 260px; }
  .ro { grid-template-columns: 1fr 1fr; }
  .bar-r { grid-template-columns: 68px 1fr 62px; }
}

@media print {
  .lb-panel { display: none; }
  .lb-stage { flex: 1; }
}
