/* 铸造大师 — 深色简洁 UI，与同系列工具同系 */

:root {
  --bg: #0a0a0a;
  --panel: #111111;
  --border: #555;
  --border-soft: #3a3a3a;
  --text: #e8e8e8;
  --muted: #9a9a9a;
  --accent: #7ec8e3;
  --accent-hover: #9ad7ee;
  --input-bg: #1a1a1a;
  --btn-bg: #1c1c1c;
  --btn-hover: #2a2a2a;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* 抑制 iPad Scribble：touch-action 不含 auto/manipulation/handwriting */
.no-scribble #panel {
  touch-action: pan-y;
}

.no-scribble #panel .btn,
.no-scribble #panel .switch,
.no-scribble #view-modes button,
.no-scribble #rotate-pad .btn {
  touch-action: none;
}

/* 输入框允许系统手势，便于弹出屏幕键盘 */
.no-scribble #panel input[type="number"],
.no-scribble #panel input[type="text"],
.no-scribble #panel textarea {
  touch-action: manipulation;
  -webkit-user-select: text;
  user-select: text;
}

/* 上传：允许系统文件选择手势（iPad） */
.no-scribble #panel .file-upload-btn,
.no-scribble #panel .file-upload-btn input[type="file"] {
  touch-action: manipulation;
}

.no-scribble #panel input[type="number"]:not([readonly]) {
  -webkit-user-select: text;
  user-select: text;
}

#app {
  display: grid;
  grid-template-columns: 1fr 250px;
  width: 100%;
  height: 100%;
}

#viewport-wrap {
  position: relative;
  background: #1a1a1a;
  border-right: 1px solid #333;
  min-width: 0;
  min-height: 0;
  touch-action: none;
}

#viewport {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#busy-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 12, 12, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

#busy-overlay[hidden] {
  display: none !important;
}

.busy-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 22px 28px;
  border: 1px solid #555;
  background: rgba(18, 18, 18, 0.92);
  border-radius: 4px;
  min-width: 200px;
  max-width: min(360px, 88vw);
}

.busy-card.is-progress {
  align-items: stretch;
}

.busy-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #3a3a3a;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: busy-spin 0.75s linear infinite;
  flex-shrink: 0;
  align-self: center;
}

.busy-title {
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.02em;
}

#busy-text {
  color: var(--text);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-align: center;
  line-height: 1.45;
}

.busy-card.is-progress #busy-text {
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.02em;
}

.busy-steps {
  list-style: none;
  margin: 2px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.busy-steps li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
}

.busy-steps li::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-top: 4px;
  border-radius: 50%;
  border: 1.5px solid #666;
  flex-shrink: 0;
  box-sizing: border-box;
}

.busy-steps li.is-done {
  color: #b8b8b8;
}

.busy-steps li.is-done::before {
  border-color: #6a9e78;
  background: #6a9e78;
}

.busy-steps li.is-active {
  color: var(--text);
  font-weight: 500;
}

.busy-steps li.is-active::before {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(126, 200, 227, 0.18);
}

.busy-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11.5px;
  text-align: center;
  line-height: 1.5;
}

@keyframes busy-spin {
  to {
    transform: rotate(360deg);
  }
}

#thin-label-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.thin-label {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
  color: #ff2a2a;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  text-shadow:
    0 0 2px rgba(0, 0, 0, 0.95),
    0 1px 2px rgba(0, 0, 0, 0.9),
    1px 0 0 rgba(0, 0, 0, 0.55),
    -1px 0 0 rgba(0, 0, 0, 0.55);
  white-space: nowrap;
  user-select: none;
}

.thin-label.is-back {
  opacity: 0.2;
}

#hint-stack {
  position: absolute;
  left: 12px;
  bottom: 62px;
  max-width: min(46%, 420px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
  z-index: 2;
}

#status {
  position: static;
  color: var(--muted);
  font-size: 11px;
  opacity: 0.95;
  text-align: left;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  line-height: 1.6;
  max-width: 100%;
  white-space: pre-line;
}

#log-panel {
  position: static;
  max-width: 100%;
  max-height: 180px;
  overflow: hidden;
  display: flex;
  flex-direction: column-reverse;
  gap: 5px;
  text-align: left;
  font-size: 11px;
  color: rgba(240, 240, 240, 0.85);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

