/* ============================================================
   图纸查看器 - 暖调精致风格
   Warm Elegance Design System
   ============================================================ */

:root {
  /* 暖调配色 */
  --bg: linear-gradient(135deg,
    rgba(228, 229, 230, 0.6) 0%,
    rgba(250, 237, 182, 0.6) 50%,
    rgba(243, 232, 203, 0.6) 100%);
  --surface: #FFFFFF;
  --surface-dark: #2D2D2D;
  --surface-embed: #1A1A1A;

  /* 文字 */
  --text: #1E293B;
  --text-muted: #9CA3AF;
  --text-dim: #64748B;
  --text-body: #6B7280;

  /* 强调色 - 黄色 */
  --accent: #FACC15;
  --accent-hover: #FDE047;
  --accent-active: #EAB308;
  --accent-glow: rgba(250, 204, 21, 0.4);

  /* 边框 */
  --border: #F3F4F6;
  --border-light: #E5E7EB;

  /* 状态色 */
  --positive: rgb(90, 173, 112);
  --danger: #EF4444;
  --orange: #F97316;
  --warning: #F59E0B;

  /* 尺寸 */
  --sidebar-width: 300px;
  --toolbar-height: 56px;
  --statusbar-height: 32px;

  /* 圆角档位 */
  --radius-card: 32px;      /* 主卡片超圆角 */
  --radius-embed: 24px;     /* 嵌入深色卡片 */
  --radius-icon-lg: 16px;   /* 大图标容器 */
  --radius-icon: 12px;      /* 图标容器 */
  --radius-pill: 9999px;    /* 全圆 */
  --radius-sm: 8px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: 'Inter', "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
}

/* 布局兜底：body 顶层若有空白/BOM 文本节点（模拟器/编辑器注入等），
   其匿名行框会占 line-height 高度，把 #app 整体下推、底部溢出视口。
   这里把 body 顶层行高清零、直接子元素各自恢复，保证 #app 从视口顶部开始。 */
body {
  line-height: 0;
}

body > * {
  line-height: 1.5;
}

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

#app {
  display: flex;
  /* 用 100%（html/body 已 height:100%）兜底：老浏览器/微信内置浏览器不支持 dvh 时，
     100vh 会高于实际可视区，导致「底部被切到屏幕外」；100% 不受此影响。
     支持 dvh 的浏览器仍用 dvh 取动态可视高度。 */
  height: 100%;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  /* 上下留白必须一致（原来上是 6px、下是 10px，视觉上底端被压低）；
     顶部收紧到 4px，整体上移 */
  padding: 4px 8px;
  gap: 8px;
}

.hidden {
  display: none !important;
}

/* ============================================================
   侧边栏 - 深色反转区
   ============================================================ */

#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--surface-dark);
  border-radius: var(--radius-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* 装饰光晕 */
#sidebar::before,
#sidebar::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

#sidebar::before {
  top: -40px;
  left: -40px;
  width: 160px;
  height: 160px;
  background: rgba(255, 255, 255, 0.05);
  filter: blur(80px);
}

#sidebar::after {
  bottom: -30px;
  right: -30px;
  width: 120px;
  height: 120px;
  background: rgba(250, 204, 21, 0.1);
  filter: blur(60px);
}

#app.sidebar-collapsed #sidebar {
  margin-left: calc(var(--sidebar-width) * -1 - 12px);
}

.sidebar-header {
  height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.01em;
}

.logo svg {
  color: var(--accent);
}

/* 返回主页按钮 */
.home-btn {
  margin-left: auto;
  padding: 6px 12px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  color: rgba(255,255,255,0.9);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s;
}
.home-btn:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.45);
  color: #fff;
}

.sidebar-section {
  padding: 20px 24px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.file-list-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 0;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: rgba(255, 255, 255, 0.4);
}

.section-count {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  min-width: 22px;
  text-align: center;
  font-weight: 500;
}

/* 按钮 */

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 44px;
  background: var(--accent);
  color: #1A1A1A;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 13px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  cursor: pointer;
  letter-spacing: 0.01em;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 20px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-primary:active {
  background: var(--accent-active);
  transform: scale(0.98);
}

.btn-label {
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
}

.btn-label:focus {
  outline: none;
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 24px;
  border: 1px solid var(--border-light);
  color: var(--text-dim);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  background: #fff;
  cursor: pointer;
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--text);
  background: #FFFEF0;
  transform: translateY(-1px);
  box-shadow: 0 2px 12px rgba(250, 204, 21, 0.15);
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-icon);
  color: var(--text-dim);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  background: transparent;
}

.btn-icon:hover {
  background: var(--border);
  color: var(--text);
}

/* 文件列表 */

.file-list {
  flex: 1;
  overflow-y: auto;
  margin: 0 -8px;
  padding: 0 8px 20px;
}

.file-list::-webkit-scrollbar {
  width: 4px;
}

.file-list::-webkit-scrollbar-track {
  background: transparent;
}

.file-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.file-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin: 4px 0;
  border-radius: var(--radius-icon-lg);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  background: transparent;
}

