* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0e1116; --panel: #171b22; --card: #1e242d; --line: #2b323c;
  --text: #e6e9ee; --dim: #8b95a3; --accent: #00c16e; --accent2: #16a34a;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); overflow: hidden;
}
#app { display: flex; height: 100vh; }

/* ---- side panel ---- */
#panel {
  width: 320px; flex: 0 0 320px; background: var(--panel);
  border-right: 1px solid var(--line); padding: 18px; overflow-y: auto;
}
#panel h1 { font-size: 20px; display: flex; align-items: center; gap: 8px; letter-spacing: .01em; }
#panel h1 .logo {
  width: 26px; height: 26px; border-radius: 7px; background: var(--accent);
  color: #071510; font-weight: 800; font-size: 16px; font-family: ui-monospace, monospace;
  display: inline-flex; align-items: center; justify-content: center;
}
.sub { color: var(--dim); font-size: 12px; margin: 6px 0 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; margin-bottom: 14px;
}
.step { display: block; font-size: 12px; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px; }
.fld { display: block; font-size: 12px; color: var(--dim); margin: 10px 0 4px; }
select {
  width: 100%; background: #11151b; color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 13px;
}
.drop {
  border: 1.5px dashed var(--line); border-radius: 10px; padding: 26px 12px;
  text-align: center; color: var(--dim); font-size: 13px; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.drop.hover, .drop:hover { border-color: var(--accent); color: var(--text); }
.drop.loaded { border-color: var(--accent2); color: var(--text); }
button#sliceBtn {
  width: 100%; background: var(--accent); color: #04130b; border: 0; border-radius: 8px;
  padding: 11px; font-size: 15px; font-weight: 700; cursor: pointer;
}
button#sliceBtn:disabled { background: #2a3038; color: #5b6573; cursor: not-allowed; }
.status { font-size: 12px; color: var(--dim); margin-top: 10px; white-space: pre-wrap; }
.status.err { color: #ff6b6b; }
.status.ok { color: var(--accent); }
.stats { font-size: 13px; line-height: 1.9; }
.stats b { color: var(--accent); }
.stats .row { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); }
.muted { color: var(--dim); font-weight: 400; }