#log-panel .log-item {
  line-height: 1.6;
  padding: 1px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#lasso-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  /* 仅绘制套索；命中判定在 WebGL canvas，空白处可转视角 */
  pointer-events: none;
  cursor: crosshair;
}

#lasso-layer canvas {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

#viewport-top-left {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  max-width: min(280px, calc(100% - 24px));
  pointer-events: none;
}

#viewport-ops {
  min-width: 168px;
  padding: 8px 10px 9px;
  background: rgba(10, 10, 10, 0.84);
  border: 1px solid #454545;
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  user-select: none;
}

.ops-title {
  font-size: 10px;
  color: #6a6a6a;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

#viewport-ops-body {
  color: #d0d0d0;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-line;
}

#view-hud {
  position: absolute;
  right: 12px;
  bottom: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  z-index: 3;
  pointer-events: none;
}

#view-hud > * {
  pointer-events: auto;
}

#result-summary {
  min-width: 168px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 9px 11px;
  background: rgba(10, 10, 10, 0.84);
  border: 1px solid #454545;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.4;
  color: #a8a8a8;
  user-select: none;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

#result-summary[hidden] {
  display: none !important;
}

#result-summary div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
}

#result-summary span {
  color: #6a6a6a;
  flex: 0 0 auto;
  font-size: 11px;
}

#result-summary b {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-size: 13px;
  color: #ffffff;
}

#result-summary b.rs-warn {
  color: #e8b84a;
}

.rs-min-title {
  margin-top: 4px;
  padding-top: 5px;
  border-top: 1px solid #333;
  color: #6a6a6a;
  font-size: 10px;
  letter-spacing: 0.06em;
}

.rs-min-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 132px;
  overflow: hidden;
}

.rs-min-list .rs-empty {
  color: #7a7a7a;
  font-size: 11px;
}

.rs-min-list div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.rs-min-list span {
  color: #6a6a6a;
  font-size: 11px;
}

.rs-min-list b {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: #fff;
}

.rs-min-list b.rs-hot {
  color: #e8b84a;
}

#view-modes {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 6px;
}

#app-brand {
  align-self: center;
  margin-right: 2px;
  color: #c8c8c8;
  font-size: 12px;
  letter-spacing: 0.06em;
  user-select: none;
  white-space: nowrap;
}

#app-version {
  align-self: center;
  margin-right: 4px;
  color: #888;
  font-size: 11px;
  letter-spacing: 0.04em;
  opacity: 0.85;
  user-select: none;
}

#view-modes button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 52px;
  height: 48px;
  padding: 4px 2px;
  border: 1px solid #666;
  background: rgba(22, 22, 22, 0.88);
  color: #c8c8c8;
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

#view-modes button svg {
  width: 20px;
  height: 20px;
  display: block;
}

#view-modes button span {
  font-size: 10px;
  line-height: 1;
  user-select: none;
}

#view-modes button:hover {
  border-color: #aaa;
  color: #fff;
  background: rgba(40, 40, 40, 0.95);
}

#view-modes button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: #444;
  color: #777;
  background: rgba(22, 22, 22, 0.6);
}

#view-modes button:disabled:hover {
  border-color: #444;
  color: #777;
  background: rgba(22, 22, 22, 0.6);
}

#view-modes button.active {
  border-color: var(--accent);
  color: #0a1a22;
  background: var(--accent);
}

#view-modes button.active svg {
  color: #0a1a22;
}

/* —— 右侧面板 —— */
#panel {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid #444;
  padding: 10px 12px 14px;
  gap: 8px;
  overflow-y: auto;
  overflow-x: hidden;
}

#workflow {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-top: 2px;
}

.wf-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  padding: 5px 2px;
  border: 1px solid #444;
  background: #171717;
  color: #8a8a8a;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.wf-step .wf-num {
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.wf-step .wf-lab {
  font-size: 11px;
  letter-spacing: 0.04em;
  line-height: 1;
  user-select: none;
}

.wf-step.done {
  border-color: rgba(110, 184, 214, 0.45);
  color: #b8d8e6;
  background: rgba(110, 184, 214, 0.08);
}

