:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #e4e7ec;
  --txt: #1f2430;
  --muted: #7b8494;
  --accent: #ff6a00;
  --accent-soft: #fff2e6;
  --blue: #0a5fff;
  --red: #e4002b;
  --shadow: 0 1px 2px rgba(20, 28, 45, .04), 0 6px 18px rgba(20, 28, 45, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--txt);
  font: 14px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  display: flex;
  flex-direction: column;
}

/* ---------- 顶栏 ---------- */
.top {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  flex: 0 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .3px;
}

.brand em {
  font-style: normal;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: .6px;
}

.logo {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--accent);
  display: inline-block;
  position: relative;
}

.logo::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 2px solid #fff;
  border-radius: 2px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tag {
  font-size: 12px;
  color: var(--muted);
  background: #f1f3f6;
  padding: 4px 10px;
  border-radius: 20px;
}

/* ---------- 布局 ---------- */
.wrap {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 306px minmax(0, 1fr) 290px;
  gap: 14px;
  padding: 14px;
  overflow: hidden;
}

.side {
  overflow-y: auto;
  padding-right: 2px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.card h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  color: #333a48;
  letter-spacing: .4px;
}

/* ---------- 控件 ---------- */
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--txt);
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
}

.btn:hover { border-color: #c9cfd8; background: #fafbfc; }

.btn.ghost { background: #fff; }

.btn.primary {
  background: var(--accent-soft);
  border-color: #ffd3ae;
  color: #b34a00;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 9px 12px;
}

.btn.primary:hover { background: #ffe8d3; }

.btn.primary span {
  font-size: 11px;
  font-weight: 400;
  color: #9a6a3f;
}

.btn.sm { padding: 4px 9px; }

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.row:last-child { margin-bottom: 0; }

.lb {
  flex: 0 0 74px;
  font-size: 12.5px;
  color: #5b6473;
}

.unit { font-size: 12px; color: var(--muted); }

input[type=number], select, textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: var(--txt);
  min-width: 0;
}

input[type=number]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 106, 0, .1);
}

select { flex: 1 1 auto; }

.triple { gap: 8px; }

.fld { flex: 1 1 0; display: flex; flex-direction: column; gap: 4px; }

.fld label { font-size: 11.5px; color: var(--muted); }

.fld input { width: 100%; }

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.seg button {
  border: 0;
  background: #fff;
  padding: 6px 11px;
  font-size: 12.5px;
  cursor: pointer;
  color: #4b5462;
  border-right: 1px solid var(--line);
  font-family: inherit;
}

.seg button:last-child { border-right: 0; }

.seg button.on { background: var(--accent-soft); color: #b34a00; font-weight: 600; }

.chk {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: #4b5462;
  cursor: pointer;
}

input[type=checkbox] { accent-color: var(--accent); }

input.mini { width: 46px; padding: 3px 6px; }

.tip {
  font-size: 11.5px;
  color: var(--muted);
  margin: 10px 0 0;
  line-height: 1.6;
}

.code {
  width: 100%;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  color: #465066;
  resize: vertical;
}

/* ---------- 箱型网格 ---------- */
.boxgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  background: #fff;
  transition: .15s;
  text-align: center;
}

.box:hover { border-color: #bfc7d2; transform: translateY(-1px); }

.box.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(255, 106, 0, .08);
}

.box svg { display: block; width: 100%; height: 58px; }

.box .nm { font-size: 12px; font-weight: 600; margin-top: 4px; }

.box .cd { font-size: 10.5px; color: var(--muted); }

/* ---------- 参数 ---------- */
.params .row { margin-bottom: 9px; }

.params .lb { flex: 1 1 auto; font-size: 12.5px; }

.params input[type=number] { width: 82px; text-align: right; }

/* ---------- 舞台 ---------- */
.stage-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 10px;
}

.stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 8px 12px;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.stage-bar .left, .stage-bar .right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.zoom { font-size: 12px; color: var(--muted); min-width: 44px; text-align: center; }

.stage-holder {
  position: relative;       /* 信息块 overlay 的定位基准（固定于可视区左上，不随画布滚动） */
  flex: 1 1 auto;
  display: flex;
  min-width: 0;
  min-height: 0;
}