.file-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.file-item.active {
  background: rgba(250, 204, 21, 0.12);
  border: 1px solid rgba(250, 204, 21, 0.2);
}

.file-item.active::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 24px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.file-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-icon);
  background: rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.6);
}

.file-icon.type-3d {
  color: var(--accent);
  background: rgba(250, 204, 21, 0.15);
}

.file-icon.type-2d {
  color: var(--positive);
  background: rgba(90, 173, 112, 0.15);
}

.file-icon.type-image {
  color: var(--orange);
  background: rgba(249, 115, 22, 0.15);
}

.file-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.file-name {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.file-item.active .file-name {
  color: var(--accent);
}

.file-meta {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
}

.file-meta.error {
  color: var(--danger);
}

.file-meta.loading {
  color: var(--accent);
}

.file-close {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-icon);
  color: rgba(255, 255, 255, 0.3);
  opacity: 0;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.file-item:hover .file-close {
  opacity: 1;
}

.file-close:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

/* 空状态 */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  color: rgba(255, 255, 255, 0.3);
  text-align: center;
}

.empty-state svg {
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 12px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.4);
}

.empty-hint {
  color: rgba(255, 255, 255, 0.25) !important;
  font-size: 11px !important;
  margin-top: 4px;
}

/* 支持格式 */

.supported-formats {
  flex-shrink: 0;
  padding-bottom: 24px;
}

.format-groups {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.format-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.format-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.4);
}

.format-tags {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  line-height: 1.6;
  font-family: 'Inter', monospace;
}

/* ============================================================
   主区域
   ============================================================ */

#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  gap: 8px;
}

/* 工具栏 */

#toolbar {
  height: var(--toolbar-height);
  background: var(--surface);
  border-radius: var(--radius-card);
  display: flex;
  align-items: center;
  padding: 0 20px;
  flex-shrink: 0;
  gap: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border);
  /* 关键：toolbar 必须在 viewport 之上（DOM 上 toolbar 在前、viewport 在后，
     同为 z-index:auto 时后者盖前者，导致测量下拉菜单被 viewport 挡住看不见） */
  position: relative;
  z-index: 950;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.toolbar-center {
  flex: 1;
  display: flex;
  /* 居中；一旦内容溢出（窄屏），safe 关键字会让内容退回左对齐，
     否则居中溢出会把左侧按钮裁掉且无法滚动到（经典 flex 溢出裁切问题），
     表现为"测量/部分按钮显示不全" */
  justify-content: center;
  justify-content: safe center;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  padding: 0 2px;
}

.toolbar-center::-webkit-scrollbar {
  display: none;
}

.view-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  padding: 0;
  flex-shrink: 0;
}

/* ===== 顶栏按钮：图标 + 文字并排自适应显示，无边框无底色 ===== */
.view-controls .btn-tool,
.toolbar-center .btn-tool {
  padding: 0 10px;
  border: none;
  background: none;
  box-shadow: none;
  gap: 5px;
  flex-shrink: 0;
}
.view-controls .btn-tool:hover,
.toolbar-center .btn-tool:hover {
  background: #eceff4;
  box-shadow: none;
}
/* 图标与文字一起显示（空间不足时工具栏横向滚动，不裁切按钮） */
.view-controls .btn-tool > span,
.toolbar-center .btn-tool > span {
  display: inline;
  font-size: 12px;
}
/* 激活态保留，便于识别当前状态 */
.view-controls .btn-tool.active,
.toolbar-center .btn-tool.active {
  background: var(--text);
  color: #fff;
}
/* 窄屏自适应：字号与内边距微缩，图标 + 文字仍完整可见 */
@media (max-width: 1360px) {
  .view-controls .btn-tool > span,
  .toolbar-center .btn-tool > span { font-size: 11px; }
  .view-controls .btn-tool,
  .toolbar-center .btn-tool { padding: 0 7px; gap: 4px; }
  .divider-v { margin: 0 4px; }
}
/* 更窄的桌面窗口：再收紧一档，避免 10 个按钮（含「分享」）溢出工具栏 */
@media (max-width: 1200px) {
  .view-controls .btn-tool > span,
  .toolbar-center .btn-tool > span { font-size: 10.5px; }
  .view-controls .btn-tool,
  .toolbar-center .btn-tool { padding: 0 5px; gap: 3px; }
  .view-controls { gap: 1px; }
  .divider-v { margin: 0 3px; }
}