.wf-step.current {
  border-color: var(--accent);
  color: #0a1a22;
  background: var(--accent);
}

.wf-step.current .wf-num,
.wf-step.current .wf-lab {
  color: #0a1a22;
  font-weight: 700;
}

#workflow-hint {
  margin-top: -2px;
  margin-bottom: 2px;
  padding: 6px 8px;
  border-left: 3px solid var(--accent);
  background: rgba(126, 200, 227, 0.08);
  color: #c8c8c8;
  font-size: 11px;
  line-height: 1.4;
}

.mode-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: 5px;
  border: 1px solid var(--block-line, #333);
  background: var(--block-bg, rgba(255, 255, 255, 0.02));
  margin-bottom: 8px;
}

.mode-block-last {
  margin-bottom: 0;
}

.mode-block.is-active {
  box-shadow: inset 0 0 0 1px var(--block-line, rgba(126, 200, 227, 0.45));
  background: var(--block-bg-active, var(--block-bg, rgba(126, 200, 227, 0.06)));
}

.mode-block[data-block="hide"] {
  --block-accent: transparent;
  --block-bg: transparent;
  --block-bg-active: transparent;
  --block-line: transparent;
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 2px 0;
  margin-bottom: 6px;
}

.mode-block[data-block="hide"].is-active {
  box-shadow: none;
  background: transparent;
}

.global-hist-row {
  display: flex;
  gap: 6px;
  margin: 0 0 8px;
}

.global-hist-row .btn {
  flex: 1;
}

.mode-block[data-block="measure"] {
  --block-accent: #6eb8d6;
  --block-bg: rgba(110, 184, 214, 0.08);
  --block-bg-active: rgba(110, 184, 214, 0.14);
  --block-line: rgba(110, 184, 214, 0.4);
}

.mode-block[data-block="shell"] {
  --block-accent: #5ecf9a;
  --block-bg: rgba(94, 207, 154, 0.08);
  --block-bg-active: rgba(94, 207, 154, 0.14);
  --block-line: rgba(94, 207, 154, 0.4);
}

.mode-block[data-block="region"] {
  --block-accent: #e8b84a;
  --block-bg: rgba(232, 184, 74, 0.09);
  --block-bg-active: rgba(232, 184, 74, 0.16);
  --block-line: rgba(232, 184, 74, 0.42);
}

/* 水口：与原「标记区域」同色 */
.mode-block[data-block="sprue"] {
  --block-accent: #e8b84a;
  --block-bg: rgba(232, 184, 74, 0.09);
  --block-bg-active: rgba(232, 184, 74, 0.16);
  --block-line: rgba(232, 184, 74, 0.42);
}

/* 核算编辑：对齐指环「开口」红调 */
.mode-block[data-block="account"] {
  --block-accent: #d47a7a;
  --block-bg: rgba(212, 122, 122, 0.11);
  --block-bg-active: rgba(212, 122, 122, 0.18);
  --block-line: rgba(212, 122, 122, 0.45);
}

.mode-block[data-block="drill"] {
  --block-accent: #7a9cff;
  --block-bg: rgba(122, 156, 255, 0.08);
  --block-bg-active: rgba(122, 156, 255, 0.14);
  --block-line: rgba(122, 156, 255, 0.4);
}

.mode-block[data-block="export"] {
  --block-accent: #9a9a9a;
  --block-bg: rgba(154, 154, 154, 0.06);
  --block-bg-active: rgba(154, 154, 154, 0.1);
  --block-line: rgba(154, 154, 154, 0.35);
}

/* 抽壳内嵌的标记区域小节 */
.sub-section {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.block-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--block-accent, #8a8a8a);
  user-select: none;
  margin-bottom: 2px;
}

.block-note,
.export-hint {
  margin: 0;
  font-size: 10px;
  line-height: 1.4;
  color: #6a6a6a;
}

.mode-extras {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mode-extras[hidden] {
  display: none !important;
}

.mode-switch-row,
.pierce-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
}

.mode-side,
.pierce-side {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.mode-side:has(input:disabled),
.pierce-side:has(input:disabled) {
  opacity: 0.35;
  pointer-events: none;
}

#block-region-inner.is-probe-locked .mode-side-label,
#block-region-inner.is-probe-locked .pierce-side-label,
#block-region-inner.is-probe-locked .param-row {
  opacity: 0.38;
}

