* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* --- 嵌入模式：落地页 iframe 演示，只留模型与加载层 --- */
body.embed #hdr,
body.embed #infoBar,
body.embed #bar,
body.embed #dims,
body.embed .panel,
body.embed #qOv,
body.embed #pTray,
body.embed #pPick,
body.embed #moreMenu,
body.embed #helpOv,
body.embed #vcWrap { display: none !important; }
body.embed #hint { bottom: 18px; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: #eef1f6; color: #1e293b;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
#app { position: fixed; inset: 0; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* 顶部标题 */
#hdr {
  position: absolute; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: linear-gradient(180deg, rgba(255,255,255,.92), rgba(255,255,255,0));
  pointer-events: none;
}
#hdrTitle { font-size: 15px; font-weight: 650; letter-spacing: .2px; color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hdrMeta { font-size: 11.5px; color: #7c8798; white-space: nowrap; }

/* 遮罩 / 密码门 / 加载 */
#overlay {
  position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 38%, #ffffff 0%, #eef2f8 65%, #e6ebf3 100%);
  transition: opacity .25s;
}
#overlay.hide { opacity: 0; pointer-events: none; }
#ovBox { width: min(340px, 84vw); text-align: center; }
#ovIcon { width: 54px; height: 54px; margin: 0 auto 16px; opacity: .95; }
#ovIcon svg { width: 100%; height: 100%; stroke: #4F46E5; fill: none; stroke-width: 1.4; }
#ovTitle { font-size: 15px; font-weight: 650; margin-bottom: 8px; color: #0f172a; }
#ovText { font-size: 12.5px; line-height: 1.6; color: #64748b; word-break: break-word; }
#ovForm { margin-top: 18px; display: flex; gap: 8px; }
#ovPass {
  flex: 1; min-width: 0; height: 42px; padding: 0 12px;
  border-radius: 10px; border: 1px solid #d7dee8; background: #fff; color: #0f172a;
  font-size: 15px; outline: none;
}
#ovPass:focus { border-color: #4F46E5; box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
#ovBtn {
  height: 42px; padding: 0 18px; border: none; border-radius: 10px;
  background: #4F46E5; color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
}
#ovBar { margin-top: 16px; height: 4px; border-radius: 4px; background: #e2e8f0; overflow: hidden; }
#ovBar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #4F46E5, #7C3AED); transition: width .2s; }
#ovRetry {
  margin-top: 16px; height: 38px; padding: 0 18px; border-radius: 10px;
  border: 1px solid #d7dee8; background: #fff; color: #475569; font-size: 13px; cursor: pointer;
}
.hide { display: none !important; }

/* 底部工具栏 */
#bar {
  position: absolute; z-index: 20;
  left: 50%; transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex; gap: 2px; padding: 6px;
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 18px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 28px rgba(15,23,42,.12);
}
#bar button {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  width: 56px; padding: 8px 0 7px; border: none; border-radius: 13px;
  background: transparent; color: #3f4c5f; cursor: pointer;
  font-size: 10.5px; font-family: inherit;
  transition: background .15s, color .15s;
}
#bar button svg { width: 19px; height: 19px; }
#bar button:active { background: rgba(79,70,229,.10); color: #4F46E5; }
#bar button.on { background: #4F46E5; color: #fff; }

/* 浮动面板 */
.panel {
  position: absolute; z-index: 20; right: 14px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  width: 252px; padding: 12px 14px 13px;
  background: rgba(255,255,255,.97);
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 14px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 32px rgba(15,23,42,.14);
}
/* 测量模式 */
.mModes { flex-wrap: wrap; gap: 4px; }
.mModes button { flex: 1 1 auto; min-width: 40px; height: 28px; font-size: 11px; padding: 0 5px; }