.btn-tool {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

.btn-tool:hover {
  color: var(--text);
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.btn-tool.active {
  background: var(--text);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.view-presets {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.view-presets .btn-tool {
  padding: 0 12px;
  font-size: 11.5px;
  min-width: 36px;
  justify-content: center;
}

.display-mode {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.display-mode .btn-tool {
  padding: 0 10px;
  min-width: 36px;
  justify-content: center;
}

.divider-v {
  width: 1px;
  height: 18px;
  background: rgba(0, 0, 0, 0.08);
  margin: 0 6px;
  flex: 0 0 auto;
}

/* 背景颜色选择器 */

.bg-picker {
  position: relative;
}

.bg-picker-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  background: var(--border);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  border: none;
  font-family: inherit;
}

.bg-picker-toggle:hover {
  color: var(--text);
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.bg-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #f5f6f8;
  border: 1px solid rgba(0, 0, 0, 0.12);
  display: inline-block;
}

.bg-picker-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
  padding: 14px;
  min-width: 200px;
  z-index: 500;
  display: none;
  border: 1px solid var(--border);
}

.bg-picker-panel.open {
  display: block;
}

.bg-picker-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

.bg-preset-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.bg-preset {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
  padding: 0;
  position: relative;
}

.bg-preset:hover {
  transform: scale(1.08);
}

.bg-preset.active {
  border-color: var(--primary);
}

.bg-preset.active::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 6px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -60%) rotate(45deg);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.bg-custom-row {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.bg-custom-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
}

.bg-custom-label input[type="color"] {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  padding: 0;
}

.bg-custom-label input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.bg-custom-label input[type="color"]::-webkit-color-swatch {
  border: 1px solid var(--border);
  border-radius: 4px;
}

.model-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 14px;
  background: var(--border);
  border-radius: var(--radius-pill);
}

.info-label {
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.05em;
}

.info-value {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.info-sep {
  color: var(--border-light);
}

/* 视口 */

#viewport {
  flex: 1;
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border);
}

#threeCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* 2D 图片查看器 */

.image-viewer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #FAFAF9;
  overflow: hidden;
}

.image-viewer img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
  border-radius: var(--radius-icon-lg);
}

.image-viewer.hidden {
  display: none;
}

/* 空视口 */

.empty-viewport {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  padding: 24px;
}

/* 空状态文字随背景亮度自适应：白/浅底 → 深色文字（清晰），暗底 → 提亮文字 */
.empty-viewport h2 {
  color: #07C160;   /* 微信绿：浅底深底都清晰 */
}
body.bg-dark .empty-viewport .empty-inner h2 {
  color: #07C160;
  text-shadow: 0 0 14px rgba(7, 193, 96, 0.5);
}
body.bg-dark .empty-viewport .empty-inner p {
  color: rgba(190, 214, 255, 0.75);
}
body.bg-dark .empty-viewport .empty-icon {
  color: #5fd0ff;
  opacity: 0.85;
  filter: drop-shadow(0 0 16px rgba(95, 208, 255, 0.6));
}
body.bg-dark .empty-viewport #dropImportBtn {
  background: rgba(20, 34, 64, 0.65);
  border-color: rgba(95, 208, 255, 0.55);
  color: #bfe3ff;
  backdrop-filter: blur(6px);
}
body.bg-light .empty-viewport #dropImportBtn {
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(30, 41, 59, 0.28);
  color: #1E293B;
  backdrop-filter: blur(6px);
}

.empty-inner {
  text-align: center;
  pointer-events: auto;
}

.empty-icon {
  position: relative;
  display: inline-block;
  color: var(--text-muted);
  margin-bottom: 24px;
  opacity: 0.5;
  animation: float 4s ease-in-out infinite;
}

/* ============ 立方体科幻动态特效（光晕呼吸 + 陀螺环 + 轨道粒子） ============ */
.cube-fx {
  position: absolute;
  inset: -40px;
  pointer-events: none;
  z-index: -1;
}
.cube-glow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 190px;
  height: 190px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle,
    rgba(95, 208, 255, 0.38) 0%,
    rgba(95, 208, 255, 0.10) 45%,
    transparent 72%);
  border-radius: 50%;
  animation: cubePulse 3.2s ease-in-out infinite;
}
.cube-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 50%;
}
.cube-ring.ring-a {
  width: 176px;
  height: 66px;
  margin: -33px 0 0 -88px;
  border: 1.5px solid rgba(95, 208, 255, 0.30);
  border-top-color: rgba(143, 232, 255, 0.85);
  animation: ringGyro 5.5s linear infinite;
}
.cube-ring.ring-b {
  width: 214px;
  height: 84px;
  margin: -42px 0 0 -107px;
  border: 1px solid rgba(129, 160, 255, 0.28);
  border-bottom-color: rgba(180, 120, 255, 0.8);
  animation: ringGyro 8.5s linear infinite reverse;
}
.cube-particle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 5px;
  margin: -2.5px 0 0 -2.5px;
  border-radius: 50%;
  background: #8fe8ff;
  box-shadow: 0 0 10px 3px rgba(95, 208, 255, 0.85);
}
.cube-particle.p1 { animation: orbitDot 4.2s linear infinite; }
.cube-particle.p2 {
  width: 4px;
  height: 4px;
  background: #c4a6ff;
  box-shadow: 0 0 8px 2px rgba(160, 120, 255, 0.8);
  animation: orbitDot 6.8s linear infinite reverse;
}
.cube-particle.p3 {
  width: 3px;
  height: 3px;
  animation: orbitDot 9.5s linear infinite;
}
@keyframes cubePulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.55; }
  50% { transform: translate(-50%, -50%) scale(1.22); opacity: 0.95; }
}
@keyframes ringGyro {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes orbitDot {
  from { transform: rotate(0deg) translateX(92px) rotate(0deg); }
  to { transform: rotate(360deg) translateX(92px) rotate(-360deg); }
}
/* 暗色背景（idle 科幻粒子）：特效更亮 */
body.bg-dark .empty-icon {
  opacity: 0.9;
}
body.bg-dark .cube-glow {
  background: radial-gradient(circle,
    rgba(120, 220, 255, 0.55) 0%,
    rgba(120, 220, 255, 0.15) 45%,
    transparent 72%);
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.empty-viewport h2 {
  font-size: 20px;
  font-weight: 600;
  color: #07C160;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.empty-viewport p {
  font-size: 13px;
  color: var(--text-body);
  margin-bottom: 24px;
  max-width: 420px;
  line-height: 1.6;
}

/* 二维码内联区：位于「选择文件」按钮下方（无图纸时显示，导入后由 app 加 .hidden 隐藏） */
.qr-inline {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 18px auto 0;
  pointer-events: auto;
  transition: opacity 0.35s ease;
}
.qr-inline img {
  width: 118px;
  height: 118px;
  object-fit: contain;
  display: block;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);   /* 白底衬二维码，暗背景下更清晰 */
  padding: 6px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(120, 140, 170, 0.25);
}
.qr-caption {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-body);
  letter-spacing: 0.02em;
  text-align: center;
}
/* 暗色背景（idle 科幻粒子）：QR 说明文字提亮 */
body.bg-dark .qr-caption {
  color: rgba(190, 214, 255, 0.85);
}