.mode-side-label,
.pierce-side-label {
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
  user-select: none;
}

.mode-block[data-block="account"] .mode-side-label {
  color: var(--text);
}

.mode-side .switch,
.pierce-side .switch {
  width: 44px;
  height: 22px;
  flex-shrink: 0;
}

.mode-side-btn {
  flex: 0 0 96px;
  width: 96px;
  min-width: 96px;
  max-width: 96px;
  box-sizing: border-box;
  padding-left: 6px;
  padding-right: 6px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hide-btns-row {
  margin: 0;
}

.hide-btns-row .btn {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  text-align: center;
  white-space: nowrap;
}

.shell-switch-row {
  align-items: center;
  gap: 6px;
}

.shell-mat-presets {
  display: none;
}

.shell-mat-btn {
  display: none;
}

.mode-switch-row .switch-slider::before,
.pierce-switch-row .switch-slider::before {
  height: 16px;
  width: 16px;
  left: 2px;
  top: 2px;
}

.mode-switch-row .switch input:checked + .switch-slider::before,
.pierce-switch-row .switch input:checked + .switch-slider::before {
  transform: translateX(22px);
}

.param-row {
  display: grid;
  grid-template-columns: 48px 1fr 52px;
  align-items: center;
  gap: 8px;
  min-height: 36px;
}

.param-row label {
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
  user-select: none;
}

.param-row input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 32px;
  margin: 0;
  background: transparent;
  border: none;
  outline: none;
  min-width: 0;
  touch-action: none;
  cursor: pointer;
}

.param-row input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  background: #2a2a2a;
  border-radius: 3px;
  border: 1px solid #444;
}

.param-row input[type="range"]::-moz-range-track {
  height: 6px;
  background: #2a2a2a;
  border-radius: 3px;
  border: 1px solid #444;
}

.param-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border-radius: 50%;
  background: #c8c8c8;
  border: 1px solid #888;
  cursor: pointer;
}

.param-row input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #c8c8c8;
  border: 1px solid #888;
  cursor: pointer;
}

.param-row input[type="number"] {
  width: 52px;
  height: 28px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  text-align: center;
  font-size: 12px;
  border-radius: 0;
  outline: none;
}

.param-row input[type="number"]:focus {
  border-color: var(--accent);
}

#heat-legend.has-heat .heat-legend-bar {
  box-shadow: 0 0 0 1px rgba(126, 200, 227, 0.35);
}

/* 与自动排石 mode-block 分隔线同款（兼容旧 class） */
.panel-sep {
  flex-shrink: 0;
  height: 0;
  margin: 4px 0;
  border: none;
  border-bottom: 1px solid var(--border);
}

.field-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}

.field-ab-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.field-ab-wrap input {
  flex: 1;
  min-width: 0;
}

.btn-icon-reset {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-reset .sync-icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  display: block;
}

.btn-icon-reset:hover:not(:disabled) {
  border-color: #6a9;
  color: #9dc;
}

.btn-icon-reset:disabled {
  opacity: 0.35;
  cursor: default;
  color: #777;
}

.material-preset-row {
  margin: 0 0 10px;
}

.material-preset-row label {
  color: var(--muted);
}

.heat-legend-inline {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0 2px;
}

.field-row label {
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
  user-select: none;
}

.field-row input,
#material-select {
  width: 100%;
  height: 28px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  text-align: center;
  font-size: 12px;
  border-radius: 0;
  outline: none;
}

.field-row input:focus,
#material-select:focus {
  border-color: var(--accent);
}

.field-switch {
  grid-template-columns: 72px 1fr;
  align-items: center;
}

.field-switch-duo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 20px;
  align-items: center;
  min-height: 28px;
}

.field-switch-duo .switch-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.field-switch-duo .switch-item > label:first-child {
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
  user-select: none;
  flex: 0 1 auto;
  min-width: 0;
}