.stage {
  flex: 1 1 auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background-image: linear-gradient(#eceff3 1px, transparent 1px), linear-gradient(90deg, #eceff3 1px, transparent 1px);
  background-size: 40px 40px;
}

.stage.no-grid { background-image: none; }

.stage-inner { margin: auto; }

#stage { display: block; }

/* ---------- 3D 成型预览 ---------- */
.stage3d {
  flex: 1 1 auto;
  background: radial-gradient(circle at 50% 35%, #ffffff 0%, #eef1f6 70%, #e6eaf0 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

.scene {
  position: absolute;
  inset: 0 0 46px 0;
  perspective: 1500px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
}

.scene.drag { cursor: grabbing; }

/* 2D 预览：拖拽平移的光标 */
#stageWrap { cursor: grab; }
#stageWrap.panning { cursor: grabbing; }
#stageWrap:active { cursor: grabbing; }

.box3d {
  position: relative;
  transform-style: preserve-3d;
  will-change: transform;
}

.box3d .face {
  position: absolute;
  left: 50%;
  top: 50%;
  box-sizing: border-box;
  border: 1px solid rgba(90, 60, 30, .35);
  transform-style: preserve-3d;
  transition: transform .75s cubic-bezier(.34, .01, .24, 1), opacity .4s ease;
}

.box3d .flap {
  position: absolute;
  box-sizing: border-box;
  border: 1px solid rgba(90, 60, 30, .35);
  transition: transform .6s cubic-bezier(.34, .01, .24, 1);
  backface-visibility: visible;
}

/* 外观 */
.look-kraft .face, .look-kraft .flap { background-color: #cfa877; }
.look-white .face, .look-white .flap { background-color: #f6f3ec; }
.look-corr .face, .look-corr .flap { background-color: #dcb98b; }

/* 瓦楞纹路：只出现在能看到楞向的面上 */
.look-corr .face.flute::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, rgba(120, 80, 40, .18) 0 1.5px, rgba(120, 80, 40, 0) 1.5px 5px);
}

.bar3d {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .75);
  backdrop-filter: blur(4px);
}

.bar3d .muted { font-size: 12px; }

select.mini2 { padding: 3px 6px; font-size: 12px; }

.tip3d {
  position: absolute;
  right: 12px;
  top: 10px;
  font-size: 11.5px;
  color: var(--muted);
  pointer-events: none;
}

/* ---------- 画布左上角信息块（图例 + 三套尺寸，对齐 Pacdora） ---------- */
.stage-overlay {
  position: absolute;
  left: 14px;
  top: 14px;
  z-index: 5;
  pointer-events: none;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(3px);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: 0 1px 4px rgba(30, 40, 60, .06);
}

.stage-overlay .ov-legend {
  display: flex;
  gap: 14px;
  align-items: center;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
}

.stage-overlay .ov-legend .ln {
  display: inline-block;
  width: 22px;
  height: 0;
  border-top-width: 2.5px;
  vertical-align: middle;
  margin-right: 5px;
}

.stage-overlay .ov-legend i.ln { margin-bottom: 3px; }

.ov-dims div { margin-bottom: 6px; }
.ov-dims div:last-child { margin-bottom: 0; }

.ov-dims span {
  display: block;
  font-size: 11px;
  color: #8a93a3;
  line-height: 1.3;
}

.ov-dims b {
  display: block;
  font-size: 13.5px;
  font-weight: 650;
  color: #1f2430;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

.legend {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: #5b6473;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  flex-wrap: wrap;
}

.legend i.ln {
  display: inline-block;
  width: 26px;
  height: 0;
  border-top-width: 2px;
  margin-right: 6px;
  vertical-align: middle;
}

.legend .cut, .stage-overlay .ov-legend .cut { border-top: 2.5px solid var(--red); }
.legend .crease, .stage-overlay .ov-legend .crease { border-top: 2.5px dashed var(--blue); }
.legend .bleed, .stage-overlay .ov-legend .bleed { border-top: 2.5px dashed #0e9f6e; }

.legend .sep { flex: 1 1 auto; }

.muted { color: var(--muted); }

/* ---------- 摘要 ---------- */
.sum {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 10px;
}

.sumrow {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
}

.sumrow:last-child { border-bottom: 0; }

.sumrow .k { font-size: 12px; color: var(--muted); }

.sumrow .v { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

.sumrow.primary { background: var(--accent-soft); }

.sumrow.primary .v { color: #b34a00; font-size: 14.5px; }

.sumrow.primary .k { color: #a1611f; }

/* ---------- 下载 ---------- */
.dloads {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0 4px;
}

.dloads .btn { width: 100%; }

.dloads .btn span { font-size: 10.5px; color: var(--muted); }

/* ---------- quick chips ---------- */
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

.chip {
  border: 1px dashed #ccd2dc;
  background: #fafbfc;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11.5px;
  color: #5b6473;
  cursor: pointer;
  font-family: inherit;
}

.chip:hover { border-color: var(--accent); color: #b34a00; }

/* ---------- 说明浮层 ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(22, 28, 40, .45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal.on { display: flex; }

.modal-box {
  background: #fff;
  border-radius: 14px;
  max-width: 560px;
  width: 100%;
  max-height: 82vh;
  overflow: auto;
  padding: 22px 24px;
  position: relative;
}

.modal-box h2 { font-size: 15px; margin: 18px 0 8px; }

.modal-box h2:first-of-type { margin-top: 0; }

.modal-box p { font-size: 13px; color: #4b5462; line-height: 1.75; }

.modal-box ul { font-size: 13px; color: #4b5462; line-height: 1.8; padding-left: 20px; }

.modal-box .x {
  position: absolute;
  right: 14px;
  top: 12px;
  border: 0;
  background: #f2f4f7;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  color: #5b6473;
}

.tbl { width: 100%; border-collapse: collapse; margin: 6px 0; font-size: 12.5px; }

.tbl th, .tbl td { border: 1px solid var(--line); padding: 6px 9px; text-align: center; }

.tbl th { background: #fafbfc; color: #4b5462; }

@media (max-width: 1220px) {
  .wrap {
    grid-template-columns: 280px minmax(0, 1fr);
    overflow: auto;
  }

  .side.right { grid-column: 1 / -1; }

  .wrap { overflow: hidden; }
}

@media (max-width: 900px) {
  .wrap { grid-template-columns: 1fr; }

  body { height: auto; }
}