.error-diagnostic {
  margin: 16px auto 0;
  max-width: 480px;
  padding: 12px 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-card);
  text-align: left;
}

.error-diagnostic .error-title {
  font-size: 12px;
  font-weight: 600;
  color: #991b1b;
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.error-diagnostic .error-text {
  font-size: 12px;
  color: #b91c1c;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  line-height: 1.5;
  word-break: break-all;
  white-space: pre-wrap;
}

/* 加载遮罩 */

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.loading-overlay.hidden {
  display: none;
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.spinner-ring {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  box-shadow: 0 0 20px var(--accent-glow);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}

/* 拖拽提示 */

.drop-overlay {
  position: absolute;
  inset: 16px;
  background: rgba(250, 204, 21, 0.08);
  border: 2px dashed var(--accent);
  border-radius: calc(var(--radius-card) - 8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  pointer-events: none;
  backdrop-filter: blur(2px);
}

.drop-overlay.hidden {
  display: none;
}

.drop-inner {
  text-align: center;
  color: var(--text);
  background: #fff;
  padding: 32px 48px;
  border-radius: var(--radius-embed);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.drop-inner svg {
  margin-bottom: 12px;
  color: var(--accent);
}

.drop-inner p {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

/* 状态栏 */

#statusbar {
  height: var(--statusbar-height);
  background: var(--surface);
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border);
  font-weight: 500;
  gap: 12px;
  overflow: hidden;
}

.status-left,
.status-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  white-space: nowrap;
}

/* 操作提示（桌面端状态栏右侧） */
.status-hint {
  color: var(--text-muted);
  opacity: 0.85;
  font-size: 11px;
}
/* 窗口较窄时优先保证 FPS 与状态文字，提示自动隐藏 */
@media (max-width: 1180px) {
  .status-hint { display: none; }
}

.status-left {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  display: block;
}

/* ============================================================
   Toast 提示
   ============================================================ */

.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-icon-lg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  font-size: 13px;
  color: var(--text);
  min-width: 280px;
  animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  font-weight: 500;
}

.toast.success {
  border-left: 3px solid var(--positive);
}

.toast.error {
  border-left: 3px solid var(--danger);
}

.toast.warning {
  border-left: 3px solid var(--warning);
}

.toast.info {
  border-left: 3px solid var(--accent);
}

.toast.fade-out {
  animation: toastOut 0.25s ease-in forwards;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(20px) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateX(0) translateY(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

/* ============================================================
   测量 / 剖切 / 爆炸图 新控件
   ============================================================ */

.toolbar-group {
  position: relative;
  flex-shrink: 0;
}

/* 测量按钮：与其它工具栏按钮完全一致（整圆角 + 标准内边距）。
   历史上这里曾是「测量 + 下拉箭头」分体按钮，右侧被削成直角且 padding 只剩 8px，
   箭头按钮删除后遗留的覆盖样式会让按钮看起来"被切掉一半"，故已移除。 */
#measureGroup #measureBtn {
  border-radius: var(--radius-pill);
  padding: 0 10px;
}

.toolbar-dropdown {
  /* fixed 定位：脱离 toolbar 层叠上下文（absolute 会被 #viewport 内的 3D canvas 覆盖，菜单不可见/不可点） */
  position: fixed;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.08);
  padding: 6px;
  min-width: 168px;
  z-index: 9999;
  display: none;
  border: 1px solid var(--border);
  animation: dropdownIn 0.14s ease;
}
@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.toolbar-dropdown.open {
  display: block;
}

.toolbar-dropdown .dropdown-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 10px 6px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 4px;
}

