/* ===== 全局 ===== */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  font-size: 13px; color: #333;
}
/* 嵌入模式：隐藏顶部菜单栏 */
body.embed #topbar { display: none; }
body.embed #main { top: 0; }
/* 精简菜单 (menu=min, 欧霓博目录嵌入专用): 只保留 剖切/线框/透明/视角/测量, 并隐藏模型树 */
body.menu-min #treePanel { display: none; }
body.menu-min #viewport { left: 0; }
body.menu-min .tool-btn[data-tool="select"],
body.menu-min .tool-btn[data-tool="drag"],
body.menu-min .tool-btn[data-tool="singalDrag"],
body.menu-min .tool-btn[data-tool="explode"],
body.menu-min #btnTree,
body.menu-min #btnColorPanel,
body.menu-min #btnShowAll,
body.menu-min #btnBbox,
body.menu-min #btnClear,
body.menu-min #btnSingleReset,
body.menu-min #btnAllReset,
body.menu-min #btnAxes,
body.menu-min #btnFull { display: none; }
.hidden { display: none !important; }
img { -webkit-user-drag: none; user-select: none; }

/* ===== 顶栏 ===== */
#topbar {
  position: absolute; top: 0; left: 0; right: 0; height: 50px;
  background: #fff; border-bottom: 1px solid #e3e6e8;
  display: flex; align-items: center; gap: 14px; padding: 0 14px; z-index: 50;
}
.logo { display: flex; align-items: center; gap: 8px; }
.logo-text { font-size: 16px; font-weight: 600; color: #2b9ae8; letter-spacing: 1px; }
.btn-primary {
  background: #2b9ae8; color: #fff; border: none; border-radius: 4px;
  padding: 7px 18px; font-size: 13px; cursor: pointer;
}
.btn-primary:hover { background: #2389cf; }
.btn-secondary {
  background: #fff; color: #2b9ae8; border: 1px solid #2b9ae8; border-radius: 4px;
  padding: 6px 16px; font-size: 13px; cursor: pointer;
}
.btn-secondary:hover { background: #f0f7fd; }
.file-name { color: #888; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quality-label { display: flex; align-items: center; gap: 6px; color: #666; font-size: 12px; flex: none; }
.quality-label select {
  border: 1px solid #ddd; border-radius: 4px; padding: 4px 6px; font-size: 12px;
  color: #333; background: #fff; cursor: pointer;
}
.top-right { display: flex; gap: 6px; }
.icon-btn {
  width: 32px; height: 32px; border: 1px solid #ddd; border-radius: 4px;
  background: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0;
}
.icon-btn:hover { border-color: #2b9ae8; }
.icon-btn img { width: 18px; height: 18px; }

/* ===== 主区域 ===== */
#main { position: absolute; top: 50px; left: 0; right: 0; bottom: 0; }

/* ===== 左侧模型树 ===== */
#treePanel {
  position: absolute; top: 0; left: 0; bottom: 0; width: 280px;
  background: #fff; border-right: 1px solid #e3e6e8; z-index: 40;
  display: flex; flex-direction: column;
}
.tree-header { padding: 10px 12px 8px; border-bottom: 1px solid #f0f2f3; }
.tree-title { font-weight: 600; font-size: 14px; }
.tree-search {
  margin-top: 8px; display: flex; align-items: center; gap: 6px;
  border: 1px solid #ddd; border-radius: 4px; padding: 4px 8px;
}
.tree-search img { width: 14px; height: 14px; opacity: .6; }
.tree-search input { border: none; outline: none; flex: 1; font-size: 12px; background: transparent; }
.tree-body { flex: 1; overflow: auto; padding: 4px 0 20px; }
.tree-empty { color: #aaa; text-align: center; padding: 40px 10px; font-size: 12px; }

.tree-row {
  display: flex; align-items: center; gap: 4px; height: 26px; padding: 0 6px;
  cursor: pointer; white-space: nowrap; user-select: none;
}
.tree-row:hover { background: #f0f7fd; }
.tree-row.highlight { background: #dceefb; }
.tree-expander { width: 14px; height: 14px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.tree-expander img { width: 10px; height: 10px; }
.tree-spacer { width: 14px; flex: none; }
.tree-icon { width: 16px; height: 16px; flex: none; }
.tree-check { width: 14px; height: 14px; flex: none; cursor: pointer; }
.tree-label { overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.tree-row.matched .tree-label { color: #2b9ae8; font-weight: 600; }
.tree-children { display: block; }

/* ===== 视口 ===== */
#viewport { position: absolute; top: 0; left: 280px; right: 0; bottom: 0; }
#canvasWrap { position: absolute; inset: 0; }
#canvasWrap canvas { display: block; }

/* ===== 底部工具栏 ===== */
#toolbar {
  position: absolute; left: 50%; bottom: 36px; transform: translateX(-50%);
  display: flex; flex-direction: row; gap: 2px; z-index: 45;
  background: #fff; border: 1px solid #e3e6e8; border-radius: 6px;
  padding: 4px 8px; box-shadow: 0 2px 10px rgba(0,0,0,.08);
}
.tool-btn {
  width: 72px; height: 72px; border: none; background: transparent; border-radius: 4px;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; color: #666; padding: 0;
}
.tool-btn img { width: 40px; height: 40px; }
.tool-btn span { font-size: 12px; line-height: 1; }
.tool-btn:hover { background: #f0f7fd; color: #2b9ae8; }
.tool-btn.active { background: #2b9ae8; color: #fff; }
.tool-btn.active img { filter: brightness(0) invert(1); }
.tool-sep { height: 1px; background: #eee; margin: 2px 4px; }

/* ===== 浮动面板 ===== */
.float-panel {
  position: absolute; z-index: 46; background: #fff; border: 1px solid #e3e6e8;
  border-radius: 6px; box-shadow: 0 2px 12px rgba(0,0,0,.12); padding: 10px 12px; width: 240px;
}
#explodePanel { right: 16px; top: 20px; }
#sectionPanel { right: 16px; top: 120px; }
.panel-title {
  font-weight: 600; font-size: 13px; margin-bottom: 10px;
  display: flex; justify-content: space-between; align-items: center;
}
.panel-close { width: 14px; height: 14px; cursor: pointer; opacity: .6; }
.panel-close:hover { opacity: 1; }
.panel-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.panel-row:last-child { margin-bottom: 0; }
.panel-row span { font-size: 12px; color: #666; flex: none; }
.panel-row input[type="range"] { flex: 1; accent-color: #2b9ae8; }
.panel-val { width: 44px; text-align: right; color: #2b9ae8; font-weight: 600; }
.axis-btn {
  width: 28px; height: 24px; border: 1px solid #ccc; background: #fff; border-radius: 3px;
  cursor: pointer; font-weight: 700; color: #555;
}
.axis-btn.active { background: #2b9ae8; border-color: #2b9ae8; color: #fff; }
.small-btn {
  border: 1px solid #ccc; background: #fff; border-radius: 3px; cursor: pointer;
  font-size: 11px; padding: 4px 8px; color: #555;
}
.small-btn:hover { border-color: #2b9ae8; color: #2b9ae8; }
.small-btn.on { background: #2b9ae8; border-color: #2b9ae8; color: #fff; }

/* ===== 测量面板（水平单行） ===== */
.measure-panel {
  left: 50%; bottom: 36px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 2px; padding: 6px 8px;
  width: auto; max-width: 96vw; overflow-x: auto;
}
#measureModes { display: flex; gap: 2px; flex-wrap: nowrap; }
.measure-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 72px; height: 72px; padding: 0; border: 1px solid transparent; border-radius: 4px;
  background: transparent; cursor: pointer; color: #555; flex: none;
}
.measure-btn img { width: 40px; height: 40px; }
.measure-btn span { display: none; }
.measure-btn:hover { background: #f0f7fd; }
.measure-btn.active { background: #2b9ae8; color: #fff; }
.measure-btn.active img { filter: brightness(0) invert(1); }
.measure-actions {
  display: flex; gap: 2px; margin-left: 6px; padding-left: 6px;
  border-left: 1px solid #eee; flex: none;
}
.measure-act {
  width: 72px; height: 72px; border: none; background: transparent; border-radius: 4px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; flex: none;
}
.measure-act:hover { background: #f0f7fd; }
.measure-act img { width: 40px; height: 40px; }

/* ===== 结果统计面板 ===== */
#statsPanel { right: 16px; top: 220px; width: 260px; max-height: 320px; display: flex; flex-direction: column; }
#statsPanel .panel-title { flex: none; }
#statsList { overflow: auto; flex: 1; }
.stats-empty { color: #aaa; text-align: center; padding: 16px 0; font-size: 12px; }
.stats-row {
  display: flex; align-items: center; gap: 6px; padding: 5px 2px;
  border-bottom: 1px solid #f5f6f7; font-size: 12px;
}
.stats-row:last-child { border-bottom: none; }
.stats-type { color: #2b9ae8; flex: none; font-weight: 600; }
.stats-value { flex: 1; color: #333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-del { cursor: pointer; color: #bbb; flex: none; padding: 0 4px; }
.stats-del:hover { color: #e74c3c; }

/* ===== 上色面板 ===== */
#colorPanel { right: 16px; top: 20px; width: 230px; }
#colorPicker { width: 36px; height: 28px; border: 1px solid #ddd; border-radius: 4px; padding: 1px; cursor: pointer; }
#colorPanel .small-btn { display: flex; align-items: center; gap: 4px; }
#colorPanel .small-btn img { width: 14px; height: 14px; }

/* ===== 嵌入链接面板 ===== */
#embedPanel { right: 16px; top: 20px; width: 340px; }
#embedPanel .panel-row { align-items: flex-start; flex-wrap: wrap; }
#embedPanel .panel-row > span { padding-top: 6px; }
#embedPanel input[type="text"], #embedPanel textarea {
  flex: 1; border: 1px solid #ddd; border-radius: 4px; padding: 5px 8px;
  font-size: 11px; color: #444; min-width: 200px;
}
#embedPanel textarea { resize: vertical; font-family: Consolas, monospace; }
.embed-actions { justify-content: flex-end; }
.embed-hint { font-size: 11px; color: #999; line-height: 1.6; }

/* ===== 零件右键菜单 ===== */
#ctxMenu {
  position: fixed; z-index: 500; background: #fff; border: 1px solid #e3e6e8;
  border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.15); padding: 6px 0;
  min-width: 140px;
}
.ctx-title {
  padding: 6px 14px; font-weight: 600; font-size: 12px; color: #2b9ae8;
  border-bottom: 1px solid #f0f2f3; margin-bottom: 4px;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ctx-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 14px;
  cursor: pointer; font-size: 12px; color: #444;
}
.ctx-item:hover { background: #f0f7fd; color: #2b9ae8; }
.ctx-item img { width: 18px; height: 18px; }
.ctx-sep { height: 1px; background: #f0f2f3; margin: 4px 0; }

/* ===== 状态栏 ===== */
#statusbar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 26px;
  background: rgba(255,255,255,.92); border-top: 1px solid #e3e6e8;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; font-size: 11px; color: #888; z-index: 44;
}
.status-right { color: #2b9ae8; }

/* ===== 加载遮罩（新迪同款弹跳圆点） ===== */
#loading {
  position: fixed; inset: 0; background: rgba(255,255,255,.9); z-index: 200;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
}
.waiter { display: flex; gap: 12px; }
.waiter > div {
  width: 18px; height: 18px; background-color: #2b9ae8; border-radius: 100%;
  animation: bouncedelay 1.4s infinite ease-in-out; animation-fill-mode: both;
}
.waiter .bounce1 { animation-delay: -0.75s; }
.waiter .bounce2 { animation-delay: -0.5s; }
.waiter .bounce3 { animation-delay: -0.25s; }
@keyframes bouncedelay {
  0% { transform: scale(0); }
  50% { transform: scale(1); }
  100% { transform: scale(0); }
}
#loadingText { color: #666; font-size: 14px; }

/* ===== 拖拽遮罩 ===== */
#dropOverlay {
  position: fixed; inset: 0; background: rgba(43,154,232,.08); z-index: 300;
  display: flex; align-items: center; justify-content: center;
}
.drop-box {
  border: 2px dashed #2b9ae8; border-radius: 12px; background: #fff;
  padding: 50px 80px; font-size: 18px; color: #2b9ae8; pointer-events: none;
}

/* ===== 测量标注 ===== */
.measure-label {
  background: #2b9ae8; color: #fff; font-size: 12px; font-weight: 600;
  padding: 3px 8px; border-radius: 3px; white-space: nowrap; pointer-events: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.measure-label::after {
  content: ''; position: absolute; left: 50%; top: 100%; margin-left: -4px;
  border: 4px solid transparent; border-top-color: #2b9ae8;
}

/* ===== 手机适配（≤768px） ===== */
.tree-close { display: none; }
@media (max-width: 768px) {
  .tree-close {
    display: block; position: absolute; top: 12px; right: 10px;
    border: none; background: #f2f7fc; color: #6b8498; font-size: 14px;
    border-radius: 4px; padding: 2px 8px; cursor: pointer;
  }
  .tree-close:hover { background: #2b9ae8; color: #fff; }
  #topbar { height: 44px; gap: 8px; padding: 0 8px; }
  #topbar .logo-text { display: none; }
  #topbar .file-name { display: none; }
  #topbar .btn-primary, #topbar .btn-secondary { padding: 5px 10px; font-size: 12px; }
  #main { top: 44px; }
  body.embed #main { top: 0; }

  /* 模型树抽屉：默认隐藏，点「结构树」按钮弹出 */
  #treePanel {
    position: fixed; top: 44px; left: 0; bottom: 0; width: min(280px, 85vw); z-index: 60;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: 2px 0 12px rgba(0,0,0,.15);
  }
  body.embed #treePanel { top: 0; }
  body.tree-open #treePanel { transform: translateX(0); }
  #treePanel.hidden { display: flex; }   /* 手机上抽屉由 tree-open 控制 */
  #viewport { left: 0; }

  #toolbar { left: 0; right: 0; transform: none; bottom: 8px;
    border-radius: 0; border-left: none; border-right: none; padding: 2px 4px; overflow-x: auto; }
  .tool-btn { width: 56px; height: 60px; flex: none; }
  .tool-btn img { width: 32px; height: 32px; }
  .tool-btn span { font-size: 11px; }
  .float-panel { max-width: 92vw; max-height: 70vh; overflow: auto; }
}