/* ---- quote ---- */
.quote { font-size: 12.5px; }
.quote .cur { display: flex; justify-content: space-between; align-items: baseline;
  padding: 4px 0 8px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.quote .cur b { color: var(--accent); font-size: 18px; }
.quote table { width: 100%; border-collapse: collapse; }
.quote th { color: var(--dim); font-weight: 500; text-align: right; font-size: 11px; padding: 2px 0; }
.quote th:first-child, .quote td:first-child { text-align: left; }
.quote td { text-align: right; padding: 3px 0; color: var(--text); }
.quote tr.on td { color: var(--accent); font-weight: 700; }
.quote tr.on td:first-child::after { content: ' ◀'; }

/* 报价单 card: headline price is the most important number on the page. */
.quote-card { border-color: rgba(0, 193, 110, .45); }
.quote .grand {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-top: 10px; margin-top: 6px; border-top: 1px solid var(--line);
  font-size: 13px; color: var(--dim);
}
.quote .grand .price { color: var(--accent); font-size: 28px; font-weight: 800; letter-spacing: .01em; }
.quote .grand .price small { font-size: 13px; font-weight: 600; margin-left: 2px; }
.yuan-anchor { text-align: right; font-size: 12px; margin-top: 2px; }
.price-tag { border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-size: 11px; color: var(--dim); }
.fee-row { display: flex; justify-content: space-between; font-size: 13px; line-height: 1.9;
  border-bottom: 1px dashed var(--line); }
.fee-row span:first-child { color: var(--dim); }
.floor-price { text-align: right; font-size: 13px; margin-top: 4px; color: var(--accent); font-weight: 600; }

/* 备注折叠(默认收起,缩短侧栏) */
details.remarks { margin: 10px 0 12px; }
details.remarks summary { font-size: 12px; color: var(--dim); cursor: pointer; user-select: none; }
details.remarks[open] summary { margin-bottom: 8px; }

.order-btn { width: 100%; margin-top: 12px; background: var(--accent); color: #04130b; border: 0;
  border-radius: 8px; padding: 11px; font-size: 15px; font-weight: 700; cursor: pointer; }
.order-btn:hover { filter: brightness(1.08); }

/* ---- order modal ---- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(4, 6, 10, .7); }
.modal[hidden] { display: none; }
.dialog { width: 420px; max-width: 92vw; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.dialog h2 { font-size: 18px; margin-bottom: 14px; }
.demo-tag { font-size: 11px; background: #3a2f00; color: #ffcf3a; padding: 2px 7px; border-radius: 6px; vertical-align: middle; }
.order-body { font-size: 13px; line-height: 1.95; }
.order-body .row { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); }
.order-body .row span:first-child { color: var(--dim); }
.qty-row { display: flex; justify-content: space-between; align-items: center; margin: 14px 0; font-size: 13px; }
.qty { display: flex; align-items: center; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.qty button { width: 34px; height: 32px; background: var(--card); color: var(--text); border: 0; font-size: 18px; cursor: pointer; }
.qty span { min-width: 44px; text-align: center; font-size: 15px; }
.order-total { background: var(--card); border-radius: 8px; padding: 10px 12px; font-size: 13px; line-height: 1.9; }
.order-total .grand { display: flex; justify-content: space-between; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.order-total .grand b { color: var(--accent); font-size: 18px; }
.order-msg { margin-top: 12px; font-size: 13px; color: var(--accent); min-height: 18px; white-space: pre-wrap; }
.dialog-actions { display: flex; gap: 10px; margin-top: 16px; }
.btn-ghost { flex: 1; background: transparent; color: var(--dim); border: 1px solid var(--line); border-radius: 8px; padding: 10px; cursor: pointer; }
.btn-primary { flex: 2; background: var(--accent); color: #04130b; border: 0; border-radius: 8px; padding: 10px; font-weight: 700; cursor: pointer; }
.btn-primary:disabled { background: #2a3038; color: #5b6573; cursor: not-allowed; }

/* ---- plate-choice modal ---- */
.plate-dialog { width: 560px; }
.plate-dialog .muted { font-size: 13px; margin-bottom: 14px; }
.plate-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px;
  max-height: 56vh; overflow-y: auto; }
.plate-opt { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px;
  cursor: pointer; text-align: center; color: var(--text); font-size: 13px; transition: border-color .15s; }
.plate-opt:hover { border-color: var(--accent); }
.plate-opt img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 6px; background: #0b0e13;
  display: block; margin-bottom: 8px; }
.plate-opt .ph { width: 100%; aspect-ratio: 1; border-radius: 6px; background: #0b0e13; display: flex;
  align-items: center; justify-content: center; font-size: 30px; color: var(--dim); margin-bottom: 8px; }

/* ---- viewport ---- */
#viewport { position: relative; flex: 1; min-width: 0; }
#canvas { display: block; width: 100%; height: 100%; }
#toolbar {
  position: absolute; top: 12px; left: 12px; right: 12px; z-index: 5;
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  pointer-events: none;
}
#toolbar > * { pointer-events: auto; }
.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: transparent; color: var(--dim); border: 0; padding: 7px 14px; font-size: 13px; cursor: pointer; }
.seg button.active { background: var(--accent); color: #04130b; font-weight: 700; }
.seg button:disabled { color: #4a525e; cursor: not-allowed; }
#orientCtl { display: flex; gap: 8px; }
#orientCtl button {
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 14px; font-size: 13px; cursor: pointer;
}
#orientCtl button.active { background: var(--accent); color: #04130b; font-weight: 700; border-color: var(--accent); }
#orientCtl button:disabled { color: #4a525e; cursor: not-allowed; }
/* Restore the [hidden] attribute behavior — ID selectors beat the browser
 * default `[hidden] { display: none }` rule, so toggling el.hidden didn't
 * actually hide these controls before. */
#orientCtl[hidden], #supportChip[hidden] { display: none; }

/* Color swatches — color is visual, pick by seeing it. */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 10px; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--line); padding: 0;
}
.swatch.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(0,193,110,.35); }

.auto-hint { font-size: 12px; margin-bottom: 8px; }