.toolbar-dropdown .dropdown-sub {
  font-size: 10.5px;
  font-weight: 600;
  color: #a0a6b0;
  letter-spacing: 0.04em;
  padding: 8px 10px 2px;
}

/* ===== 测量菜单：加宽，工具行（孔洞统计/特征数量/一键测量/导出CSV）单行显示 ===== */
#measureDropdown { min-width: 320px; max-width: 360px; }
/* 智能测量保留文字（最常用，突出显示） */
#measureDropdown button.smart-measure { display: flex; width: 100%; }
/* 其余测量类型：只显示图标，横向排成网格 */
#measureDropdown button[data-measure]:not(.smart-measure):not(.dropdown-ghost):not(.dropdown-stop) {
  display: inline-flex;
  width: auto;
  padding: 7px;
  margin: 2px;
  justify-content: center;
  background: #f1f3f6;
  border-radius: 7px;
}
#measureDropdown button[data-measure]:not(.smart-measure):not(.dropdown-ghost):not(.dropdown-stop):hover {
  background: #e4e8ee;
}
/* 测量类型按钮仅隐藏文字（悬浮 title 提示）；清空/退出测量按钮保留文字 */
#measureDropdown button[data-measure]:not(.smart-measure):not(.dropdown-ghost):not(.dropdown-stop) > span,
#measureDropdown button[data-measure]:not(.smart-measure):not(.dropdown-ghost):not(.dropdown-stop) > em {
  display: none;
}
/* 颜色图例：显示文字 + 色点，直观对应识别特征 */
#measureDropdown .feature-legend .legend-item { font-size: 11.5px; gap: 4px; padding: 2px 4px; }
#measureDropdown .feature-legend .legend-item i { width: 10px; height: 10px; margin: 0; flex: 0 0 auto; }
/* 工具行：四个按钮等宽单行显示，不换行 */
.measure-tool-row { display: flex; gap: 4px; }
.measure-tool-row .panel-btn {
  flex: 1 1 0;
  white-space: nowrap;
  padding: 5px 2px;
  font-size: 11.5px;
  border-radius: 8px;
}

