/* rp-prep 작업 화면. 외부 글꼴·이미지 없이 시스템 글꼴만 쓴다(설치형·온라인판 공통, CSP style-src 'self').
   배치: 짙은 위 막대(파일·되돌리기·장비) · 왼쪽 부품 · 가운데 3D 보기와 보기 막대 · 오른쪽 작업 탭 · 아래 알림 줄.
   색: 차가운 회색 작업대 위에 강조색은 하나(호박색, 3D에서 고른 부품과 같은 색). 축 색은 X 빨강·Y 초록·Z 파랑 관례. */
:root {
  --chrome: #1f2328; --chrome-2: #2c3238; --chrome-3: #383f46; --chrome-fg: #e8ebee; --chrome-muted: #98a1aa;
  --chrome-line: #3a4148;
  --bg: #e9ecef; --panel: #ffffff; --panel-2: #f5f7f8; --panel-3: #eef1f3;
  --ink: #1b1f23; --ink-2: #444c55; --muted: #66707a; --line: #e1e5e9; --line-2: #c9d0d6;
  --accent: #e2802c; --accent-strong: #c9671a; --accent-ink: #8f4709; --accent-tint: #fdf2e7; --accent-line: #f1bc8c;
  --primary: #22282e; --primary-2: #343c44; --primary-fg: #ffffff;
  --ok: #1d7f45; --ok-tint: #e5f4ea; --bad: #cf3535; --bad-tint: #fdeaea; --warn: #a96400; --warn-tint: #fff4e0;
  --warn-ink: #8a5200; /* 호박색 고른 부품 바탕(--accent-tint) 위에서도 4.5:1 */
  --ax-x: #d64545; --ax-y: #2f9a4f; --ax-z: #3a72d6;
  --r: 6px; --h: 30px;
  --sh-1: 0 1px 2px rgba(17, 24, 31, .07), 0 0 0 1px rgba(17, 24, 31, .02);
  --sh-2: 0 8px 24px rgba(17, 24, 31, .14), 0 1px 3px rgba(17, 24, 31, .08);
  --font: system-ui, -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 13px/1.45 var(--font);
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
::selection { background: var(--accent-tint); }
.grow { flex: 1; }
.sep { width: 1px; align-self: stretch; background: var(--line); margin: 2px 4px; }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }

/* ---------------------------------------------------------------- 단추 */
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--h); padding: 0 11px;
  border: 1px solid var(--line-2); border-radius: var(--r); background: var(--panel); color: var(--ink);
  box-shadow: var(--sh-1); cursor: pointer; white-space: nowrap; font-weight: 500;
  transition: background-color .12s, border-color .12s, color .12s, box-shadow .12s;
}
button:hover:not(:disabled) { background: var(--panel-2); border-color: #b4bcc4; }
button:active:not(:disabled) { background: var(--panel-3); box-shadow: none; }
button:disabled { opacity: .42; cursor: default; box-shadow: none; }
button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
button.primary:hover:not(:disabled) { background: var(--primary-2); border-color: var(--primary-2); }
button.primary:active:not(:disabled) { background: #121619; }
button.accent { background: var(--accent); border-color: var(--accent-strong); color: #1b1206; font-weight: 600; }
button.accent:hover:not(:disabled) { background: #ec8d3a; border-color: var(--accent-strong); }
button.accent:active:not(:disabled) { background: var(--accent-strong); }
button.quiet { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); }
button.quiet:hover:not(:disabled) { background: var(--panel-3); border-color: transparent; }
button.danger:hover:not(:disabled) { background: var(--bad-tint); color: var(--bad); }
button.block { width: 100%; height: 34px; margin-top: 10px; font-weight: 600; }
button.on { background: var(--accent-tint); border-color: var(--accent-line); color: var(--accent-ink); }
button.on:hover:not(:disabled) { background: #fbe6d1; border-color: var(--accent-line); }
.ic {
  width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
  stroke-linejoin: round; pointer-events: none; /* 누른 곳이 늘 단추가 되게 */
}

/* 용어 도움말 [?]와 뜻 풍선 */
button.help {
  display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; padding: 0;
  margin: 0 0 0 5px; border: 1px solid var(--line-2); border-radius: 50%; background: var(--panel); color: var(--ink-2);
  box-shadow: none; font-size: 10.5px; font-weight: 700; line-height: 1; vertical-align: 1px; cursor: help; flex: none;
}
button.help::before { content: "?"; }
button.help:hover, button.help:focus-visible, button.help[aria-describedby] {
  background: var(--accent-tint); border-color: var(--accent-line); color: var(--accent-ink);
}
#helpTip {
  position: fixed; z-index: 50; max-width: min(320px, calc(100vw - 16px)); padding: 10px 12px; border-radius: 8px;
  background: var(--primary); color: #f1f3f5; box-shadow: var(--sh-2); font-size: 12.5px; line-height: 1.55;
  pointer-events: none;
}
#helpTip b { display: block; margin-bottom: 3px; color: #ffffff; }

/* ---------------------------------------------------------------- 입력 */
input[type=number], input[type=text], input[type=date], select {
  height: var(--h); border: 1px solid var(--line-2); border-radius: var(--r); background: var(--panel); padding: 0 8px;
  min-width: 0; transition: border-color .12s, box-shadow .12s;
}
input[type=number] { width: 84px; font-variant-numeric: tabular-nums; }
input[type=number]:focus, input[type=text]:focus, input[type=date]:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(226, 128, 44, .2); }
/* 바탕색만 바꾼다. background 줄임말은 아래 select 화살표의 반복·위치·크기까지 처음 값으로 되돌려, 작업 중(비활성)
   위 막대 선택 칸에 화살표가 가로로 줄지어 그려진다 */
input:disabled, select:disabled { background-color: var(--panel-3); color: var(--muted); }
select:disabled { cursor: default; }
input[readonly] { background: var(--panel-2); color: var(--ink-2); }
input::placeholder { color: #9aa2ab; }
select {
  appearance: none; padding-right: 26px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e7781' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center; background-size: 14px;
}
input[type=checkbox], input[type=radio], input[type=range] { accent-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: 15px; height: 15px; margin: 0; flex: none; cursor: pointer; }

/* 입력 + 단위 묶음 */
.ig {
  display: inline-flex; align-items: stretch; height: var(--h); border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--panel); overflow: hidden; min-width: 0; transition: border-color .12s, box-shadow .12s;
}
.ig:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(226, 128, 44, .2); }
.ig input { border: 0; border-radius: 0; height: 100%; width: 100%; min-width: 0; box-shadow: none !important; }
.ig .unit {
  display: flex; align-items: center; padding: 0 8px; color: var(--muted); background: var(--panel-2);
  border-left: 1px solid var(--line); font-size: 12px; white-space: nowrap;
}
.ig.small { width: 72px; flex: none; }
.ig select {
  height: 100%; border: 0; border-left: 1px solid var(--line); border-radius: 0; background-color: var(--panel-2);
  color: var(--muted); font-size: 12px; padding: 0 22px 0 8px; background-position: right 5px center; flex: none;
}
.ig select:focus { box-shadow: none; }
.ax {
  display: flex; align-items: center; justify-content: center; width: 24px; flex: none; font-weight: 700; font-size: 11.5px;
  color: #fff;
}
.ax.x { background: var(--ax-x); }
.ax.y { background: var(--ax-y); }
.ax.z { background: var(--ax-z); }
.axissel { width: 58px; flex: none; text-transform: uppercase; font-weight: 600; }

/* ---------------------------------------------------------------- 위 막대 */
.bar {
  display: flex; align-items: center; gap: 8px; padding: 0 12px; min-height: 50px; background: var(--chrome);
  color: var(--chrome-fg); flex-wrap: wrap; border-bottom: 1px solid #111417;
}
.brand { display: flex; align-items: center; gap: 8px; margin-right: 8px; }
.brand b { font-size: 15px; font-weight: 700; letter-spacing: .2px; }
.logo { width: 24px; height: 24px; }
.logo .l1 { fill: var(--accent); }
.logo .l2 { fill: #c7cdd3; }
.logo .l3 { fill: #8f99a3; }
.logo .l0 { fill: #5d6770; }
.ver {
  font-size: 11px; color: var(--chrome-muted); border: 1px solid var(--chrome-line); border-radius: 999px; padding: 0 7px;
  line-height: 18px; font-variant-numeric: tabular-nums;
}
.ver:empty { display: none; }
.tools { display: flex; align-items: center; gap: 6px; }
.bar .sep { background: var(--chrome-line); margin: 12px 4px; }
.bar button:not(.accent) { background: transparent; border-color: transparent; color: var(--chrome-fg); box-shadow: none; }
.bar button:not(.accent):hover:not(:disabled) { background: var(--chrome-2); border-color: var(--chrome-line); }
.bar button:not(.accent):active:not(:disabled) { background: var(--chrome-3); }
.bar button:disabled { opacity: .38; }
.bar button.accent { box-shadow: none; }
.field { display: flex; align-items: center; gap: 7px; color: var(--chrome-muted); font-size: 12px; }
.bar select {
  background-color: var(--chrome-2); border-color: var(--chrome-line); color: var(--chrome-fg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2398a1aa' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
.bar select:hover:not(:disabled) { border-color: #4c545c; }
.bar select:disabled { opacity: .55; }
.bar select option { background: var(--panel); color: var(--ink); }
.machine select { max-width: 340px; }
header.bar button.help { background: transparent; border-color: var(--chrome-line); color: var(--chrome-muted); }
header.bar button.help:hover, header.bar button.help[aria-describedby] {
  background: var(--chrome-2); border-color: var(--chrome-line); color: var(--chrome-fg);
}
.bar { position: relative; }
.bar button.privacy { color: #a6e3bd; }
.bar button.privacy[aria-expanded="true"] { background: var(--chrome-2); border-color: var(--chrome-line); }
.popover {
  position: absolute; right: 12px; top: calc(100% + 6px); width: min(360px, calc(100vw - 24px)); z-index: 30;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line-2); border-radius: 10px; padding: 14px 16px;
  box-shadow: var(--sh-2); font-size: 12.5px; line-height: 1.55;
}
.popover h4 { margin: 0 0 8px; font-size: 13px; }
.popover p { margin: 6px 0 0; color: var(--ink-2); }
.popover .how { background: var(--ok-tint); color: #145c33; border-radius: 7px; padding: 7px 9px; margin-top: 10px; }
.popover .how b { margin-right: 4px; }

/* ---------------------------------------------------------------- 세 칸 */
main { display: grid; grid-template-columns: 264px minmax(0, 1fr) 404px; min-height: 0; }
.panel { background: var(--panel); overflow: auto; min-height: 0; }
#left { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
#right { border-left: 1px solid var(--line); }
.sec { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.sec.grow-sec { flex: 1; border-bottom: 0; display: flex; flex-direction: column; min-height: 120px; }
.sechead { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
h2 {
  font-size: 11.5px; margin: 0; font-weight: 700; color: var(--ink-2); letter-spacing: .4px;
}
.chip {
  font-size: 11px; font-weight: 600; color: var(--ink-2); background: var(--panel-3); border-radius: 999px; padding: 0 7px;
  line-height: 18px; font-variant-numeric: tabular-nums;
}
.chip:empty { display: none; }
.empty {
  margin: 0; padding: 18px 12px; text-align: center; color: var(--muted); border: 1px dashed var(--line-2);
  border-radius: 8px; background: var(--panel-2); font-size: 12.5px;
}
.row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row + .row { margin-top: 8px; }
.form + .row { margin-top: 12px; }
.row.two > button { flex: 1; }
.actions { margin-top: 10px; }

/* 부품 목록 */
#parts { list-style: none; margin: 0; padding: 0; max-height: 38vh; overflow: auto; display: grid; gap: 4px; }
#parts:empty { display: none; }
#parts li {
  display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 0 8px; align-items: start; padding: 7px 9px;
  border: 1px solid transparent; border-radius: 7px; cursor: pointer; transition: background-color .1s;
}
#parts li > .ic { margin-top: 2px; color: var(--muted); width: 18px; height: 18px; }
#parts li:hover { background: var(--panel-2); }
#parts li[aria-selected=true] { background: var(--accent-tint); border-color: var(--accent-line); }
#parts li[aria-selected=true] > .ic { color: var(--accent-strong); }
#parts .name { font-weight: 600; overflow-wrap: anywhere; }
#parts .sub { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
/* 부피: 견적에 쓰는 값이라 크기보다 먼저, 굵게. 닫히지 않은 부품의 근삿값은 경고색 */
.vol { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
#parts .vol { font-size: 12px; margin: 1px 0; }
.vol.approx { color: var(--warn-ink); }
.sechead .total { margin-left: auto; font-size: 11.5px; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tag {
  display: inline-block; font-size: 10.5px; padding: 0 6px; border-radius: 999px; margin-left: 6px; font-weight: 700;
  line-height: 17px; vertical-align: 1px;
}
.tag.bad { background: var(--bad-tint); color: var(--bad); }
.tag.sup { background: #e3edf6; color: #2f5d86; }
#partinfo {
  display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 10px 0 0; font-size: 12px; padding: 9px 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
}
#partinfo:empty { display: none; }
#partinfo dt { color: var(--muted); }
#partinfo dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
#partinfo dd small { display: block; font-size: 11px; font-weight: 400; color: var(--ink-2); }
#partinfo dt.hist, #partinfo dd.hist { grid-column: 1 / -1; text-align: left; }
#partinfo dd.hist ol { margin: 2px 0 0; padding-left: 18px; color: var(--ink-2); }
#partinfo dd.hist li.more { list-style: none; margin-left: -18px; color: var(--muted); }
#log {
  margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--ink-2); overflow: auto; flex: 1;
  max-height: 32vh; min-height: 0;
}
#log li { padding: 4px 0 4px 10px; border-left: 2px solid var(--line); overflow-wrap: anywhere; }
#log li + li { margin-top: 1px; }
#log li.err { color: var(--bad); border-left-color: var(--bad); }
#log li.warn { color: var(--warn); border-left-color: #e8b04a; }
#btnLog { margin-top: 8px; align-self: flex-start; }

/* ---------------------------------------------------------------- 3D 보기 */
#center { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#view { position: relative; flex: 1; min-height: 240px; background: #e4e8ec; overflow: hidden; }
#view canvas { display: block; touch-action: none; }
#dropzone {
  position: absolute; inset: 14px; border: 2px dashed var(--accent); border-radius: 12px; display: flex;
  align-items: center; justify-content: center; font-size: 17px; font-weight: 600; color: var(--accent-ink);
  background: rgba(253, 242, 231, .78); pointer-events: none;
}
#viewbar {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: var(--panel);
  border-top: 1px solid var(--line); flex-wrap: wrap;
}
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r); overflow: hidden; box-shadow: var(--sh-1); }
.seg > button { border: 0; border-radius: 0; box-shadow: none; height: calc(var(--h) - 2px); }
.seg > button + button { border-left: 1px solid var(--line); }
.seg > button.on { border-left-color: var(--accent-line); }
.seg > button.on + button { border-left-color: var(--accent-line); }
#measureInfo { color: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
#measureInfo:empty { display: none; }
#legend { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
#legend label {
  display: flex; gap: 6px; align-items: center; cursor: pointer; padding: 3px 8px 3px 6px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--panel-2); font-variant-numeric: tabular-nums;
}
#legend input { width: 13px; height: 13px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
#view.measuring canvas { cursor: crosshair; }
body[data-busy="1"] #view { cursor: progress; }

/* 3D 보기 위 글자: 측정값(선분 가운데), 끄는 동안 이동량, 조작 안내 */
.mlabel, .tip, .hint { position: absolute; pointer-events: none; font-variant-numeric: tabular-nums; }
.mlabel {
  transform: translate(-50%, -50%); background: rgba(255, 255, 255, .96); border: 1px solid var(--line-2);
  border-radius: 7px; padding: 3px 9px; text-align: center; line-height: 1.3; white-space: nowrap; box-shadow: var(--sh-2);
}
.mlabel b { display: block; font-size: 13px; }
.mlabel .mhead { display: flex; align-items: center; justify-content: center; gap: 6px; }
.mlabel .mhead b { display: inline; }
.mlabel i {
  font-style: normal; font-size: 10.5px; font-weight: 700; color: #fff; background: var(--primary); border-radius: 999px;
  min-width: 16px; height: 16px; line-height: 16px; padding: 0 4px;
}
.mlabel .mclose {
  pointer-events: auto; border: 0; background: transparent; color: var(--muted); padding: 0 2px; font-size: 14px; height: auto;
  line-height: 1; cursor: pointer; box-shadow: none;
}
.mlabel .mclose:hover { color: var(--bad); background: transparent; }
.mlabel span { display: block; font-size: 11px; color: var(--muted); }
.tip {
  background: var(--primary); color: var(--primary-fg); border-radius: 6px; padding: 3px 8px; font-size: 12px;
  white-space: nowrap; box-shadow: var(--sh-2);
}
.hint {
  right: 10px; bottom: 9px; font-size: 11px; line-height: 1.5; color: var(--ink-2); background: rgba(255, 255, 255, .78);
  padding: 3px 9px; border-radius: 6px; max-width: calc(100% - 120px); text-align: right;
}
.hint b { color: var(--ink); font-weight: 600; }
.hud {
  position: absolute; left: 10px; top: 10px; pointer-events: none; max-width: calc(100% - 100px); padding: 6px 11px;
  background: rgba(255, 255, 255, .9); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: var(--sh-1);
  font-variant-numeric: tabular-nums;
}
.hud b { display: block; font-size: 15px; color: var(--ink); }
.hud span { display: block; font-size: 11.5px; color: var(--ink-2); white-space: pre-line; overflow-wrap: anywhere; }
.hud.approx b { color: var(--warn-ink); }

/* ---------------------------------------------------------------- 오른쪽 탭 */
#tabs {
  display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); position: sticky; top: 0; z-index: 2;
  background: var(--panel); border-bottom: 1px solid var(--line); padding: 0 4px;
}
#tabs button {
  flex-direction: column; gap: 4px; height: auto; padding: 10px 2px 9px; border: 0; border-radius: 0; box-shadow: none;
  background: transparent; color: var(--muted); font-size: 11.5px; font-weight: 600; position: relative; white-space: normal;
  line-height: 1.2; text-align: center;
}
#tabs button .ic { width: 18px; height: 18px; }
#tabs button:hover { color: var(--ink); background: var(--panel-2); }
#tabs button.on { color: var(--ink); background: transparent; }
#tabs button.on::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px;
  background: var(--accent);
}
#tabs button.on .ic { color: var(--accent-strong); }
.tab { display: none; padding: 4px 14px 16px; }
.tab.on { display: block; }
.group { padding: 12px 0 14px; }
.group + .group { border-top: 1px solid var(--line); }
h3 {
  font-size: 11.5px; margin: 0 0 10px; font-weight: 700; color: var(--ink-2); letter-spacing: .4px;
}
.note { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.form {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 200px); gap: 8px 12px; align-items: center;
}
.form + .form, .xyz + .form { margin-top: 10px; }
.form > label, .form > .lab { color: var(--ink-2); }
.form small, .check small { display: block; color: var(--muted); font-size: 11px; line-height: 1.3; }
.form > .ig, .form > select, .form > input[type=text], .form > input[type=date] { width: 100%; }
.form .wide { grid-column: 1 / -1; }
.form > .val { color: var(--ink); text-align: right; overflow-wrap: anywhere; }
.form > .note.wide { margin: -2px 0 0; }
.ig.dims input { flex: 1 1 0; text-align: center; }
.ig.dims input:disabled { background: transparent; }
.ig.dims:has(input:disabled) { background: var(--panel-3); }
.ig .times { display: flex; align-items: center; color: var(--muted); padding: 0 2px; }
.eq { color: var(--muted); }
.check { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; color: var(--ink-2); }
.check input { margin-top: 2px; }
.xyz { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.xyz .ig { width: 100%; }
.choice { display: grid; gap: 6px; margin-top: 12px; }
.choice label {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 8px;
  cursor: pointer; color: var(--ink-2); transition: border-color .12s, background-color .12s;
}
.choice label:hover { background: var(--panel-2); }
.choice label:has(input:checked) { border-color: var(--accent-line); background: var(--accent-tint); color: var(--ink); }

/* 결과 */
.result:empty { display: none; }
.result {
  margin-top: 6px; border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--panel);
  box-shadow: var(--sh-1);
}
.result.stale > :not(.stalenote) { opacity: .5; }
.result p { margin: 6px 0; }
.rhead { margin: 0 0 6px; overflow-wrap: anywhere; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  line-height: 20px;
}
.badge.ok { background: var(--ok-tint); color: var(--ok); }
.badge.bad { background: var(--bad-tint); color: var(--bad); }
.badge.warn { background: var(--warn-tint); color: var(--warn-ink); }
.badge.info { background: var(--panel-2); color: var(--muted); }
table.dg th, table.dg td { text-align: left; }
table.dg td:nth-child(3) { white-space: nowrap; }
table.dg tr.sub td { color: var(--ink-2); font-size: 11.5px; padding-top: 0; }
table.dg tr:not(.sub) td { border-bottom: 0; }
table { border-collapse: collapse; width: 100%; font-size: 12px; margin-top: 8px; }
th, td { padding: 5px 6px; text-align: right; font-variant-numeric: tabular-nums; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { text-align: left; }
th {
  font-weight: 600; color: var(--muted); white-space: nowrap; font-size: 11px; background: var(--panel-2);
  border-bottom-color: var(--line-2);
}
tbody tr:hover td, table tr:hover td { background: #fafbfc; }
td.bad { color: var(--bad); font-weight: 700; }
tr.total td { font-weight: 700; border-top: 1px solid var(--line-2); }
.tipbox {
  margin: 8px 0; padding: 9px 11px; border-radius: 8px; background: var(--warn-tint); border: 1px solid #f0d9a8;
  display: grid; gap: 8px; justify-items: start;
}
.tipbox p { margin: 0; color: #6b4a00; font-size: 12px; }
ul.msgs { margin: 6px 0 0; padding-left: 18px; }
ul.msgs li { margin: 3px 0; }
li.warn, p.warn { color: var(--warn); }
.err { color: var(--bad); font-weight: 600; }
#sliceBox { margin-top: 12px; }
#slice2d {
  width: 100%; height: 300px; background: #fff; border: 1px solid var(--line); border-radius: 8px; margin-top: 8px;
}
#layerSlider { width: 100%; }

/* 3D 보기 오른쪽 층 보기 막대: 위가 마지막 층. 고른 층 번호와 높이는 위 칸에 */
#layerBar {
  position: absolute; right: 12px; top: 12px; bottom: 58px; width: 64px; display: flex; flex-direction: column;
  align-items: center; gap: 6px; padding: 8px 4px; background: rgba(255, 255, 255, .92); border: 1px solid var(--line-2);
  border-radius: 10px; box-shadow: var(--sh-2); font-variant-numeric: tabular-nums;
}
#layerBar[hidden] { display: none; }
.lb-now { text-align: center; line-height: 1.25; }
.lb-now b { display: block; font-size: 14px; color: var(--accent-ink); }
.lb-now span { display: block; font-size: 10.5px; color: var(--ink-2); white-space: nowrap; }
#layerRange { flex: 1; min-height: 60px; width: 22px; margin: 0; writing-mode: vertical-lr; direction: rtl; cursor: ns-resize; }
.lb-end { font-size: 10.5px; color: var(--muted); display: flex; align-items: center; gap: 2px; }

/* ---------------------------------------------------------------- 아래 알림 줄 */
#status {
  display: flex; align-items: center; gap: 8px; padding: 0 14px; background: var(--panel-2);
  border-top: 1px solid var(--line); min-height: 30px; font-size: 12.5px; color: var(--ink-2);
}
#status::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: #9aa3ab; flex: none;
}
body[data-busy="1"] #status::before { display: none; }
#status.err::before { background: var(--bad); }
#status.warn::before { background: #e8a33a; }
#status.err #msg { color: var(--bad); font-weight: 600; }
#status.warn #msg { color: var(--warn); }
#spinner {
  width: 13px; height: 13px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite; flex: none;
}
/* 진행률 막대(작업 중에만): 막대 + 퍼센트. 단계 이름·지난 시간은 옆 알림 글자에 */
#prog { display: inline-flex; align-items: center; gap: 7px; flex: none; }
#prog .track { width: 150px; height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
#progFill { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .25s linear; }
#progPct { min-width: 3.2em; color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
#progTime { color: var(--muted); font-variant-numeric: tabular-nums; }
body[data-busy="0"] #progTime { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  #spinner { animation-duration: 2s; }
}

@media (max-width: 1100px) {
  main { grid-template-columns: 232px minmax(0, 1fr); }
  #right { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); max-height: none; }
  body { grid-template-rows: auto auto auto; height: auto; }
  #center { min-height: 60vh; }
}
@media (max-width: 700px) {
  main { grid-template-columns: minmax(0, 1fr); }
  #left { border-right: 0; border-bottom: 1px solid var(--line); }
  #center { min-height: 55vh; }
  .hint { display: none; }
}