/* 整体尺寸 / 面积 / 体积 */
.pStats {
  font-size: 11px; color: #52606f; line-height: 1.7;
  border-top: 1px solid #eef2f8; padding-top: 9px; margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.pStats b { color: #0f172a; font-weight: 650; }
.pStats .sk { color: #94a3b8; }
.pRow { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.pRow:last-child { margin-bottom: 0; }
.pRow b { font-size: 12.5px; font-weight: 650; color: #0f172a; }
.pClose { border: none; background: transparent; color: #94a3b8; font-size: 19px; line-height: 1; cursor: pointer; padding: 0 2px; }
.pBig { font-size: 19px; font-weight: 700; color: #0f172a; font-variant-numeric: tabular-nums; margin: 4px 0 10px; }
.pBig small { font-size: 11px; font-weight: 500; color: #7c8798; margin-left: 3px; }
.pBtn {
  flex: 1; height: 32px; border-radius: 8px; border: 1px solid #d7dee8;
  background: #f8fafc; color: #475569; font-size: 12px; cursor: pointer;
}
.pBtn:active { background: #eef2f8; }
.pTip { font-size: 10.5px; color: #94a3b8; margin-top: 8px; line-height: 1.5; }
.seg { gap: 4px; }
.seg button {
  flex: 1; height: 30px; border-radius: 8px; border: 1px solid #d7dee8;
  background: #f8fafc; color: #52606f; font-size: 12px; cursor: pointer;
}
.seg button.on { background: #4F46E5; border-color: #4F46E5; color: #fff; }
#cRange { width: 100%; margin: 2px 0 10px; accent-color: #4F46E5; }

/* 尺寸信息（顶部，避免与工具栏/面板重叠） */
#dims {
  position: absolute; z-index: 15; left: 14px;
  top: calc(50px + env(safe-area-inset-top));
  font-size: 11px; color: #52606f; line-height: 1.5;
  font-variant-numeric: tabular-nums; pointer-events: none;
}
#dims b { color: #0f172a; font-weight: 650; }

/* 提示条 */
#hint {
  position: absolute; z-index: 25; left: 50%; transform: translateX(-50%);
  top: calc(88px + env(safe-area-inset-top));
  padding: 8px 14px; border-radius: 20px;
  background: rgba(79,70,229,.94); color: #fff; font-size: 12.5px;
  white-space: nowrap; opacity: 0; transition: opacity .2s; pointer-events: none;
  box-shadow: 0 6px 18px rgba(79,70,229,.28);
}
#hint.show { opacity: 1; }

/* 测量标签 */
#labels { position: absolute; inset: 0; z-index: 12; pointer-events: none; overflow: hidden; }
.mlbl {
  position: absolute; transform: translate(-50%, -50%);
  padding: 2px 7px; border-radius: 6px;
  background: rgba(79,70,229,.94); color: #fff;
  font-size: 11px; font-weight: 600; white-space: nowrap;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 10px rgba(15,23,42,.22);
}

@media (max-width: 520px) {
  #bar { gap: 0; padding: 5px; }
  #bar button { width: 43px; font-size: 9px; padding: 7px 0 6px; }
  #bar button svg { width: 17px; height: 17px; }
  .panel { width: 196px; right: 10px; }
  #dims { font-size: 10px; }
  .qBox { border-radius: 14px; }
  .qImgWrap { padding: 8px; }
}
@media (max-height: 460px) and (orientation: landscape) {
  #bar { bottom: calc(8px + env(safe-area-inset-bottom)); }
  .panel { bottom: calc(78px + env(safe-area-inset-bottom)); }
}


/* 材料 / 重量 */
.pSel {
  flex: 1; min-width: 0; height: 30px; padding: 0 6px;
  border-radius: 8px; border: 1px solid #d7dee8; background: #f8fafc;
  color: #475569; font-size: 11.5px; font-family: inherit; outline: none;
}
.pSel:focus { border-color: #4F46E5; }
.pWt { font-size: 13px; font-weight: 700; color: #0f172a; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pWt em { font-style: normal; font-size: 10.5px; font-weight: 500; color: #7c8798; margin-left: 2px; }

/* 零件信息条（左上，尺寸下方） */
#infoBar {
  position: absolute; z-index: 16; left: 14px;
  top: calc(104px + env(safe-area-inset-top));
  max-width: 62vw; padding: 5px 10px; border-radius: 10px;
  background: rgba(255,255,255,.94); border: 1px solid rgba(15,23,42,.08);
  box-shadow: 0 4px 14px rgba(15,23,42,.08);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  font-size: 11px; color: #475569; line-height: 1.5;
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
#infoBar b { color: #0f172a; font-weight: 650; }
#infoBar i { font-style: normal; color: #cbd5e1; margin: 0 4px; }
#infoBar::after { content: " ›"; color: #94a3b8; }

/* 拔模图例 */
.dLegend {
  display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 2px 0 10px;
  font-size: 10.5px; color: #52606f;
}
.dLegend span { display: inline-flex; align-items: center; gap: 4px; }
.lg { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.lg-ok { background: #33b864; }
.lg-warn { background: #f5b301; }
.lg-bad { background: #e03a3a; }

@media (max-width: 520px) {
  #infoBar { font-size: 10px; max-width: 68vw; }
  #infoBar { top: calc(96px + env(safe-area-inset-top)); }
}
@media (max-width: 380px) {
  #bar button { width: 42px; font-size: 9px; }
  #bar button svg { width: 17px; height: 17px; }
}

/* 信息卡字段行 */
#infoRows { border-top: none; padding-top: 0; margin-top: 0; }
.iRow { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 5px; }
.iRow:last-child { margin-bottom: 0; }
.iK { flex: 0 0 52px; color: #94a3b8; font-size: 10.5px; line-height: 1.6; }
.iV { flex: 1; min-width: 0; color: #0f172a; font-size: 11.5px; font-weight: 600; line-height: 1.6; word-break: break-word; }

/* 零件信息面板：顶部横向，避免与右侧工具面板重叠 */
#infoFull {
  left: 14px; right: 14px; width: auto;
  top: calc(150px + env(safe-area-inset-top));
  bottom: auto;
}
@media (min-width: 640px) {
  #infoFull { width: 330px; right: auto; }
}

/* ---------------- 报价图浮层 ---------------- */
#qOv {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10,16,28,.62);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; box-sizing: border-box;
}
#qOv.hide { display: none; }
.qBox {
  width: min(760px, 100%); max-height: calc(100vh - 32px);
  display: flex; flex-direction: column;
  background: #fff; border-radius: 18px; overflow: hidden;
  box-shadow: 0 20px 60px rgba(8,14,26,.35);
}
.qTop {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid #eef1f6;
  font-size: 14px; color: #16202e;
}
.qTop button {
  width: 30px; height: 30px; border: none; border-radius: 9px;
  background: #f2f5fa; color: #5b6779; font-size: 16px; cursor: pointer;
}
.qImgWrap { flex: 1; min-height: 0; overflow: auto; padding: 12px; background: #f7f9fc; }
.qImgWrap img { display: block; width: 100%; height: auto; border-radius: 8px; }
.qTip { padding: 10px 16px 0; font-size: 11.5px; color: #8a94a6; line-height: 1.6; }
.qActs { display: flex; gap: 8px; padding: 12px 16px 14px; }
.qActs .pBtn { height: 38px; font-size: 13px; }
#qSave { background: #4F46E5; border-color: #4F46E5; color: #fff; }
#qSave:active { background: #4338CA; }
.pBtn.ghost { background: #fff; }
.qSum {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 10px 16px 0;
}
.qSum span {
  padding: 3px 9px; border-radius: 7px;
  background: #f1f4fa; color: #3f4c5f;
  font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap;
}
#qImg { cursor: zoom-in; }

/* ===== 装配树 / 更多菜单 ===== */
/* 工具栏：手机隐藏被收纳的按钮（「更多」两端都显示，里面还有来源与帮助） */
#bar button.off { opacity: .42; }

/* ---------------- 装配树面板 ---------------- */
#pTray {
  position: absolute; z-index: 22; left: 14px;
  top: calc(150px + env(safe-area-inset-top));
  width: 238px; max-height: 58vh;
  display: flex; flex-direction: column;
  background: rgba(255,255,255,.97);
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 14px;
  box-shadow: 0 10px 32px rgba(15,23,42,.14);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  overflow: hidden;
}
.ptHead {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 10px 8px 12px; border-bottom: 1px solid #eef2f8;
  font-size: 12.5px; color: #0f172a;
}
.ptHead b { font-weight: 650; }
.ptHead b span { color: #94a3b8; font-weight: 500; font-size: 11px; }
.ptActs { display: flex; gap: 4px; }
.ptActs button {
  height: 24px; padding: 0 8px; border-radius: 7px;
  border: 1px solid #e2e8f0; background: #fff; color: #475569;
  font-size: 11px; cursor: pointer; font-family: inherit;
}
.ptActs button:hover { background: #f7f9fc; }
.ptSearch { padding: 7px 10px 3px; }
.ptSearch input {
  width: 100%; height: 28px; padding: 0 8px;
  border: 1px solid #e2e8f0; border-radius: 8px;
  font-size: 11.5px; font-family: inherit; outline: none;
  box-sizing: border-box;
}
.ptSearch input:focus { border-color: #4F46E5; }
#pTree { flex: 1; min-height: 0; overflow: auto; padding: 4px 0 6px; -webkit-overflow-scrolling: touch; }
.pRowItem {
  display: flex; align-items: center; gap: 5px; height: 28px;
  padding-right: 8px; cursor: pointer;
  font-size: 12px; color: #334155;
}
.pRowItem:hover { background: rgba(79,70,229,.07); }
.pRowItem.grp { color: #0f172a; font-weight: 600; }
.pTw { flex: 0 0 12px; width: 12px; text-align: center; color: #94a3b8; font-size: 10px; }
.pEye {
  flex: 0 0 18px; width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 5px; color: #64748b;
}
.pEye:hover { background: rgba(79,70,229,.12); color: #4F46E5; }
.pEye svg { width: 14px; height: 14px; }
.pEye.off { color: #cbd5e1; }
.pName { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pCnt { flex: 0 0 auto; font-size: 10px; color: #94a3b8; font-variant-numeric: tabular-nums; }
.pEmpty { padding: 16px 12px; color: #94a3b8; font-size: 12px; text-align: center; }
.ptTip { padding: 7px 12px 9px; font-size: 10.5px; color: #94a3b8; border-top: 1px solid #eef2f8; }

/* ---------------- 更多菜单 ---------------- */
#moreMenu {
  position: absolute; inset: 0; z-index: 45;
  background: rgba(10,16,28,.34);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0 12px calc(84px + env(safe-area-inset-bottom));
  box-sizing: border-box;
}
.mmBox {
  width: min(330px, 94vw);
  background: #fff; border-radius: 16px;
  padding: 10px 12px 12px;
  box-shadow: 0 16px 44px rgba(15,23,42,.28);
}
.mmHead {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: #0f172a; margin-bottom: 8px;
}
.mmHead b { font-weight: 650; }
.mmHead button {
  width: 26px; height: 26px; border: none; border-radius: 8px;
  background: #f1f5f9; color: #64748b; font-size: 16px; line-height: 1;
  cursor: pointer; font-family: inherit;
}
#mmItems { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.mmItem {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 0 8px; border: none; border-radius: 12px;
  background: #f6f8fc; color: #3f4c5f;
  font-size: 11px; font-family: inherit; cursor: pointer;
}
.mmItem svg { width: 20px; height: 20px; }
.mmItem:active { background: #eceffa; }
.mmItem.on { background: #4F46E5; color: #fff; }
/* 「使用帮助」独占一行 */
.mmWide {
  width: 100%; margin-top: 6px; padding: 9px 0 8px;
  flex-direction: row; justify-content: center; gap: 7px;
  background: #eef2ff; color: #4338CA; font-size: 12px; font-weight: 650;
}
.mmWide svg { width: 17px; height: 17px; }
.mmWide:active { background: #e3e8ff; }

@media (max-width: 520px) {
  #bar button.m-collapse { display: none !important; }
  #bar button.d-only { display: flex !important; }
  #pTray {
    left: 10px; right: 10px; width: auto;
    top: auto; bottom: calc(84px + env(safe-area-inset-bottom));
    max-height: 36vh;
  }
}
@media (max-height: 460px) and (orientation: landscape) {
  #pTray { top: calc(96px + env(safe-area-inset-top)); bottom: auto; max-height: 60vh; left: 10px; width: 220px; }
}

/* ---------------- 模型点选 ---------------- */
.pRowItem.sel { background: rgba(79,70,229,.14); color: #4F46E5; font-weight: 650; }
.pRowItem.sel .pName { color: #4F46E5; }
#pPick {
  position: absolute; z-index: 26; left: 50%; transform: translateX(-50%);
  top: calc(58px + env(safe-area-inset-top));
  max-width: 72vw; padding: 6px 14px; border-radius: 20px;
  background: rgba(255,255,255,.97); color: #4F46E5;
  border: 1px solid rgba(79,70,229,.34);
  font-size: 12.5px; font-weight: 650;
  box-shadow: 0 6px 20px rgba(15,23,42,.18);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none;
}

/* ===== 爆炸图面板 ===== */
#eRange { width: 100%; margin: 2px 0 10px; accent-color: #4F46E5; }

/* ===== 视图导航立方体（右上角） ===== */
#vcWrap {
  position: absolute; z-index: 18; right: 14px;
  top: calc(54px + env(safe-area-inset-top));
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none;
}
#vCube {
  width: 98px; height: 98px; display: block;
  pointer-events: auto; cursor: pointer; touch-action: none;
  filter: drop-shadow(0 4px 12px rgba(15,23,42,.10));
}
#vcMatte {
  pointer-events: auto; cursor: pointer;
  height: 27px; min-width: 54px; padding: 0 12px; border-radius: 14px;
  border: 1px solid rgba(15,23,42,.10);
  background: rgba(255,255,255,.92); color: #52606f;
  font-size: 10.5px; font-family: inherit;
  transition: background .15s, color .15s;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
#vcMatte.on { background: #4F46E5; border-color: #4F46E5; color: #fff; }
@media (max-width: 520px) {
  #vcWrap { top: calc(48px + env(safe-area-inset-top)); right: 10px; gap: 4px; }
  #vCube { width: 78px; height: 78px; }
  #vcMatte { height: 25px; font-size: 10.5px; padding: 0 10px; min-width: 48px; border-radius: 13px; }
}
@media (max-height: 400px) and (orientation: landscape) {
  #vcWrap { display: none; }
}

/* ---------- 使用帮助弹层 ---------- */
#helpOv {
  position: absolute; inset: 0; z-index: 46;
  background: rgba(10,16,28,.34);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; box-sizing: border-box;
}
.hpBox {
  width: min(360px, 94vw); max-height: 82vh; overflow: auto;
  background: #fff; border-radius: 16px; padding: 10px 14px 14px;
  box-shadow: 0 16px 44px rgba(15,23,42,.28);
}
.hpList { display: flex; flex-direction: column; gap: 9px; margin-top: 6px; }
.hpList > div { display: flex; gap: 10px; align-items: flex-start; }
.hpList b { flex: 0 0 42px; font-size: 12.5px; font-weight: 650; color: #0f172a; }
.hpList span { flex: 1; font-size: 12.5px; line-height: 1.55; color: #4a5666; }
.hpFoot {
  margin-top: 12px; padding-top: 10px;
  border-top: 1px solid #eef2f8;
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: #8492a6;
}
.hpFoot svg { width: 14px; height: 14px; opacity: .65; flex: 0 0 14px; }
.hpFoot a { color: #4F46E5; text-decoration: none; font-weight: 700; letter-spacing: .02em; }