.toolbar-dropdown button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text-dim);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.toolbar-dropdown button svg { flex: 0 0 auto; opacity: 0.75; }
.toolbar-dropdown button span { flex: 1 1 auto; }
.toolbar-dropdown button em {
  font-style: normal;
  font-size: 10.5px;
  color: #9aa5b5;
  background: var(--border-light);
  padding: 1px 6px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.toolbar-dropdown button:hover {
  background: var(--border);
  color: var(--text);
}

.toolbar-dropdown .dropdown-sep {
  height: 1px;
  background: var(--border-light);
  margin: 4px 6px;
}

.toolbar-dropdown button.smart-measure {
  background: linear-gradient(135deg, #eef4ff, #e8f0ff);
  color: #2b6fe0;
  font-weight: 600;
  border: 1px solid #cfe0ff;
  margin-bottom: 2px;
}
.toolbar-dropdown button.smart-measure svg { opacity: 1; }
.toolbar-dropdown button.smart-measure em { background: #dce9ff; color: #3b72d6; }
.toolbar-dropdown button.smart-measure:hover { background: linear-gradient(135deg, #e2ecff, #d8e6ff); color: #1f56b8; }

.toolbar-dropdown button[data-measure="stop"] {
  color: var(--danger);
}

/* 浮动面板（测量结果 / 剖切 / 爆炸图） */
.float-panel {
  position: absolute;
  bottom: 16px;
  left: 16px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  padding: 12px 14px;
  min-width: 220px;
  max-width: 320px;
  z-index: 300;
  font-size: 12.5px;
  color: var(--text);
}

.float-panel.hidden {
  display: none;
}

.float-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 12px;
  color: var(--text);
  margin-bottom: 8px;
}

.panel-btn {
  background: var(--border);
  border: none;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
}

.panel-btn:hover {
  color: var(--text);
  background: var(--border-light);
}

.float-panel-list {
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}

.measure-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 8px;
  background: var(--border);
  border-radius: 8px;
  font-size: 12px;
}

.measure-item .m-tag {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-active);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.measure-item .m-val {
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  flex: 1;
  min-width: 0;
}

/* 单条测量删除按钮 */
.measure-item .m-del {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.measure-item .m-del:hover {
  background: var(--danger-soft, rgba(220, 53, 69, 0.12));
  color: var(--danger, #dc3545);
}

/* 测量菜单：工具较多，限制高度可滚动 */
.toolbar-dropdown {
  max-height: min(74vh, 620px);
  overflow-y: auto;
}

/* 单位切换行 */
.unit-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
}
.unit-row .unit-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-right: 2px;
  flex: 0 0 auto;
}
.unit-row .unit-btn {
  flex: 1 1 auto;
  padding: 4px 6px;
  font-size: 11px;
  text-align: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.unit-row .unit-btn.active {
  background: var(--accent-active);
  border-color: var(--accent-active);
  color: #fff;
}

/* 清空全部测量 */
.toolbar-dropdown button.dropdown-ghost {
  color: var(--text-muted);
  justify-content: flex-start;
}

.float-panel-hint {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  min-height: 14px;
}

.section-axis-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.section-axis {
  flex: 1;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  background: #fff;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.section-axis.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

.section-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slider-label {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.section-slider-row input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent-active);
}

.slider-val {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  min-width: 32px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   响应式 / 移动端
   ============================================================ */

/* 侧边栏遮罩（移动端抽屉，z-index 与侧边栏同层，盖住工具栏） */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 23, 0.45);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.sidebar-backdrop.show {
  display: block;
  opacity: 1;
}

/* 移动端浮动导入按钮（FAB） */
.mobile-fab {
  display: none;
  position: fixed;
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #1A1A1A;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(250, 204, 21, 0.45), 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 60;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mobile-fab:active {
  transform: scale(0.94);
}
.mobile-fab svg {
  width: 24px;
  height: 24px;
}

/* 移动端底部操作栏 */
.mobile-bar {
  display: none;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 8px 10px;
  overflow-x: auto;
  scrollbar-width: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}
.mobile-bar::-webkit-scrollbar {
  display: none;
}

.mbtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 52px;
  height: 48px;
  padding: 0 10px;
  border-radius: 12px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 500;
  background: transparent;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  /* 取消 iOS 双击缩放判定/点击延迟：触摸时立即触发，微信内置浏览器（WKWebView）同样生效 */
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.mbtn svg {
  width: 18px;
  height: 18px;
}
.mbtn.active {
  background: var(--text);
  color: #fff;
}
.mbtn:active {
  background: rgba(0, 0, 0, 0.06);
}
.mbtn.active:active {
  background: var(--text);
}

.mbtn-divider {
  width: 1px;
  height: 28px;
  background: var(--border-light);
  flex-shrink: 0;
  margin: 0 2px;
}

@media (max-width: 900px) {
  #app {
    /* 上下留白一致（安全区不再重复计入：只由底部操作栏的 margin 承担一次），整体上移 */
    padding: 4px 6px;
    gap: 6px;
    height: 100dvh;
  }

  /* 侧边栏变为抽屉：默认收起，打开时覆盖在内容之上（含工具栏，z-index 须高于 toolbar 950） */
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100dvh;
    width: min(calc(100vw / 3), 300px);
    min-width: 0;
    z-index: 1000;
    margin-left: 0;
    border-radius: 0 var(--radius-embed) var(--radius-embed) 0;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    padding-top: env(safe-area-inset-top, 0px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  }
  #app.sidebar-collapsed #sidebar {
    transform: translateX(-100%);
    margin-left: 0;
  }
  #app:not(.sidebar-collapsed) #sidebar {
    transform: translateX(0);
  }

  /* 顶部工具栏：隐藏密集的视图控件（已迁移到底部栏），仅保留开关 + 文件名 + 背景 */
  .toolbar-center {
    display: none;
  }

  .model-info {
    display: none;
  }

  /* 移动端隐藏状态栏，节省纵向空间（加载/就绪信息由 Toast 与加载遮罩承载） */
  #statusbar {
    display: none;
  }

  .current-file-name {
    max-width: 38vw;
  }

  /* 侧边栏开关按钮加大触控区（移动端） */
  #toolbar .btn-icon {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }

  /* 移动端侧边栏较窄：隐藏站点标题，压缩文字避免错乱 */
  .sidebar-header .logo-text {
    display: none;
  }
  .sidebar-header {
    padding: 10px 10px;
    gap: 8px;
  }
  .sidebar-header .home-btn {
    font-size: 12px;
    padding: 6px 10px;
    white-space: nowrap;
  }
  .sidebar-section {
    padding: 10px;
  }
  .supported-formats .format-tags {
    font-size: 11px;
    line-height: 1.6;
    word-break: break-word;
  }
  .supported-formats .format-group {
    flex-wrap: wrap;
  }
  .file-item .file-name {
    font-size: 12px;
    word-break: break-all;
    line-height: 1.35;
  }

  /* 移动端：扫码传图面向电脑端，手机端隐藏；支持格式说明在预览区已有，隐藏精简侧边栏 */
  #phoneUploadBtn {
    display: none;
  }
  .supported-formats {
    display: none;
  }
  /* 文件清单简化：去掉大小/状态元信息，只留图标+文件名 */
  .file-item {
    padding: 8px 10px;
  }
  .file-item .file-meta {
    display: none;
  }
  .file-list-section .section-header {
    margin-bottom: 4px;
  }

  /* 背景选择器面板在小屏居中，避免溢出右侧 */
  .bg-picker-panel {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(100vw - 24px);
  }

  /* FAB 与底部栏在小屏显示 */
  .mobile-fab {
    display: flex;
  }
  .mobile-bar {
    display: flex;
    /* 底部安全区只在这里计一次（#app 底 padding 已去掉安全区），上移一点并留出屏幕边界距离 */
    margin-bottom: calc(3px + env(safe-area-inset-bottom, 0px));
    /* 居中排布：按钮数量已精简（复位/显示/测量/剖切/爆炸/导出/分享），整体可完整显示 */
    justify-content: center;
    scrollbar-width: none;
  }
  .mobile-bar::-webkit-scrollbar { display: none; }

  /* 列表项去除悬停依赖：移动端始终显示删除按钮，并加大点按区域 */
  .file-close {
    opacity: 1;
  }
  .file-item {
    padding: 12px;
  }

  /* 测量下拉在移动端全宽可用，避免被视口边缘截断 */
  .toolbar-dropdown {
    max-width: calc(100vw - 16px);
    min-width: 168px;
  }
}

