* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font: 13px/1.45 "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  color: #2b2b2b; background: #eceae4;
  display: grid; grid-template-rows: 50px minmax(0, 1fr); grid-template-columns: minmax(0, 1fr);
  --c: #e8730c; --c2: #2f6fb0; --line: #dcd8ce;
}
button { font: inherit; cursor: pointer; }
.btn {
  border: 1px solid var(--line); background: #fff; color: #333; border-radius: 8px;
  padding: 6px 12px; white-space: nowrap; transition: background .15s;
}
.btn:hover { background: #fbf4ea; border-color: #e0c9a8; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.icon { padding: 4px 10px; font-size: 16px; }
.btn.sm { padding: 3px 9px; font-size: 12px; border-radius: 6px; }
.btn.primary { background: var(--c); border-color: var(--c); color: #fff; }
.btn.primary:hover { background: #d4650a; }
.btn.danger { color: #c62828; }
.btn.danger:hover { background: #fdecea; border-color: #f2b8b5; }

#top {
  display: flex; align-items: center; gap: 12px; padding: 0 12px;
  background: #fff; border-bottom: 1px solid var(--line); min-width: 0;
}
.brand { font-size: 16px; white-space: nowrap; }
.brand b { color: var(--c); }
.proj { display: flex; gap: 6px; min-width: 0; }
#projSel { max-width: 260px; min-width: 120px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; }
.grp { display: flex; gap: 6px; }
.grp.right { margin-left: auto; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 6px 14px; color: #555; white-space: nowrap; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--c); color: #fff; }
.seg.sm button { padding: 3px 9px; font-size: 12px; }

#main { display: flex; min-height: 0; min-width: 0; }
#tools {
  width: 78px; flex: none; background: #fff; border-right: 1px solid var(--line);
  overflow-y: auto; padding: 6px 5px; display: flex; flex-direction: column; gap: 3px;
}
#tools button {
  border: 1px solid transparent; background: transparent; border-radius: 9px; padding: 5px 2px;
  display: flex; flex-direction: column; align-items: center; gap: 1px; color: #444; font-size: 11.5px;
}
#tools button i { font-style: normal; font-size: 19px; line-height: 1.2; }
#tools button:hover { background: #f6f1e8; }
#tools button.on { background: #fff1e0; border-color: #f3c58f; color: #b4560a; font-weight: bold; }

#views { flex: 1; display: flex; min-width: 0; gap: 4px; padding: 4px; }
.pane { position: relative; flex: 1; min-width: 0; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #fff; }
body[data-view="plan"] #view3dWrap { display: none; }
body[data-view="3d"] #planWrap { display: none; }
#plan { position: absolute; left: 0; top: 0; display: block; touch-action: none; }
#view3dWrap canvas { position: absolute; left: 0; top: 0; display: block; touch-action: none; }
.paneTitle {
  position: absolute; left: 10px; top: 8px; background: rgba(255,255,255,.88); padding: 2px 9px;
  border-radius: 6px; font-weight: bold; color: #555; pointer-events: none; font-size: 12px; z-index: 2;
}
.paneTitle .unit { font-weight: normal; color: #999; margin-left: 6px; }
.paneBtns { position: absolute; right: 8px; top: 8px; display: flex; gap: 4px; }
#statusBar {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 10px 3px 120px; font-size: 12px; color: #666;
  background: linear-gradient(transparent, rgba(255,255,255,.9) 40%); pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.camBar {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 10px; z-index: 3;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center;
  background: rgba(255,255,255,.9); padding: 5px 8px; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,.12);
  max-width: calc(100% - 20px);
}
.chk { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: #555; white-space: nowrap; }
.labels3d { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lb3 {
  position: absolute; left: 0; top: 0; white-space: nowrap; font-size: 11px; padding: 1px 6px; border-radius: 5px;
  background: rgba(255,255,255,.85); color: #333; box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.lb3.sl { background: #fff3e6; color: #b03024; font-weight: bold; }
.lb3.pl { background: #f4efe5; color: #4a4339; }
.lb3.rl { background: #eef3f7; }
.lb3.dm { background: #1565c0; color: #fff; font-weight: bold; }
.lb3.dl { background: #f6ede4; color: #7b5534; }
.lb3.wl { background: rgba(255,255,255,.6); color: #777; font-size: 10px; }
.lb3.pp { background: #e7f0fb; color: #3f7cc4; }

#side {
  width: 310px; flex: none; background: #fff; border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; background: #faf9f6; padding: 9px; color: #666; }
.tabs button.on { background: #fff; color: var(--c); font-weight: bold; box-shadow: inset 0 -2px var(--c); }
.tabPane { flex: 1; overflow-y: auto; padding: 10px 12px 30px; }
.phead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.phead .ti { font-size: 15px; font-weight: bold; }
.phead .acts { display: flex; gap: 4px; }
.row { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.row .lab { flex: 0 0 112px; color: #555; font-size: 12.5px; }
.row .lab[title] { text-decoration: underline dotted #bbb; text-underline-offset: 3px; cursor: help; }
.row input[type=number], .row input[type=text], .row select {
  flex: 1; min-width: 0; padding: 5px 7px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: #fff;
}
.row input:focus, .row select:focus { outline: 2px solid #f6c48d; border-color: #e8a45c; }
.row .u { color: #999; font-size: 12px; width: 22px; }
.row .ro { flex: 1; color: #2f6fb0; font-weight: bold; }
.row.chkrow { cursor: pointer; }
.row.chkrow .lab { flex: 1; }
.row.chkrow input { width: 16px; height: 16px; margin: 0 2px 0 0; }
.row.btns { gap: 6px; flex-wrap: wrap; }
.selwrap { flex: 1; display: flex; gap: 4px; align-items: center; min-width: 0; }
.selwrap select { flex: 1; min-width: 0; padding: 5px 7px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.selwrap input[type=color], .colorMini { width: 34px; height: 28px; padding: 1px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.sec { margin: 12px 0 4px; padding-top: 8px; border-top: 1px dashed var(--line); font-weight: bold; color: #8a5a2b; font-size: 12.5px; }
.hint { color: #888; font-size: 12px; padding: 6px 0; }
.summary { margin-top: 12px; padding: 8px 10px; background: #f3f8fd; border-radius: 8px; font-size: 12.5px; color: #234; }
.checks { margin-top: 8px; }
.ck { font-size: 12px; padding: 4px 8px; margin: 3px 0; border-radius: 6px; background: #f6f6f3; }
.ck.warn { background: #fff4e5; color: #8a4b00; }
.ck.ok { background: #edf7ed; color: #2e6b30; }
.ck.note { background: none; color: #aaa; font-size: 11px; }
.ck.li { cursor: pointer; }
.gates .gate { border: 1px solid #f0dcc4; background: #fffaf3; border-radius: 8px; padding: 6px 8px; margin: 6px 0; }
.gates .gtitle { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.gates .row .lab { flex-basis: 90px; }
.tplbtn { display: block; width: 100%; text-align: left; margin: 4px 0; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stats div { background: #f7f4ee; border-radius: 8px; padding: 6px 8px; font-size: 12px; }
.stats b { color: var(--c); font-size: 15px; }
#listPane .li { padding: 6px 8px; border-radius: 7px; cursor: pointer; margin: 2px 0; }
#listPane .li:hover { background: #f8f3ea; }
#listPane .li.on { background: #fff1e0; }
#listPane .li b { display: block; font-size: 12.5px; }
#listPane .li span { color: #666; font-size: 12px; }

.menu {
  position: fixed; z-index: 50; background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.16); padding: 5px; min-width: 220px; max-width: calc(100vw - 12px);
}
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 7px; }
.menu button:hover { background: #fbf2e6; }
.menu button.danger { color: #c62828; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
#toast {
  position: fixed; left: 50%; top: 60px; transform: translate(-50%, -20px); opacity: 0; z-index: 60;
  background: #333; color: #fff; padding: 8px 16px; border-radius: 9px; transition: .25s; pointer-events: none; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 70; padding: 16px; }
.modal[hidden] { display: none; }
.modal .card { background: #fff; border-radius: 14px; padding: 18px 22px; max-width: 620px; max-height: 90vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal h2 { margin: 0 0 8px; color: var(--c); }
.modal ol { padding-left: 20px; margin: 0 0 10px; }
.modal li { margin: 5px 0; }
.modal .keys { color: #777; font-size: 12px; background: #f6f4ef; padding: 6px 10px; border-radius: 8px; }
#sheetBtn { display: none; }

@media (max-width: 1100px) {
  #side { width: 270px; }
  .row .lab { flex-basis: 96px; }
}
@media (max-width: 820px) {
  body { grid-template-rows: auto minmax(0, 1fr); }
  #top { flex-wrap: wrap; gap: 6px; padding: 6px 8px; }
  .brand { display: none; }
  #projSel { max-width: 150px; }
  .grp.right { margin-left: 0; }
  #main { flex-direction: column; }
  #tools {
    order: 2; width: auto; flex-direction: row; overflow-x: auto; overflow-y: hidden; border-right: 0; border-top: 1px solid var(--line);
    padding: 4px; gap: 2px; flex: none;
  }
  #tools button { flex: 0 0 62px; font-size: 10.5px; }
  #views { order: 1; flex: 1; min-height: 0; flex-direction: column; }
  #side {
    position: fixed; left: 0; right: 0; bottom: 0; width: auto; height: 62vh; z-index: 40; border-radius: 14px 14px 0 0;
    box-shadow: 0 -6px 24px rgba(0,0,0,.2); transform: translateY(105%); transition: transform .25s;
  }
  body.sheet #side { transform: none; }
  #sheetBtn { display: block; position: fixed; right: 10px; bottom: 86px; z-index: 45; box-shadow: 0 2px 10px rgba(0,0,0,.2); background: var(--c); color: #fff; border-color: var(--c); }
  body.sheet #sheetBtn { bottom: calc(62vh + 8px); }
  .camBar { bottom: 6px; gap: 4px; padding: 4px; }
  .camBar .chk { font-size: 11px; }
  #statusBar { padding-left: 100px; font-size: 11px; }
}

/* 3D 尺寸线 */
.lb3.dim3 { font-weight: bold; font-size: 11.5px; color: #fff; padding: 1px 7px; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.lb3.dw { background: #e53935; }
.lb3.dd { background: #2e7d32; }
.lb3.dh { background: #1565c0; }
.lb3.dr { background: #ef6c00; }
.dimLegend { position: absolute; right: 10px; top: 8px; z-index: 2; display: flex; gap: 8px; background: rgba(255,255,255,.88); padding: 2px 9px; border-radius: 6px; font-size: 12px; font-weight: bold; pointer-events: none; }
.dimLegend .dw { color: #e53935; } .dimLegend .dd { color: #2e7d32; } .dimLegend .dh { color: #1565c0; } .dimLegend .dr { color: #ef6c00; }
.camBar select { font: inherit; font-size: 12px; padding: 2px 4px; border: 1px solid var(--line); border-radius: 6px; }

/* 分屏时 3D 占大头 */
body[data-view="split"] #view3dWrap { flex: 1.8; }
@media (max-width: 820px) { body[data-view="split"] #view3dWrap { flex: 1.4; } }

/* 简单高度标注：只写数字，白底彩字 */
.lb3.dim3.hs { background: rgba(255,255,255,.92); font-size: 12px; padding: 0 6px; }
.lb3.dim3.hs.dh { color: #1565c0; }
.lb3.dim3.hs.dr { color: #ef6c00; }