.field-switch-duo .switch {
  justify-self: auto;
  flex-shrink: 0;
  margin-left: 4px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 26px;
  cursor: pointer;
  justify-self: end;
  flex-shrink: 0;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track,
.switch-slider {
  position: absolute;
  inset: 0;
  background: #2a2a2a;
  border: 1px solid #555;
  border-radius: 999px;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.switch-track::after,
.switch-slider::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #d0d0d0;
  border: 1px solid #888;
  transition: transform 0.18s ease, background 0.18s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.switch-track::after {
  width: 16px;
  height: 16px;
}

.switch input:checked + .switch-track,
.switch input:checked + .switch-slider {
  background: #6eb8e8;
  border-color: #6eb8e8;
}

.switch input:checked + .switch-track::after {
  transform: translateX(18px);
  background: #f2f2f2;
  border-color: #f2f2f2;
}

.switch input:checked + .switch-slider::before {
  transform: translateX(26px);
  background: #f2f2f2;
  border-color: #f2f2f2;
}

.switch input:focus-visible + .switch-track,
.switch input:focus-visible + .switch-slider {
  outline: 1px solid #6eb8e8;
  outline-offset: 2px;
}

.field-switch-duo .switch {
  width: 40px;
  height: 22px;
}

.field-switch-duo .switch-slider::before,
.field-switch-duo .switch-track::after {
  width: 16px;
  height: 16px;
}

.field-switch-duo .switch input:checked + .switch-slider::before,
.field-switch-duo .switch input:checked + .switch-track::after {
  transform: translateX(18px);
}

#heat-legend {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 2px 0 6px;
}

.heat-legend-bar {
  height: 10px;
  border: 1px solid #555;
  border-radius: 2px;
  background: linear-gradient(90deg, #eb1f1a 0%, #fa7a14 18%, #fbe02e 32%, #24c247 46%, #3890f5 62%, #143ee8 74%, #0a1a6a 88%, #03050f 100%);
}

.heat-legend-ends {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
}

#material-select {
  text-align: left;
  padding: 0 8px;
  cursor: pointer;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.cut-path-btns {
  grid-template-columns: 1fr 1fr;
  margin-bottom: 0;
  gap: 8px;
}

.cut-path-section .btn {
  width: 100%;
}

.account-price-btns {
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.account-size-block {
  /* 轴标签 | 比例锁 | 输入+重置+mm */
  display: grid;
  grid-template-columns: 18px 28px minmax(0, 1fr);
  grid-template-rows: repeat(3, auto);
  gap: 6px 8px;
  align-items: center;
  margin: 4px 0 8px;
}

.account-size-block > .axis-x {
  grid-column: 1;
  grid-row: 1;
}

.account-size-block > .axis-y {
  grid-column: 1;
  grid-row: 2;
}

.account-size-block > .axis-z {
  grid-column: 1;
  grid-row: 3;
}

.account-size-lock {
  grid-column: 2;
  grid-row: 1 / span 3;
  align-self: stretch;
  width: 28px;
  min-height: 64px;
  padding: 0;
  border: 1px solid rgba(212, 122, 122, 0.35);
  border-radius: 6px;
  background: rgba(212, 122, 122, 0.08);
  color: #e8d0d0;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.account-size-lock.is-locked {
  border-color: rgba(212, 122, 122, 0.7);
  background: rgba(212, 122, 122, 0.2);
  color: #e8a0a0;
}

.account-size-lock:disabled {
  opacity: 0.45;
  cursor: default;
}

.account-size-block > .account-size-wrap {
  grid-column: 3;
}

.account-size-block > .axis-x,
.account-size-block > .axis-y,
.account-size-block > .axis-z {
  margin: 0;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  user-select: none;
}

.account-size-block > .axis-x {
  color: #e74c3c;
}

.account-size-block > .axis-y {
  color: #2ecc71;
}

.account-size-block > .axis-z {
  color: #3498db;
}

.account-size-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  width: 100%;
}

.account-size-wrap input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  height: 28px;
  text-align: center;
  background: var(--input-bg) !important;
  color: var(--text) !important;
  border: 1px solid var(--border);
  border-radius: 0;
  outline: none;
  color-scheme: dark;
  -webkit-text-fill-color: var(--text);
  opacity: 1;
}

.account-size-wrap input:disabled,
.account-size-wrap input:read-only {
  background: var(--input-bg) !important;
  color: var(--text) !important;
  opacity: 1;
  -webkit-text-fill-color: var(--text);
}

.account-size-wrap input:-webkit-autofill,
.account-size-wrap input:-webkit-autofill:hover,
.account-size-wrap input:-webkit-autofill:focus,
.account-size-wrap input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 1000px var(--input-bg) inset !important;
  box-shadow: 0 0 0 1000px var(--input-bg) inset !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
  transition: background-color 99999s ease-out;
}

