/* ================= 3D 设计器 ================= */
html, body { height: 100%; overflow: hidden; background: #eef2f8; }
.cad-app { height: 100vh; display: flex; flex-direction: column; position: relative; }

/* 顶栏 */
.cad-top {
  height: 56px; flex: none; background: #0d1624; color: #fff; display: flex; align-items: center;
  padding: 0 16px; gap: 16px; z-index: 60; position: relative;
  box-shadow: 0 1px 0 rgba(255,255,255,.05), 0 6px 18px rgba(9,18,34,.16);
}
.cad-brand { display: flex; align-items: center; gap: 9px; flex: none; }
.cad-brand .mark {
  width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(145deg, #2d6bff, #0b3fc4);
  display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(29,92,255,.35);
}
.cad-brand .mark svg { width: 17px; height: 17px; }
.cad-brand .txt b { font-size: 13.5px; display: block; line-height: 1.2; letter-spacing: .01em; }
.cad-brand .txt span { font-size: 9.5px; color: rgba(255,255,255,.42); letter-spacing: .12em; font-family: var(--mono); }
.cad-divider { width: 1px; height: 24px; background: rgba(255,255,255,.1); flex: none; }
.cad-proj { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); border-radius: 8px; padding: 3px 8px 3px 10px; }
.cad-proj input { background: transparent; border: none; outline: none; color: #fff; font-size: 12.5px; width: 150px; font-weight: 500; }
.cad-proj i { color: rgba(255,255,255,.4); font-size: 11px; }
.cad-toolbar { display: flex; align-items: center; gap: 2px; margin-left: 6px; }
.cad-tool {
  height: 40px; min-width: 52px; padding: 0 8px; border: none; background: transparent; color: rgba(255,255,255,.68);
  border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 10.5px; transition: all .15s var(--ease); white-space: nowrap;
}
.cad-tool i { font-size: 14px; }
.cad-tool:hover { background: rgba(255,255,255,.08); color: #fff; }
.cad-tool.on { background: rgba(45,107,255,.2); color: #8db1ff; }
.cad-right { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.cad-right .cad-tool { min-width: 58px; }
.cad-more-wrap { position: relative; }
.cad-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); width: 200px; background: #fff; color: var(--ink);
  border-radius: 11px; box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 80;
}
.cad-more-wrap.open .cad-dropdown { display: block; }
.cad-dropdown button, .cad-dropdown a {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 10px; border: none;
  background: none; border-radius: 7px; font-size: 12.5px; color: var(--ink-2); text-align: left;
}
.cad-dropdown button:hover, .cad-dropdown a:hover { background: var(--bg); color: var(--primary); }
.cad-dropdown i { width: 15px; text-align: center; color: var(--muted); font-size: 12.5px; }
.cad-dropdown .divider { height: 1px; background: var(--line-2); margin: 5px 4px; }
.cad-dropdown .kbd { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--muted-2); }
.cad-ver { font-family: var(--mono); font-size: 9.5px; color: rgba(255,255,255,.32); border: 1px solid rgba(255,255,255,.12); padding: 2px 5px; border-radius: 4px; }

/* 主区域 */
.cad-main { flex: 1; position: relative; overflow: hidden; }
.cad-viewport { position: absolute; inset: 0; }
.cad-viewport canvas { display: block; width: 100%; height: 100%; outline: none; }
.cad-vignette { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 120px rgba(24,40,70,.07); }

/* 左侧工具栏 */
.cad-rail {
  position: absolute; left: 0; top: 0; bottom: 0; width: 66px; background: rgba(255,255,255,.96);
  border-right: 1px solid var(--line); z-index: 30; padding: 8px 0; display: flex; flex-direction: column;
  gap: 1px; backdrop-filter: blur(10px);
}
.rail-item {
  height: 70px; border: none; background: none; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 5px; color: var(--ink-3); font-size: 10.5px; position: relative;
  transition: all .16s var(--ease); padding: 0;
}
.rail-item svg { width: 23px; height: 23px; stroke-width: 1.5; opacity: .82; }
.rail-item:hover { background: #f5f8fd; color: var(--primary); }
.rail-item:hover svg { opacity: 1; }
.rail-item.on { color: var(--primary); background: #f2f6ff; font-weight: 600; }
.rail-item.on svg { opacity: 1; }
.rail-item.on::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
.rail-item.dim { opacity: .45; }
.rail-foot { margin-top: auto; padding-top: 6px; border-top: 1px solid var(--line-2); }

/* 左侧面板 */
.cad-panel {
  position: absolute; left: 78px; top: 14px; bottom: 14px; width: 318px; background: #fff;
  border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 36px rgba(16,30,54,.10);
  z-index: 35; display: flex; flex-direction: column; overflow: hidden;
  transition: transform .28s var(--ease), opacity .25s;
}
.cad-panel.hidden { transform: translateX(-30px); opacity: 0; pointer-events: none; }
.panel-head { padding: 15px 17px 12px; border-bottom: 1px solid var(--line-2); display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.panel-head h3 { font-size: 14.5px; letter-spacing: -.01em; }
.panel-head .sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
.panel-body { flex: 1; overflow-y: auto; padding: 14px 15px 20px; }
.panel-collapse { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--muted); display: flex; align-items: center; justify-content: center; font-size: 11px; }
.panel-collapse:hover { color: var(--primary); border-color: #c9d6ec; }
.panel-section { margin-bottom: 18px; }
.panel-label { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .04em; margin-bottom: 9px; display: flex; align-items: center; justify-content: space-between; }
.panel-label .link { font-size: 10.5px; color: var(--primary); cursor: pointer; font-weight: 500; }
.select-card {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; cursor: pointer; transition: all .16s; margin-bottom: 8px;
}
.select-card:hover { border-color: #b9c9e6; background: #fafcff; }
.select-card .thumb { width: 42px; height: 34px; border-radius: 6px; background: #f1f5fb; display: flex; align-items: center; justify-content: center; flex: none; overflow: hidden; }
.select-card .thumb svg { width: 100%; height: 100%; }
.select-card .meta { flex: 1; min-width: 0; }
.select-card .meta b { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.select-card .meta span { font-size: 10.5px; color: var(--muted); }
.select-card .arrow { color: #b6c3d6; font-size: 11px; }
.color-dot { width: 42px; height: 32px; border-radius: 6px; border: 1px solid rgba(0,0,0,.06); flex: none; }

.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tool-item {
  border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 12px 8px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 7px; font-size: 11.5px; color: var(--ink-3);
  transition: all .16s var(--ease); position: relative;
}
.tool-item svg { width: 30px; height: 26px; }
.tool-item:hover { border-color: #b9c9e6; background: #fafcff; transform: translateY(-1px); }
.tool-item.on { border-color: var(--primary); background: #f2f6ff; color: var(--primary); box-shadow: 0 0 0 2px rgba(29,92,255,.1); }
.tool-item .kbd { font-family: var(--mono); font-size: 9px; color: var(--muted-2); }

.lib-group { margin-bottom: 14px; }
.lib-group h5 { font-size: 11px; color: var(--muted); font-weight: 500; margin-bottom: 7px; }
.lib-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.lib-item {
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 8px; background: #fff; display: flex;
  align-items: center; gap: 8px; text-align: left; transition: all .14s;
}
.lib-item:hover { border-color: #b9c9e6; background: #fafcff; }
.lib-item.on { border-color: var(--primary); background: #f2f6ff; }
.lib-item .ico { width: 30px; height: 30px; border-radius: 7px; background: #f2f5fa; display: flex; align-items: center; justify-content: center; color: #5f779c; flex: none; }
.lib-item .ico svg { width: 22px; height: 22px; }
.lib-item b { display: block; font-size: 11px; line-height: 1.35; font-weight: 500; }
.lib-item span { font-size: 9.5px; color: var(--muted-2); font-family: var(--mono); }

.panel-tip { background: #f4f7fc; border: 1px solid #e6edf8; border-radius: 9px; padding: 10px 12px; font-size: 11px; color: #5f779c; line-height: 1.7; }
.panel-tip b { color: var(--primary); }
.panel-tip ol { padding-left: 14px; list-style: decimal; margin-top: 4px; }
.panel-tip li { margin: 2px 0; }
.panel-empty { text-align: center; color: var(--muted); font-size: 11.5px; padding: 26px 10px; }

.btn-generate { width: 100%; height: 38px; border-radius: 9px; border: 1px dashed #b9c9e6; background: #f8fbff; color: var(--primary); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; justify-content: center; gap: 7px; transition: all .16s; }
.btn-generate:hover { background: #eef4ff; border-color: var(--primary); }
.default-conn { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 8px; }
.default-conn b { color: var(--ink-3); font-weight: 500; }

/* 右侧竖排操作 */
.cad-rail-right { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); z-index: 40; display: flex; flex-direction: column; gap: 8px; }
.rail-action {
  width: 44px; height: 92px; border-radius: 11px; border: none; color: #fff; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; font-size: 12px; writing-mode: vertical-rl; letter-spacing: .18em;
  box-shadow: 0 10px 24px rgba(16,30,54,.2); transition: all .2s var(--ease);
}
.rail-action i { font-size: 16px; writing-mode: horizontal-tb; letter-spacing: 0; }
.rail-action:hover { transform: translateX(-2px) scale(1.02); }
.rail-save { background: linear-gradient(160deg, #2d6bff, #0b45d8); }
.rail-quote { background: linear-gradient(160deg, #f6b23f, #e08c11); color: #2a1c05; }

/* 视图立方体 */
.view-cube { position: absolute; right: 18px; top: 16px; z-index: 30; width: 100px; height: 100px; }
.cube-wrap { width: 100%; height: 100%; position: relative; perspective: 600px; }
.cube-3d { position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; transform-style: preserve-3d; transform: translate(-50%,-50%) rotateX(-24deg) rotateY(38deg); transition: transform .3s; }
.cube-face { position: absolute; inset: 0; background: rgba(255,255,255,.92); border: 1px solid #c9d6ea; display: flex; align-items: center; justify-content: center; font-size: 9px; color: #5f779c; font-family: var(--mono); cursor: pointer; }
.cube-face:hover { background: #eef4ff; color: var(--primary); border-color: var(--primary); }
.cf-front { transform: translateZ(24px); }
.cf-back { transform: rotateY(180deg) translateZ(24px); }
.cf-left { transform: rotateY(-90deg) translateZ(24px); }
.cf-right { transform: rotateY(90deg) translateZ(24px); }
.cf-top { transform: rotateX(90deg) translateZ(24px); }
.cf-bottom { transform: rotateX(-90deg) translateZ(24px); }
.cube-note { position: absolute; left: 50%; bottom: -18px; transform: translateX(-50%); font-size: 9.5px; color: var(--muted); white-space: nowrap; }

/* 缩放 */
.zoom-ctrl { position: absolute; right: 18px; bottom: 105px; z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow-sm); overflow: hidden; display: flex; flex-direction: column; }
.zoom-ctrl button { width: 34px; height: 32px; border: none; background: #fff; color: var(--ink-3); font-size: 12px; display: flex; align-items: center; justify-content: center; }
.zoom-ctrl button + button { border-top: 1px solid var(--line-2); }
.zoom-ctrl button:hover { background: #f4f7fc; color: var(--primary); }

/* 底部提示 */
.cad-hint {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 25;
  background: rgba(11,20,35,.86); color: rgba(255,255,255,.72); border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px; height: 38px; padding: 0 16px; display: flex; align-items: center; gap: 14px;
  font-size: 11px; backdrop-filter: blur(10px); white-space: nowrap;
}
.cad-hint .dot { width: 5px; height: 5px; border-radius: 50%; background: #4d8dff; box-shadow: 0 0 0 3px rgba(77,141,255,.18); }
.cad-hint b { color: #fff; font-weight: 500; }
.cad-hint .sep { width: 1px; height: 12px; background: rgba(255,255,255,.14); }
.cad-hint label { display: flex; align-items: center; gap: 5px; cursor: pointer; color: rgba(255,255,255,.55); }
.cad-hint input { accent-color: #4d8dff; }
.cad-hint .close { color: rgba(255,255,255,.4); cursor: pointer; }
.cad-hint .close:hover { color: #fff; }

/* 属性面板 */
.prop-panel {
  position: absolute; right: 14px; bottom: 105px; width: 288px; background: #fff; border: 1px solid var(--line);
  border-radius: 13px; box-shadow: 0 16px 40px rgba(16,30,54,.14); z-index: 45; display: none; overflow: hidden;
}
.prop-panel.open { display: block; animation: slideIn .2s var(--ease); }
.prop-head { padding: 12px 14px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; }
.prop-head b { font-size: 12.5px; }
.prop-head .badge { height: 20px; font-size: 10.5px; }
.prop-body { padding: 12px 14px 14px; max-height: 45vh; overflow: auto; }
.prop-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: 11.5px; }
.prop-row > span { color: var(--muted); flex: none; }
.prop-row .input, .prop-row .select { height: 31px; width: 150px; font-size: 12px; border-radius: 7px; }
.prop-foot { display: flex; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--line-2); background: #fbfcfe; }
.prop-foot .btn { flex: 1; height: 32px; font-size: 11.5px; }
.prop-empty { padding: 18px 14px; font-size: 11.5px; color: var(--muted); text-align: center; }

/* 画布浮层 */
.hover-tip {
  position: absolute; z-index: 50; pointer-events: none; background: rgba(11,20,35,.9); color: #fff;
  font-size: 10.5px; padding: 4px 8px; border-radius: 5px; display: none; white-space: nowrap; font-family: var(--mono);
}
.dim-label {
  position: absolute; z-index: 20; pointer-events: none; background: rgba(255,255,255,.94); border: 1px solid #c9d6ea;
  color: var(--ink-2); font-size: 10px; padding: 2px 6px; border-radius: 4px; font-family: var(--mono);
  transform: translate(-50%, -50%); white-space: nowrap; box-shadow: 0 2px 6px rgba(16,30,54,.08);
}
.draw-badge {
  position: absolute; left: 50%; top: 16px; transform: translateX(-50%); z-index: 30;
  background: rgba(11,20,35,.88); color: #fff; border-radius: 8px; padding: 7px 14px; font-size: 11.5px;
  display: none; align-items: center; gap: 8px; backdrop-filter: blur(8px);
}
.draw-badge.show { display: flex; }
.draw-badge i { color: #7da3ff; }

/* 计价弹窗 */
.quote-total { background: #f7f9fd; border: 1px solid var(--line); border-radius: 11px; padding: 15px 18px; margin-top: 16px; }
.quote-total .row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); padding: 4px 0; }
.quote-total .row b { color: var(--ink-2); font-family: var(--mono); }
.quote-total .row.total { border-top: 1px dashed var(--line); margin-top: 7px; padding-top: 10px; font-size: 14px; color: var(--ink); align-items: baseline; }
.quote-total .row.total b { color: var(--danger); font-size: 22px; }
.quote-groups { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.quote-group { background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; }
.quote-group span { font-size: 10.5px; color: var(--muted); display: block; }
.quote-group b { font-family: var(--mono); font-size: 14px; }
.quote-note { font-size: 11px; color: var(--muted); line-height: 1.7; margin-top: 10px; }

/* 只读 */
.readonly-badge { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 36; background: #fff4e2; color: #a56908; border: 1px solid #f4d9ac; border-radius: 999px; padding: 5px 13px; font-size: 11px; display: none; }
.readonly-badge.show { display: block; }

/* 加载 */
.cad-loading { position: absolute; inset: 0; z-index: 100; background: #f4f7fc; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; }
.cad-loading .ring { width: 56px; height: 56px; border-radius: 50%; border: 3px solid #e2e9f4; border-top-color: var(--primary); animation: spin .8s linear infinite; }
.cad-loading b { font-size: 13px; }
.cad-loading span { font-size: 11.5px; color: var(--muted); }

/* 移动端 */
@media (max-width: 860px) {
  .cad-brand .txt, .cad-ver, .cad-tool span, .cad-tool { min-width: 44px; }
  .cad-toolbar .cad-tool:nth-child(n+4) { display: none; }
  .cad-panel { width: calc(100% - 96px); max-width: 300px; }
  .cad-hint { display: none; }
  .view-cube { display: none; }
  .prop-panel { width: calc(100% - 28px); left: 14px; right: 14px; }
}