@media (max-width: 640px) {
  #app {
    /* 手机端上下留白一致，整体上移（安全区由底栏 margin 承担） */
    padding: 3px 5px;
    gap: 5px;
  }

  #toolbar {
    padding: 0 12px;
    border-radius: var(--radius-embed);
    height: 50px;
  }

  #viewport {
    border-radius: var(--radius-embed);
  }

  .current-file-name {
    max-width: 30vw;
    font-size: 12px;
  }

  .empty-viewport h2 {
    font-size: 17px;
  }

  .empty-viewport p {
    font-size: 12px;
    max-width: 300px;
  }

  .mobile-bar {
    /* 底栏紧凑化：确保 7 个按钮在手机上一行完整显示，不再被裁切 */
    padding: 6px 8px;
    gap: 3px;
    border-radius: 16px;
  }

  .mbtn {
    min-width: 42px;
    height: 44px;
    padding: 0 4px;
    gap: 2px;
    font-size: 10.5px;
  }
  .mbtn svg {
    width: 17px;
    height: 17px;
  }
  .mbtn-divider {
    height: 26px;
    margin: 0 1px;
  }
}

@media (max-width: 380px) {
  .mbtn {
    min-width: 44px;
    padding: 0 6px;
  }
  .current-file-name {
    max-width: 24vw;
  }
}


/* 测量：特征捕捉 + 标注字号 */
/* ============ 分享 / 导出菜单 ============ */
/* 分享菜单底部的说明文字 */
.toolbar-dropdown .share-hint {
  font-size: 11px;
  line-height: 1.55;
  color: var(--text-muted, #98a1af);
  padding: 8px 10px 4px;
  border-top: 1px solid var(--border-light);
  margin-top: 4px;
}
/* 显示设置菜单里的 开/关/当前 标记 */
.toolbar-dropdown button .disp-state {
  background: transparent;
  color: #7b8494;
  font-size: 10.5px;
  padding: 0 2px;
}
.toolbar-dropdown button .disp-state:empty { display: none; }

/* 只读分享横幅（打开 ?share=xxx 时显示） */
.share-banner {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%) translateY(-140%);
  z-index: 100001;
  display: none;
  align-items: center;
  gap: 8px;
  max-width: min(92vw, 620px);
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(232, 240, 255, 0.97);
  border: 1px solid #cfe0ff;
  color: #2b5fbb;
  font-size: 12.5px;
  line-height: 1.5;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1);
}
.share-banner.show {
  display: flex;
  transform: translateX(-50%) translateY(0);
}
.share-banner .sb-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3b72d6;
}
.share-banner.sb-error {
  background: rgba(253, 236, 236, 0.97);
  border-color: #f5c2c2;
  color: #b02a2a;
}
.share-banner.sb-error .sb-dot { background: #d9534f; }
.share-banner .sb-close {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  opacity: 0.7;
}
.share-banner .sb-close:hover { opacity: 1; }

/* ============ 三视图出图 ============ */
#drawingPanel { max-width: 480px; }
#drawingPanel .drawing-actions .panel-btn { font-size: 11.5px; }
#layerPanel, #bomPanel { max-width: 360px; }

/* ============ 视图工具条（AutoCAD ViewCube 风格，全局透明、无外框边框） ============ */
.view-cube {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0;
  /* 全局透明：无底色、无模糊、无边框、无阴影 */
  background: transparent;
  border: none;
  border-radius: 12px;
  box-shadow: none;
  z-index: 50;
  transition: background 0.2s ease;
}
.view-cube:hover { background: transparent; }
.view-cube .vc-face {
  /* 按钮 48px；前/顶/侧文字放大三倍（SVG 内 font-size 6 → 18） */
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 9px;
  color: #334;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.12s;
}
.view-cube .vc-face svg { width: 26px; height: 26px; display: block; }
.view-cube .vc-face svg text { font-weight: 600; }
.view-cube .vc-face:hover {
  background: rgba(255, 255, 255, 0.55);
  color: #111;
  transform: scale(1.06);
}
.view-cube .vc-face.vc-active {
  background: rgba(40, 48, 60, 0.72);
  color: #fff;
}

.drawing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px 12px;
}
.drawing-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.drawing-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.drawing-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.dwg-ph { font-size: 12px; color: var(--text-dim); }
.dwg-cap { font-size: 11px; color: var(--text-dim); }
.drawing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px 10px;
}
.drawing-actions .panel-btn.primary {
  background: var(--text, #2c3338);
  color: #fff;
}
.drawing-actions .panel-btn.primary:hover {
  background: #1a1f24;
  color: #fff;
}

/* ============ 图层管理 ============ */
.layer-actions { display: flex; gap: 6px; padding: 8px 12px 4px; }
.layer-list { max-height: 240px; overflow-y: auto; padding: 4px 12px 10px; }
.layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 13px;
  cursor: pointer;
}
.layer-item input[type="checkbox"] { width: 14px; height: 14px; accent-color: #4c9aff; cursor: pointer; }
.layer-item .layer-swatch {
  width: 12px; height: 12px; border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.15); flex: 0 0 auto;
}
.layer-item .layer-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-item.selected { color: #4c9aff; font-weight: 600; }

/* ============ BOM 物料表 ============ */
.bom-actions { display: flex; gap: 6px; padding: 8px 12px 4px; }
.bom-list { max-height: 260px; overflow-y: auto; padding: 4px 12px 10px; }
.bom-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.bom-table th, .bom-table td {
  text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--border);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bom-table th { color: var(--text-dim); font-weight: 500; }
.bom-table td.num { text-align: right; }
.bom-empty { font-size: 12px; color: var(--text-dim); padding: 8px 0; }

/* ============ 设备适配 ============ */
/* 手机（窄屏）：隐藏高级功能，仅保留查看与测量 */
@media (max-width: 767px) {
  .adv-feature { display: none !important; }
}
/* 平板竖屏也可能偏窄，这里用指针+宽度组合判断由 JS 处理（见 body.device-phone） */
body.device-phone .adv-feature { display: none !important; }

/* ============ 矮窗口保护：浏览器窗口很矮时压缩固定高度区，避免底部被切 ============ */
@media (max-height: 620px) and (min-width: 901px) {
  #toolbar { height: 48px; }
  #statusbar { height: 26px; }
  .status-hint { display: none; }
  .model-info { display: none; }
}
@media (max-height: 480px) and (min-width: 901px) {
  #toolbar { height: 44px; }
  #statusbar { display: none; }
}

/* 取点序号开关 */
.opt-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.opt-switch input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: #4c9aff;
  cursor: pointer;
}

