:root {
  --ink: #4b3028;
  --muted: #806b60;
  --line: rgba(111, 71, 51, .2);
  --paper: #fff8ec;
  --paper-deep: #f6e3d1;
  --pink: #d9879e;
  --pink-deep: #a94f6f;
  --mint: #a9cfa9;
  --mint-deep: #598765;
  --cream: #f7e6bd;
  --wood: #bd7b51;
  --cute: "YouYuan", "幼圆", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  --pixel: "Courier New", Consolas, monospace;
}

* { box-sizing: border-box; }
html { background: #f7ead8; color-scheme: light; }
body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(250, 237, 218, .8), rgba(248, 229, 209, .86)),
    var(--pixel-storage-pattern, none),
    radial-gradient(circle, rgba(190, 112, 130, .13) 0 2px, transparent 2.5px);
  background-size: auto, 112px 112px, 31px 31px;
  font-family: var(--cute);
  font-size: 14px;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.rack-header {
  position: sticky;
  z-index: 20;
  top: 0;
  min-height: 68px;
  padding: 10px 4vw;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 249, 237, .93);
  backdrop-filter: blur(12px);
}

.rack-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.rack-brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 2px solid #78472f;
  background: #f2c98e;
  box-shadow: 3px 3px 0 rgba(91, 51, 32, .13);
}

.rack-brand-mark canvas { width: 32px; height: 32px; image-rendering: pixelated; }
.rack-brand strong, .rack-brand small { display: block; }
.rack-brand strong { font-size: 14px; font-weight: 900; letter-spacing: .08em; }
.rack-brand small { margin-top: 2px; color: var(--muted); font: 700 7px/1 var(--pixel); letter-spacing: .08em; }
.rack-header-note { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 9px; font-weight: 800; }
.rack-header-note i { width: 6px; height: 6px; background: var(--mint-deep); box-shadow: 0 0 0 4px rgba(89, 135, 101, .12); }
.back-link { justify-self: end; color: var(--ink); font-size: 10px; font-weight: 900; text-decoration: none; }