.account-size-lock .lock-icon {
  width: 17px;
  height: 17px;
  display: block;
  flex-shrink: 0;
}

.account-size-lock:not(.is-locked) {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
  color: #ececec;
}

.account-size-lock:not(.is-locked) .lock-icon-open {
  transform: translateY(-1px);
}

/* 理论重量等：标签列宽 = 轴+锁，使输入框左缘与 XYZ 对齐 */
.mode-block[data-block="account"] .mode-extras > .field-row {
  grid-template-columns: 54px 1fr;
}

.btn-size-reset {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid rgba(212, 122, 122, 0.35);
  border-radius: 4px;
  background: rgba(212, 122, 122, 0.08);
  color: #d0d0d0;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.btn-size-reset:hover:not(:disabled) {
  border-color: rgba(212, 122, 122, 0.7);
  color: #e8a0a0;
}

.btn-size-reset:disabled {
  opacity: 0.4;
  cursor: default;
}

input.no-spin::-webkit-outer-spin-button,
input.no-spin::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input.no-spin {
  -moz-appearance: textfield;
  appearance: textfield;
}

.shrink-row {
  margin-top: 8px;
}

/* 方位立方 108×108、margin 14；徽章放大 25% 后与立方垂直居中对齐 */
#shrink-fang-badge {
  position: absolute;
  top: 51px;
  right: 128px;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid #d47a7a;
  color: #d47a7a;
  font-size: 15px;
  font-weight: 700;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
  pointer-events: none;
  box-shadow: none;
  letter-spacing: 0;
  line-height: 1;
}

#shrink-fang-badge[hidden] {
  display: none !important;
}

.account-cost-block {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 8px;
  margin: 10px 0 4px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(255, 170, 60, 0.08);
}

.account-cost-label {
  font-size: 12px;
  color: var(--muted, #9aa3ad);
  white-space: nowrap;
}

.account-cost-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  color: #ffb84d;
  letter-spacing: 0.02em;
  text-align: right;
  font-variant-numeric: tabular-nums;
  min-height: 1.2em;
}

.account-cost-unit {
  font-size: 13px;
  color: #ffb84d;
  opacity: 0.85;
}

.field-unit {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--muted, #9aa3ad);
  min-width: 2.5em;
}

.hint-line {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.55);
}

.sprue-hist-row {
  margin: 0;
}

.sprue-hist-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  padding: 0 8px;
}

.sprue-hist-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: block;
  overflow: visible;
}

.sprue-hist-btn span {
  line-height: 1;
}

.btn {
  flex-shrink: 0;
  height: 34px;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s;
}

.btn:hover:not(:disabled) {
  background: var(--btn-hover);
  border-color: #888;
}

.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.btn-primary {
  border-color: #5a9bb0;
  background: var(--accent);
  color: #0a1a22;
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* iPad：文件选择须由手指直接点在 input 上，不能 JS 间接 click */
.file-upload-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin: 0;
  -webkit-user-select: none;
  user-select: none;
}

.file-upload-btn input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.01;
  cursor: pointer;
  font-size: 16px;
  z-index: 2;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.file-upload-btn.is-disabled {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
}

.file-upload-btn.is-disabled input[type="file"] {
  pointer-events: none;
}

.btn-export {
  margin-top: 4px;
  border-color: #5a9bb0;
  background: var(--accent);
  color: #0a1a22;
  font-weight: 600;
}

.btn-export:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn.active-mode {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(126, 200, 227, 0.08);
}

#rotate-pad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px 0 2px;
}

#rotate-pad > .btn-rot {
  width: 72px;
}

.rotate-mid {
  display: flex;
  gap: 8px;
  width: 100%;
  justify-content: center;
}

.rotate-mid .btn-rot {
  width: calc(50% - 4px);
  max-width: 88px;
}