/* 特征颜色图例：说明各颜色对应的识别特征 */
.feature-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 6px 14px 8px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.feature-legend .legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}
.feature-legend .legend-item i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
  flex: 0 0 auto;
}

/* 特征识别悬停提示（跟随鼠标，显示当前吸附到的特征类型） */
.feature-tip {
  position: fixed;
  z-index: 100002;
  display: none;
  pointer-events: none;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(20, 24, 34, 0.9);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.feature-tip i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.measure-opt-row { display: flex; align-items: center; gap: 8px; padding: 6px 14px; }
.opt-label { font-size: 12px; color: #9aa4b2; white-space: nowrap; width: 52px; flex-shrink: 0; }
.snap-btns { display: flex; gap: 4px; flex: 1; }
.snap-btn {
  flex: 1; padding: 4px 2px; font-size: 12px; border: 1px solid #3a4356;
  background: transparent; color: #c8d0dc; border-radius: 6px; cursor: pointer;
}
.snap-btn.active { background: #4c9aff; border-color: #4c9aff; color: #fff; font-weight: 600; }
.measure-opt-row input[type="range"] { flex: 1; accent-color: #4c9aff; min-width: 60px; }
.opt-val { font-size: 12px; color: #c8d0dc; width: 40px; text-align: right; }
@media (max-width: 720px) {
  .opt-label { width: 46px; font-size: 11px; }
  .snap-btn { font-size: 11px; padding: 5px 2px; }
}

/* ============ 框选（测量/删除）：拖框矩形高亮 ============ */
.box-select-rect {
  position: absolute;
  border: 1.5px solid #4fc3f7;
  background: rgba(79, 195, 247, 0.12);
  box-shadow: 0 0 0 1px rgba(79, 195, 247, 0.35);
  pointer-events: none;
  z-index: 30;
  display: none;
}

/* ============ 移动端：画布长按操作菜单 ============ */
.mobile-canvas-menu {
  position: fixed;
  z-index: 100003;
  min-width: 180px;
  background: #1c2333;
  border: 1px solid #2d3546;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mobile-canvas-menu.hidden { display: none; }
.mobile-canvas-menu-head {
  font-size: 11px;
  color: #7b8496;
  padding: 4px 10px 2px;
  border-bottom: 1px solid #2d3546;
  margin-bottom: 4px;
}
.mobile-canvas-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: #e6e9f0;
  font-size: 13px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.mobile-canvas-menu button:active { background: rgba(79, 195, 247, 0.15); }