.rack-hero {
  width: min(1240px, calc(100% - 40px));
  margin: 26px auto 18px;
  padding: 34px 34px 26px;
  display: grid;
  grid-template-columns: 1fr .62fr;
  align-items: end;
  gap: 50px;
  border: 1px solid var(--line);
  border-top: 9px solid transparent;
  border-image: repeating-linear-gradient(90deg, #6d412d 0 28px, #d89a6c 28px 56px) 9;
  background:
    linear-gradient(rgba(255, 249, 237, .88), rgba(255, 242, 229, .91)),
    radial-gradient(circle, rgba(205, 117, 143, .12) 0 3px, transparent 3.5px);
  background-size: auto, 28px 28px;
  box-shadow: 5px 6px 0 rgba(102, 61, 39, .08);
}

.rack-hero p { margin: 0 0 12px; color: var(--pink-deep); font: 800 8px/1 var(--pixel); letter-spacing: .13em; }
.rack-hero h1 { margin: 0; font-size: clamp(33px, 4vw, 58px); font-weight: 900; line-height: 1.12; letter-spacing: -.04em; }
.rack-hero-copy { padding-left: 22px; border-left: 1px solid var(--line); }
.rack-hero-copy b, .rack-hero-copy span { display: block; }
.rack-hero-copy b { margin-bottom: 8px; color: var(--pink-deep); font-size: 13px; }
.rack-hero-copy span { color: var(--muted); font-size: 11px; line-height: 1.8; }

.rack-workbench {
  width: min(1460px, calc(100% - 40px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(260px, 310px) minmax(520px, 1fr) minmax(230px, 270px);
  gap: 12px;
  align-items: start;
}

.rack-controls, .rack-stage, .rack-result {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 249, 237, .95);
  box-shadow: 5px 6px 0 rgba(100, 59, 38, .08);
}

.rack-controls { padding: 18px 16px 24px; }
.control-heading { margin: 4px 0 13px; display: flex; align-items: flex-start; gap: 10px; }
.control-heading:not(:first-child) { margin-top: 24px; padding-top: 19px; border-top: 1px solid var(--line); }
.control-heading > span {
  display: grid; width: 24px; height: 24px; flex: 0 0 24px; place-items: center;
  border: 1px solid #ba7652; background: #f4cca1; font: 800 8px/1 var(--pixel);
}
.control-heading b, .control-heading small { display: block; }
.control-heading b { font-size: 14px; font-weight: 900; }
.control-heading small { margin-top: 3px; color: var(--muted); font-size: 8px; }

.rack-drop {
  min-height: 122px;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px dashed #c58e6a;
  border-radius: 7px;
  background:
    linear-gradient(rgba(255, 250, 239, .9), rgba(255, 247, 232, .9)),
    repeating-linear-gradient(45deg, #f5dfca 0 7px, #fff5e5 7px 14px);
  cursor: pointer;
}
.rack-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.rack-drop > span { display: grid; width: 31px; height: 31px; margin-bottom: 8px; place-items: center; border: 1px solid #a56b4d; background: #f2c995; font: 900 16px/1 var(--pixel); }
.rack-drop b { font-size: 11px; }
.rack-drop small { margin-top: 5px; color: var(--muted); font-size: 8px; }
.rack-drop.is-dragging { border-color: var(--pink-deep); box-shadow: 0 0 0 4px rgba(217, 135, 158, .15); }
.sample-rack { width: 100%; margin-top: 8px; padding: 10px 11px; display: flex; justify-content: space-between; border: 1px solid var(--line); border-radius: 5px; background: #fffaf0; color: var(--ink); font-size: 9px; font-weight: 900; cursor: pointer; }

.range-control { margin-top: 15px; }
.range-control > div { display: flex; justify-content: space-between; }
.range-control label { font-size: 10px; font-weight: 900; }
.range-control output { padding: 3px 6px; border-radius: 9px; background: #f0e6da; font: 800 8px/1 var(--pixel); }
.range-control input { width: 100%; accent-color: var(--pink-deep); }
.range-control small { color: var(--muted); font-size: 8px; }
.rotation-heading { margin-top: 22px; }
.rack-rotation-card { padding: 12px; border: 1px solid #d3b99c; border-radius: 7px; background: linear-gradient(145deg, #fffaf2, #f7eadb); }
.rotation-readout { display: flex; align-items: center; justify-content: space-between; }
.rotation-readout label { color: var(--ink); font-size: 9px; font-weight: 900; }
.rotation-readout output { padding: 4px 7px; border-radius: 9px; background: #f0ddd0; color: var(--pink-deep); font: 900 9px/1 var(--pixel); }
#rackImageRotation { width: 100%; margin: 10px 0 8px; accent-color: var(--pink-deep); }
.rotation-shortcuts { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.rotation-shortcuts button { min-height: 28px; padding: 4px 2px; border: 1px solid #d6bea6; border-radius: 4px; background: #fffaf2; color: #725642; font: 800 7px/1 var(--pixel); cursor: pointer; }
.rotation-shortcuts button:hover, .rotation-shortcuts button.is-active { border-color: #b06d78; background: #f8dce1; color: #824858; }
.stability-advice { display: grid; grid-template-columns: 26px 1fr; gap: 8px; margin-top: 10px; padding: 10px; border: 1px solid #d9b891; border-radius: 6px; background: #fff4df; }
.stability-advice > span { display: grid; width: 25px; height: 25px; place-items: center; border-radius: 50%; background: #f1c88e; color: #6b432a; font: 900 12px/1 var(--pixel); }
.stability-advice div, .stability-advice b, .stability-advice small { display: block; }
.stability-advice b { color: #62442f; font-size: 8px; line-height: 1.4; }
.stability-advice small { margin-top: 3px; color: #8c6c53; font-size: 7px; line-height: 1.5; }
.stability-advice button { grid-column: 1 / -1; min-height: 30px; border: 1px solid #9a6650; border-radius: 4px; background: #8b563d; color: #fffaf2; font-size: 8px; font-weight: 900; cursor: pointer; }
.stability-advice button:disabled { cursor: not-allowed; opacity: .45; }
.stability-advice.is-good { border-color: #94b797; background: #edf6e7; }
.stability-advice.is-good > span { background: #bfe2ce; color: #37634b; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field-grid label { position: relative; color: var(--muted); font-size: 8px; font-weight: 800; }
.field-grid input {
  width: 100%; min-height: 39px; margin-top: 5px; padding: 8px 30px 8px 9px;
  border: 1px solid #d3b99c; border-radius: 5px; background: #fffaf2; color: var(--ink); font: 800 11px/1 var(--pixel); outline: none;
}
.field-grid input:focus { border-color: var(--pink); box-shadow: 0 0 0 3px rgba(217, 135, 158, .15); }
.field-grid label i { position: absolute; right: 8px; bottom: 12px; color: #967c6d; font: 700 7px/1 var(--pixel); }
.rack-alignment-card { margin-top: 10px; padding: 11px; border: 1px solid #cbb39a; border-radius: 7px; background: #fff8ec; }
.alignment-title b, .alignment-title small { display: block; }
.alignment-title b { color: var(--ink); font-size: 9px; }
.alignment-title small { margin-top: 3px; color: var(--muted); font-size: 7px; line-height: 1.45; }
.alignment-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 9px; }
.alignment-grid label { color: var(--muted); font-size: 8px; font-weight: 800; }
.alignment-grid .alignment-wide { grid-column: 1 / -1; }
.alignment-grid select { width: 100%; min-height: 36px; margin-top: 4px; padding: 7px; border: 1px solid #d3b99c; border-radius: 5px; background: #fffdf7; color: var(--ink); font-size: 8px; font-weight: 900; outline: none; }
.alignment-grid select:focus { border-color: var(--pink-deep); box-shadow: 0 0 0 3px rgba(217, 135, 158, .14); }
.rack-subdivision { margin-top: 10px; padding: 11px; border: 1px solid #c7ae93; border-radius: 7px; background: linear-gradient(145deg, #fff8ec, #f2e3d4); }
.subdivision-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.subdivision-title span, .subdivision-title b, .subdivision-title small { display: block; }
.subdivision-title b { color: var(--ink); font-size: 9px; }
.subdivision-title small { margin-top: 3px; color: var(--muted); font-size: 7px; }
.subdivision-title i { padding: 4px 6px; border-radius: 8px; background: #e8c4cc; color: #7d4653; font: 900 7px/1 var(--pixel); }
.subdivision-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-top: 9px; }
.subdivision-options button { min-height: 47px; border: 1px solid #d3b99c; border-radius: 5px; background: #fffaf2; color: var(--ink); cursor: pointer; }
.subdivision-options b, .subdivision-options small { display: block; }
.subdivision-options b { font: 900 9px/1 var(--pixel); }
.subdivision-options small { margin-top: 4px; color: var(--muted); font-size: 7px; }
.subdivision-options button.is-active { border-color: #a95f70; background: #f7dce2; box-shadow: inset 0 0 0 2px rgba(169,95,112,.12); }
.rack-subdivision p { margin: 8px 0 0; color: var(--muted); font-size: 7px; line-height: 1.55; }

.base-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.base-options button { min-height: 78px; padding: 8px 4px; border: 1px solid #d3b99c; border-radius: 6px; background: #fffaf2; color: var(--ink); cursor: pointer; }
.base-options button i, .base-options button b, .base-options button small { display: block; }
.base-options button i { color: var(--mint-deep); font: 900 20px/1 var(--pixel); }
.base-options button b { margin-top: 6px; font-size: 9px; }
.base-options button small { margin-top: 3px; color: var(--muted); font-size: 7px; }
.base-options button.is-active { border-color: #6f9f78; background: #e5f0dc; box-shadow: inset 0 0 0 2px rgba(89, 135, 101, .14); }
.base-fields { margin-top: 9px; }
.color-mode-label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 8px; font-weight: 900; }
#rackFaceDirection { width: 100%; min-height: 40px; padding: 8px; border: 1px solid #d3b99c; border-radius: 5px; background: #fffaf2; color: var(--ink); font-size: 10px; font-weight: 900; }
.rack-body-color {
  min-height: 54px; margin-top: 8px; padding: 9px 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid #d3b99c; border-radius: 5px; background: #fffaf2; cursor: pointer;
}
.rack-body-color span, .rack-body-color b, .rack-body-color small { display: block; }
.rack-body-color b { color: var(--ink); font-size: 9px; }
.rack-body-color small { margin-top: 3px; color: var(--muted); font-size: 7px; }
.rack-body-color input { width: 42px; height: 34px; padding: 2px; border: 1px solid #b99a7d; border-radius: 4px; background: #fff; cursor: pointer; }
.rack-color-swatches { display: flex; gap: 7px; margin-top: 8px; }
.rack-color-swatches button {
  width: 28px; height: 28px; border: 2px solid #fffaf2; border-radius: 4px; background: var(--swatch);
  box-shadow: 0 0 0 1px #b99a7d; cursor: pointer;
}
.rack-color-swatches button:hover, .rack-color-swatches button:focus-visible { transform: translateY(-2px); box-shadow: 0 2px 0 1px #8f6147; }
.control-note { margin: 9px 0 0; color: var(--muted); font-size: 8px; line-height: 1.6; }

.rack-stage { position: sticky; top: 80px; height: calc(100vh - 100px); min-height: 690px; display: flex; flex-direction: column; }
.rack-toolbar { min-height: 52px; padding: 8px 12px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(255, 251, 243, .96); }
.rack-view-buttons { display: flex; padding: 3px; border-radius: 6px; background: #efe3d6; }
.rack-view-buttons button { padding: 7px 10px; border: 0; border-radius: 4px; background: transparent; color: var(--ink); font-size: 9px; font-weight: 900; cursor: pointer; }
.rack-view-buttons button.is-active { background: #fffaf0; box-shadow: 2px 2px 0 rgba(89, 52, 34, .09); }
.rack-size { color: var(--pink-deep); font: 800 8px/1 var(--pixel); }
.rack-canvas-wrap {
  position: relative; flex: 1; min-height: 500px; overflow: hidden;
  background:
    linear-gradient(rgba(112, 78, 57, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(112, 78, 57, .035) 1px, transparent 1px),
    linear-gradient(160deg, #f4e9dc, #ead7ca);
  background-size: 30px 30px, 30px 30px, auto;
}
#rackCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#rackCanvas:active { cursor: grabbing; }
.rack-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; }
.rack-empty.is-hidden { display: none; }
.rack-empty canvas { width: 128px; height: 128px; image-rendering: pixelated; filter: drop-shadow(0 8px 2px rgba(90, 53, 34, .09)); }
.rack-empty b { margin-top: 8px; font-size: 15px; }
.rack-empty p { max-width: 330px; margin: 7px 16px; color: var(--muted); font-size: 10px; line-height: 1.65; }
.rack-badge { position: absolute; top: 12px; right: 12px; padding: 6px 8px; border: 1px solid rgba(89, 54, 36, .15); border-radius: 12px; background: rgba(255, 250, 239, .85); color: var(--muted); font: 800 8px/1 var(--pixel); pointer-events: none; }
.rack-checks { min-height: 68px; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); background: #fffaf1; }
.rack-checks > div { padding: 10px; display: grid; grid-template-columns: 19px 1fr; align-content: center; column-gap: 7px; border-right: 1px solid var(--line); }
.rack-checks > div:last-child { border-right: 0; }
.rack-checks span { grid-row: 1 / 3; display: grid; width: 18px; height: 18px; place-items: center; border: 1px solid #b7a699; border-radius: 50%; font-size: 9px; }
.rack-checks span.is-good { border-color: #709244; background: #dff0a8; color: #4a6818; }
.rack-checks b { font-size: 9px; }
.rack-checks small { margin-top: 2px; color: var(--muted); font-size: 7px; }

.rack-result { position: sticky; top: 80px; padding: 18px 15px; }
.result-heading { display: flex; align-items: center; justify-content: space-between; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.result-heading b { font-size: 13px; }
.result-heading span { padding: 5px 7px; border-radius: 10px; background: #eee5dc; color: var(--muted); font: 800 7px/1 var(--pixel); }
.result-heading span.is-good { background: #dfefa9; color: #486316; }
.rack-result dl { margin: 10px 0 15px; }
.rack-result dl div { min-height: 49px; padding: 9px 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); }
.rack-result dt { color: var(--muted); font-size: 9px; }
.rack-result dd { margin: 0; text-align: right; font: 800 8px/1.4 var(--pixel); }
.rack-downloads { display: grid; gap: 7px; }
.rack-downloads button { min-height: 44px; padding: 0 12px; display: flex; align-items: center; justify-content: space-between; border: 1px solid #a36a4e; border-radius: 5px; background: #81503c; color: #fffaf0; font-size: 10px; font-weight: 900; cursor: pointer; }
.rack-downloads button:nth-child(2) { border-color: #a95875; background: #d4849c; }
.rack-downloads .rack-3mf-download { border-color: #527b65; background: #73a486; }
.rack-downloads button:disabled { cursor: not-allowed; filter: grayscale(.55); opacity: .38; }
.rack-result > p { margin: 13px 2px 0; color: var(--muted); font-size: 8px; line-height: 1.6; }

footer { width: min(1240px, calc(100% - 40px)); margin: 26px auto 0; padding: 18px 0 24px; display: flex; justify-content: space-between; color: var(--muted); font: 800 8px/1 var(--pixel); }

@media (max-width: 1120px) {
  .rack-workbench { grid-template-columns: 290px minmax(0, 1fr); }
  .rack-result { position: static; grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1.2fr; gap: 20px; }
  .rack-result .rack-downloads { align-content: start; }
  .rack-result > p { grid-column: 2; }
}

@media (max-width: 780px) {
  .rack-header { grid-template-columns: 1fr auto; }
  .rack-header-note { display: none; }
  .rack-hero { grid-template-columns: 1fr; gap: 18px; padding: 26px 20px 22px; }
  .rack-hero-copy { padding: 14px 0 0; border-top: 1px solid var(--line); border-left: 0; }
  .rack-workbench { grid-template-columns: 1fr; }
  .rack-controls, .rack-stage, .rack-result { grid-column: auto; }
  .rack-stage { position: static; height: min(720px, calc(100vh - 20px)); min-height: 590px; }
  .rack-result { grid-template-columns: 1fr; }
  .rack-result > p { grid-column: auto; }
}

@media (max-width: 520px) {
  .rack-header { padding-inline: 14px; }
  .rack-brand small { display: none; }
  .rack-hero, .rack-workbench, footer { width: calc(100% - 20px); }
  .rack-hero h1 { font-size: 31px; }
  .rack-toolbar { align-items: flex-start; gap: 8px; }
  .rack-view-buttons { display: grid; grid-template-columns: 1fr 1fr; }
  .rack-view-buttons button { padding: 6px 8px; }
  .rack-size { margin-top: 7px; }
  .rack-checks { grid-template-columns: 1fr; }
  .rack-checks > div { border-right: 0; border-bottom: 1px solid var(--line); }
  footer { gap: 18px; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}

/* White studio preview. Watermark is a UI overlay, never exported geometry. */
.rack-canvas-wrap {
  isolation: isolate;
  background: radial-gradient(ellipse at 50% 38%, #ffffff 0%, #fffefc 55%, #f1ede8 100%);
}

.rack-canvas-wrap::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: 12%;
  right: 12%;
  bottom: 8%;
  height: 24%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(84, 48, 34, .12), transparent 68%);
  filter: blur(24px);
  pointer-events: none;
}

#rackCanvas {
  z-index: 1;
}

.rack-canvas-wrap .model-watermark {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, .82);
  font: 400 clamp(34px, 5vw, 62px)/1 Georgia, "Times New Roman", serif;
  letter-spacing: .025em;
  text-shadow: 0 1px 2px rgba(54, 38, 30, .34), 0 0 16px rgba(255, 255, 255, .22);
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}

.rack-empty,
.rack-badge {
  z-index: 7;
}

@media (max-width: 520px) {
  .rack-canvas-wrap .model-watermark {
    font-size: clamp(30px, 11vw, 48px);
  }
}