/* Quantity (份数) stepper in the config card + remarks controls. */
#qtyCtl { margin-bottom: 10px; width: fit-content; }
.remark-opts { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.remark-text {
  width: 100%; box-sizing: border-box; resize: vertical; margin-bottom: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); padding: 6px 10px; font-size: 13px; font-family: inherit;
}

/* Support warning chip — appears next to the orient controls when the
 * uploaded model has overhangs. Same warm orange as the realsim shader's
 * support-zone tint, so customers connect the chip to the orange area
 * they see on the 3D preview. */
.support-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 8px;
  background: rgba(245, 130, 30, 0.16);
  border: 1px solid rgba(245, 130, 30, 0.55);
  color: #f8b482; font-size: 12px; font-weight: 600;
}
.support-chip .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #f5821e; box-shadow: 0 0 6px rgba(245, 130, 30, 0.7);
}
.chk { display: flex; align-items: center; gap: 4px; }
.auto-opts { display: flex; gap: 14px; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.auto-opts .chk[aria-disabled="true"] { opacity: 0.4; cursor: not-allowed; }
.file-list { list-style: none; margin: 8px 0 0; padding: 0; font-size: 12px; color: var(--muted); max-height: 160px; overflow-y: auto; }
.file-list li { padding: 3px 0; display: flex; align-items: center; gap: 8px; border-bottom: 1px dashed var(--line); }
.file-list li .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.file-list li .meta { color: var(--accent); flex-shrink: 0; }
.qty-mini { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; flex-shrink: 0; }
.qty-mini button { width: 22px; height: 22px; background: var(--card); color: var(--text); border: 0; font-size: 14px; line-height: 1; cursor: pointer; }
.qty-mini b { min-width: 26px; text-align: center; font-size: 12px; }
.file-list li .rm { background: none; border: 0; color: var(--dim); font-size: 15px; cursor: pointer; flex-shrink: 0; padding: 0 2px; }
.file-list li .rm:hover { color: #ff6b6b; }
/* ---- floating plate strip (left-middle, over the 3D view) ---- */
#plateStrip { position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 5; }
#plateStrip[hidden] { display: none; }
.plate-tile { width: 56px; background: rgba(22, 27, 34, .9); border: 1px solid var(--line);
  border-radius: 8px; padding: 4px; cursor: pointer; text-align: center; }
.plate-tile canvas { display: block; width: 46px; height: 46px; margin: 0 auto; border-radius: 4px; background: #0b0e13; }
.plate-tile .lbl { font-size: 10.5px; color: var(--dim); margin-top: 2px; }
.plate-tile.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.plate-tile.active .lbl { color: var(--accent); font-weight: 700; }
.plate-tile.add { color: var(--dim); font-size: 22px; line-height: 46px; padding: 4px 4px 8px; }
.plate-tile.add:hover { color: var(--accent); border-color: var(--accent); }

/* ---- selected-instance action bar (floats top-center of viewport) ---- */
#selBar { position: absolute; top: 52px; left: 50%; transform: translateX(-50%); z-index: 6;
  background: rgba(22, 27, 34, .95); border: 1px solid var(--accent); border-radius: 8px;
  padding: 6px 10px; font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
#selBar[hidden] { display: none; }
#selBar .who { color: var(--accent); font-weight: 700; margin-right: 4px; }
#selBar button { background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: 3px 9px; font-size: 12px; cursor: pointer; }
#selBar button:hover { border-color: var(--accent); }
#selBar .dismiss { border: 0; background: none; color: var(--dim); font-size: 14px; }

/* ---- 3MF object-choice modal additions ---- */
.plate-opt.checked { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.plate-opt .tick { position: absolute; top: 6px; right: 8px; color: var(--accent); font-weight: 700; visibility: hidden; }
.plate-opt { position: relative; }
.plate-opt.checked .tick { visibility: visible; }
.overlay {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(8, 10, 14, .6); color: var(--text); font-size: 14px; z-index: 10;
}
.overlay.show { display: flex; }
.overlay .obox { display: flex; flex-direction: column; align-items: center; gap: 10px;
  max-width: 70%; text-align: center; }
.overlay .obar { width: 240px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.12);
  overflow: hidden; }
.overlay .obar .fill { height: 100%; background: var(--accent); border-radius: 3px;
  transition: width .15s ease; }