.btn-rot {
  height: 30px;
  font-size: 12px;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#rotate-pad .btn-rot-spin .rot-spin-icon {
  width: 18px;
  height: 18px;
  display: block;
  color: #e8e8e8;
}

#rotate-pad .btn-rot-spin:disabled .rot-spin-icon {
  color: #777;
}

.field-hint {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.35;
  color: #9a9a9a;
}

.cast-color-hint {
  line-height: 1.55;
  color: #a8a8a8;
}

.cast-color-hint .cc-swatch {
  display: inline-block;
  font-weight: 700;
  padding: 0 5px;
  margin: 0 1px;
  border-radius: 3px;
  line-height: 1.35;
  vertical-align: baseline;
}

/* 与 colormap 一致：红/黄/绿/青/中蓝/墨蓝 */
.cast-color-hint .cc-red {
  background: #eb1f1a;
  color: #fff;
}

.cast-color-hint .cc-yellow {
  background: #facd2e;
  color: #1a1a1a;
}

.cast-color-hint .cc-green {
  background: #24c247;
  color: #fff;
}

.cast-color-hint .cc-cyan {
  background: #7ec8e3;
  color: #0a3040;
}

.cast-color-hint .cc-blue {
  background: #143dea; /* COLOR_THICK ≈ (0.08,0.24,0.92) */
  color: #fff;
}

.cast-color-hint .cc-ink {
  background: #05081a; /* COLOR_INK_BLUE ≈ (0.02,0.03,0.10) */
  color: #dce3ff;
  box-shadow: inset 0 0 0 1px #4a5688;
}

.cast-tune-note {
  margin: 6px 0 4px;
  font-size: 11px;
  line-height: 1.4;
  color: #8a8a8a;
}

.cast-tune-panel {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px dashed #555;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
}

.cast-tune-panel > summary {
  cursor: pointer;
  font-size: 12px;
  color: #c8c8c8;
  user-select: none;
}

.cast-tune-actions {
  margin-top: 8px;
}

.cast-tune-sliders {
  margin-top: 6px;
  max-height: 420px;
  overflow: auto;
  padding-right: 2px;
}

.cast-tune-group-title {
  margin: 10px 0 4px;
  font-size: 11px;
  color: #8ab4f8;
  letter-spacing: 0.02em;
}

.cast-tune-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  align-items: center;
  margin-bottom: 6px;
}

.cast-tune-row label {
  font-size: 11px;
  color: #bdbdbd;
  grid-column: 1 / -1;
}

.cast-tune-row input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: #5b9bd5;
}

.cast-tune-val {
  font-size: 11px;
  color: #e0e0e0;
  min-width: 3.2em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cast-tune-row .cast-tune-hint {
  grid-column: 1 / -1;
  font-size: 10px;
  color: #777;
  line-height: 1.25;
}

/* 兼容旧 class：全部映射为统一灰按钮 */
.btn-green,
.btn-orange,
.btn-pink,
.btn-white,
.btn-blue {
  background: var(--btn-bg);
  border-color: var(--border);
  color: var(--text);
}

.btn-green:hover:not(:disabled),
.btn-orange:hover:not(:disabled),
.btn-pink:hover:not(:disabled),
.btn-white:hover:not(:disabled),
.btn-blue:hover:not(:disabled) {
  background: var(--btn-hover);
  border-color: #888;
  color: var(--text);
}

#panel::-webkit-scrollbar {
  width: 6px;
}

#panel::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 3px;
}


.tunnel-tools {
  display: flex;
  gap: 6px;
  width: 100%;
}
.tunnel-tools .btn {
  flex: 1;
}
#btn-tunnel-exit:disabled,
#btn-delete-faces:disabled,
#btn-tunnel-erase:disabled {
  opacity: 0.45;
}
#btn-tunnel-erase.active-mode {
  border-color: #c45c2a;
  color: #f0c0a0;
}


.confirm-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text);
  text-align: center;
}

.confirm-message {
  color: var(--muted);
  line-height: 1.55;
  white-space: pre-line;
  margin-bottom: 14px;
  text-align: center;
}

.choice-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  width: 100%;
}

.choice-options .choice-option {
  width: 100%;
  justify-content: center;
  text-align: center;
}

#choice-overlay {
  position: absolute;
  inset: 0;
  z-index: 22;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 12, 12, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

#choice-overlay[hidden] {
  display: none !important;
}

#confirm-overlay {
  position: absolute;
  inset: 0;
  z-index: 21;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 12, 12, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
#confirm-overlay[hidden] {
  display: none !important;
}
.confirm-card {
  min-width: min(420px, 86vw);
  max-width: 520px;
  text-align: center;
}
.confirm-text {
  color: #f2f2f2;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  margin-bottom: 4px;
}
.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  width: 100%;
  margin-top: 6px;
}
.confirm-actions .btn {
  min-width: 120px;
}


/* 法线选区 HUD（对齐排石） */
#normal-pick-hud {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 18;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}
#normal-pick-hud[hidden] {
  display: none !important;
}
#normal-pick-hud .np-slider-wrap,
#normal-pick-hud .np-actions {
  pointer-events: auto;
}
#normal-pick-hud .np-slider-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 8px;
  background: rgba(18, 18, 18, 0.88);
  border: 1px solid #555;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}
#normal-pick-hud #normal-tol {
  width: min(42vw, 220px);
  accent-color: #e8a020;
}
#normal-pick-hud #normal-tol-val {
  min-width: 2.6em;
  font-size: 13px;
  color: #f0c070;
  font-variant-numeric: tabular-nums;
}
#normal-pick-hud .np-actions {
  display: flex;
  gap: 10px;
}
#normal-pick-hud .np-btn {
  min-width: 72px;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid #666;
  background: #222;
  color: #ddd;
  cursor: pointer;
  font-size: 14px;
}
#normal-pick-hud .np-ok {
  border-color: #e8a020;
  color: #1a1208;
  background: #e8a020;
}
.region-tool-row-3 {
  flex-wrap: wrap;
}
.region-tool-row-3 .pierce-side {
  flex: 1 1 auto;
  min-width: 4.5em;
}


/* —— 用量统计看板（tool-usage-stats） —— */
/* 用量管理员看板（暗色工具面板）— 金标指环 v1.14.54 */

.usage-admin-root,
#usage-admin-root {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.usage-admin-root[hidden],
#usage-admin-root[hidden] {
  display: none !important;
}
.usage-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}
.usage-panel {
  position: relative;
  z-index: 1;
  width: min(720px, calc(100vw - 24px));
  max-height: min(86vh, 900px);
  overflow: auto;
  background: #161616;
  border: 1px solid #444;
  border-radius: 6px;
  color: #ddd;
  padding: 14px 16px 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.usage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.usage-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.usage-close {
  border: 0;
  background: transparent;
  color: #aaa;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.usage-login-form {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.usage-login-form input,
.usage-password {
  flex: 1;
  min-width: 0;
  height: 34px;
  border: 1px solid #555;
  border-radius: 3px;
  background: #0e0e0e;
  color: #eee;
  padding: 0 10px;
}
.usage-err {
  color: #e74c3c;
  font-size: 12px;
  margin: 0;
}
.usage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 13px;
}
.usage-toolbar select,
.usage-days {
  margin: 0 4px;
  background: #0e0e0e;
  color: #eee;
  border: 1px solid #555;
  border-radius: 3px;
  height: 28px;
}
.usage-overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.usage-card {
  background: #101010;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 8px 6px;
  text-align: center;
}
.usage-card b {
  display: block;
  font-size: 18px;
  color: #f0f0f0;
  margin-bottom: 2px;
}
.usage-card span {
  font-size: 11px;
  color: #888;
}
.usage-dash h3 {
  margin: 14px 0 6px;
  font-size: 13px;
  color: #bbb;
  font-weight: 600;
}
.usage-table-wrap {
  overflow: auto;
  border: 1px solid #333;
  border-radius: 4px;
}
.usage-recent-wrap {
  max-height: 180px;
}
.usage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.usage-table th,
.usage-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #2a2a2a;
  text-align: left;
  white-space: nowrap;
}
.usage-table th {
  background: #1c1c1c;
  color: #aaa;
  font-weight: 500;
  position: sticky;
  top: 0;
}
.usage-note {
  margin: 10px 0 0;
  font-size: 11px;
  color: #777;
  line-height: 1.4;
}
@media (max-width: 640px) {
  .usage-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

