/* NaviWorks Web — Navisworks-style UI */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root,
html[data-theme="midnight"] {
  color-scheme: dark;
  --app-bg: #0e151d; --surface: #151f29; --surface-raised: #1c2935; --surface-inset: #0b1118;
  --surface-soft: #22313e; --border: #334656; --text: #e4edf4; --text-muted: #91a5b5;
  --accent: #4db6ff; --accent-strong: #218fd3; --selection: #183f5c; --hover: #20384a;
  --canvas-bg: #0b1118; --canvas-user-bg: var(--canvas-bg); --overlay: rgba(5,10,15,.78);
  --title-bg: linear-gradient(#17232e,#101820); --on-accent: #fff;
  --success: #86c65a; --danger: #ef6670; --warning: #ffb454;
  --nw-green: var(--success); --nw-green-dark: #70ad48; --nw-bg: var(--app-bg); --nw-panel: var(--surface);
  --nw-border: var(--border); --nw-text: var(--text); --nw-ribbon-bg: var(--surface-raised);
  --nw-accent: var(--accent); --nw-sel: var(--selection);
}
html[data-theme="blueprint"] {
  color-scheme: dark;
  --app-bg:#061c31; --surface:#0b2b48; --surface-raised:#103858; --surface-inset:#082744;
  --surface-soft:#164566; --border:#276184; --text:#e5f5ff; --text-muted:#99c5df;
  --accent:#6bd7ff; --accent-strong:#25a9dc; --selection:#15557b; --hover:#16486b;
  --canvas-bg:#082744; --overlay:rgba(3,20,36,.8); --title-bg:linear-gradient(#0c3557,#07243e);
  --success:#72dc96; --danger:#ff7580; --warning:#ffd166; --nw-green-dark:#62c887;
}
html[data-theme="graphite"] {
  color-scheme: dark;
  --app-bg:#191b1e; --surface:#24272b; --surface-raised:#2d3136; --surface-inset:#202225;
  --surface-soft:#353a40; --border:#4b5158; --text:#eef0f2; --text-muted:#adb3ba;
  --accent:#72b7ff; --accent-strong:#4a94dc; --selection:#374e66; --hover:#353f49;
  --canvas-bg:#202225; --overlay:rgba(13,14,16,.8); --title-bg:linear-gradient(#33373c,#25282c);
  --success:#88c966; --danger:#ee6d77; --warning:#f5b85b; --nw-green-dark:#73ae55;
}
html[data-theme="solar"] {
  color-scheme: dark;
  --app-bg:#0e171e; --surface:#17242d; --surface-raised:#21313b; --surface-inset:#101a22;
  --surface-soft:#2b3c47; --border:#465863; --text:#fff3d2; --text-muted:#c6b98f;
  --accent:#ffbd55; --accent-strong:#db8a20; --selection:#62471d; --hover:#463b28;
  --canvas-bg:#101a22; --overlay:rgba(12,15,16,.8); --title-bg:linear-gradient(#2e342d,#1b2524);
  --success:#96c765; --danger:#ef6c72; --warning:#ffbd55; --nw-green-dark:#7aaa50;
}
html[data-theme="light"] {
  color-scheme: light;
  --app-bg:#dfe7ec; --surface:#f7fafc; --surface-raised:#ffffff; --surface-inset:#e7eef3;
  --surface-soft:#edf3f6; --border:#aebdc7; --text:#1f303c; --text-muted:#5d7180;
  --accent:#087fca; --accent-strong:#0566a4; --selection:#c9e7f8; --hover:#e0eff7;
  --canvas-bg:#e7eef3; --overlay:rgba(245,249,252,.82); --title-bg:linear-gradient(#405361,#2f404d);
  --success:#4e8f2d; --danger:#bd3743; --warning:#b86a0c; --nw-green-dark:#447d29;
}
html, body { height: 100%; overflow: hidden; font-family: 'Segoe UI', 'Malgun Gothic', sans-serif; font-size: 13px; color: var(--nw-text); background: var(--nw-bg); }
body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
/* 헤더(리본)와 상태바는 절대 찌그러지면 안 되는 고정 영역.
   flex-shrink:0 이 없으면 세로가 좁아질 때 flexbox가 리본/상태바를
   강제로 축소해 버튼이 잘리거나 겹친다(배치 붕괴의 근본 원인). */
#app-header { flex: 0 0 auto; }
#status-bar { flex: 0 0 auto; }

/* ── Title bar ── */
#title-bar { display: flex; align-items: center; gap: 14px; background: var(--title-bg); color: var(--text); padding: 5px 12px; font-size: 12px; }
#title-bar .logo { font-size: 14px; color: var(--nw-green); }
#title-bar .logo b { color: #fff; }
#current-file-name { color: var(--text-muted); font-style: italic; }
.title-right { margin-left: auto; color: var(--text-muted); font-size: 11px; display: flex; align-items: center; gap: 10px; }
.app-switch-link { color: #cfe6f7; text-decoration: none; padding: 3px 9px; border-radius: 5px; background: rgba(255,255,255,.08); font-size: 11px; transition: .15s; }
.app-switch-link:hover { background: var(--nw-accent); color: #fff; }

/* ── Ribbon ── */
#ribbon-tabs { display: flex; background: var(--surface-soft); border-bottom: 1px solid var(--nw-border); padding: 0 8px; }
.ribbon-tab { border: none; background: transparent; padding: 6px 18px; font-size: 13px; cursor: pointer; color: var(--text); border-bottom: 2px solid transparent; }
.ribbon-tab:hover { background: var(--hover); }
.ribbon-tab.active { background: var(--nw-ribbon-bg); border-bottom-color: var(--nw-green); font-weight: 600; }

#ribbon-content { background: var(--nw-ribbon-bg); border-bottom: 1px solid var(--nw-border); min-height: 92px; overflow-x: auto; overflow-y: hidden; }
.ribbon-panel { display: none; padding: 4px 8px; }
.ribbon-panel.active { display: flex; gap: 4px; }
.ribbon-group { display: flex; flex-direction: column; border-right: 1px solid var(--border); padding: 0 10px; }
.ribbon-group-items { display: flex; gap: 3px; align-items: center; flex: 1; }
.ribbon-group-label { text-align: center; font-size: 10px; color: var(--text-muted); padding: 3px 0 2px; }

.rbtn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 52px; padding: 6px 8px; border: 1px solid transparent; border-radius: 3px; background: transparent; cursor: pointer; font-size: 11px; color: var(--text); }
.rbtn i { font-size: 16px; color: var(--success); }
.rbtn.big { min-width: 64px; padding: 8px 10px; }
.rbtn.big i { font-size: 22px; }
.rbtn:hover { background: var(--hover); border-color: var(--accent); }
.rbtn.active, .rbtn.toggle.active { background: var(--nw-sel); border-color: var(--nw-accent); }
.chk { display: flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 6px; cursor: pointer; }
.section-controls { flex-direction: column; align-items: flex-start; }
#sec-slider { width: 130px; }

/* ── Workspace layout ── */
#workspace { flex: 1; display: flex; min-height: 0; }
#left-panel { width: 250px; background: var(--nw-panel); border-right: 1px solid var(--nw-border); display: flex; flex-direction: column; }
#right-panel { width: 260px; background: var(--nw-panel); border-left: 1px solid var(--nw-border); display: flex; flex-direction: column; }
.panel-tabs { display: flex; background: var(--surface-soft); border-bottom: 1px solid var(--nw-border); }
.ptab { flex: 1; border: none; background: transparent; padding: 6px 4px; font-size: 11px; cursor: pointer; color: var(--text-muted); border-bottom: 2px solid transparent; }
.ptab.active { background: var(--nw-panel); border-bottom-color: var(--nw-green); font-weight: 600; }
.panel-body { flex: 1; overflow: auto; display: none; padding: 4px; }
.panel-body.active { display: block; }

/* ── Tree ── */
.tree-root, .tree-root ul { list-style: none; }
.tree-root ul { padding-left: 16px; }
.tree-node { display: flex; align-items: center; gap: 5px; padding: 2px 4px; border-radius: 2px; cursor: pointer; white-space: nowrap; font-size: 12px; }
.tree-node:hover { background: var(--hover); }
.tree-node.selected { background: var(--nw-sel); }
.tree-node.hidden-node { color: #aaa; text-decoration: line-through; }
.tree-node .caret { width: 12px; text-align: center; font-size: 9px; color: #777; }
.tree-node .ticon { color: #b08c3e; font-size: 11px; }
.tree-node .ticon.geom { color: #4d7a1f; }
.tree-empty, .prop-empty { color: #999; font-size: 12px; padding: 10px; text-align: center; }
.tree-children.collapsed { display: none; }

/* ── Viewpoint / clash lists ── */
#vp-list, #clash-list { list-style: none; }
#vp-list li, #clash-list li { padding: 6px 8px; border-bottom: 1px solid #eee; cursor: pointer; font-size: 12px; display: flex; align-items: center; gap: 6px; }
#vp-list li:hover, #clash-list li:hover { background: var(--hover); }
#vp-list li i { color: var(--nw-accent); }
#vp-list .vp-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#vp-list .vp-del { border: none; background: none; color: #b55; cursor: pointer; padding: 2px 5px; border-radius: 4px; opacity: 0; transition: opacity .15s; }
#vp-list .vp-item:hover .vp-del { opacity: 1; }
#vp-list .vp-del:hover { background: rgba(200,50,50,.12); }
#clash-list li i { color: #d33; }
.clash-summary { padding: 8px; font-size: 12px; color: #666; border-bottom: 1px solid #eee; }
.clash-summary.has-clash { color: #c22; font-weight: 600; }
/* [P1] 근사 소스 포함 시 간섭 검사 불완전 경고 — 클릭 대상 아님, 항상 최상단 */
#clash-list li.clash-incomplete-warn {
  cursor: default; background: #fff3cd; color: #7a5b00;
  border-left: 3px solid #e0a800; font-weight: 600; line-height: 1.5;
}
#clash-list li.clash-incomplete-warn:hover { background: #fff3cd; }
.clash-opts { padding: 8px; border-bottom: 1px solid #eee; display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: #444; }
.clash-opt { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.clash-tol-row { gap: 8px; }
.clash-tol-input { width: 72px; padding: 2px 4px; font-size: 12px; border: 1px solid #ccc; border-radius: 3px; }

/* ── Viewport ── */
#viewport-container { flex: 1; position: relative; min-width: 0; background: var(--canvas-user-bg, var(--canvas-bg)); }
/* 캔버스는 문서 탭바(34px)만큼 위에서 밀려나야 탭바에 가려지지 않는다.
   <canvas>는 padding이 적용되지 않으므로 top/height 를 직접 보정한다. */
#viewport { position: absolute; left: 0; right: 0;
  top: var(--doc-tabs-h, 0px);
  height: calc(100% - var(--doc-tabs-h, 0px));
  width: auto; display: block; }
#drop-overlay { position: absolute; left: 0; right: 0; bottom: 0; top: var(--doc-tabs-h, 0px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #7a8fa0; pointer-events: none; opacity: 1; transition: opacity .3s; }
#drop-overlay.hidden { opacity: 0; }
#drop-overlay i { font-size: 56px; }
#drop-overlay p { font-size: 17px; }
#drop-overlay small { font-size: 11px; color: #9ab0c0; }
#drop-overlay.dragging { background: rgba(134,185,63,.15); color: var(--nw-green-dark); opacity: 1; }

#progress-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: var(--overlay); color: var(--text); z-index: 20; }
#progress-overlay.hidden { display: none; }
.spinner { width: 42px; height: 42px; border: 4px solid #ccc; border-top-color: var(--nw-green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#measure-hint { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: rgba(30,136,199,.92); color: #fff; padding: 5px 14px; border-radius: 4px; font-size: 12px; z-index: 15; }
#measure-hint.hidden { display: none; }

/* ── Properties ── */
#prop-table { width: 100%; border-collapse: collapse; font-size: 12px; }
#prop-table td { padding: 4px 6px; border-bottom: 1px solid #eee; word-break: break-all; }
#prop-table td:first-child { color: #666; width: 42%; background: #f5f5f5; }
.prop-cat td { background: #e5edda !important; font-weight: 600; color: #4d6b28 !important; }

/* ── Status bar ── */
#status-bar { display: flex; gap: 18px; align-items: center; min-width: 0; background: var(--surface-soft); border-top: 1px solid var(--nw-border); padding: 3px 12px; font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; }
#status-bar > span { flex: 0 0 auto; }
#status-bar .grow { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; text-align: center; color: var(--nw-green-dark); }

/* ── Tree node actions (visibility / delete) ── */
.tree-node .tlabel { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.tree-node .ticon.line { color: #2f6fb0; }
.tree-node.node-hidden { color: #b0b0b0; }
.tree-node.node-hidden .tlabel { text-decoration: line-through; }
.tree-actions { display: none; gap: 2px; margin-left: auto; }
.tree-node:hover .tree-actions { display: flex; }
.tree-act { border: none; background: transparent; cursor: pointer; padding: 2px 4px; border-radius: 3px; font-size: 11px; color: #778; }
.tree-act:hover { background: #dbe6f2; color: #345; }
.tree-act.del:hover { background: #f6d6d6; color: #c22; }

/* ── Color / opacity ribbon controls ── */
.color-controls, .opacity-controls { flex-direction: column; align-items: flex-start; gap: 6px; }
.color-pick { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; cursor: pointer; padding: 4px 6px; border: 1px solid #cde0ae; border-radius: 3px; background: #fff; }
.color-pick i { color: #4d7a1f; font-size: 14px; }
.color-pick input[type=color] { width: 28px; height: 22px; border: none; background: none; cursor: pointer; padding: 0; }
.slider-label { display: flex; align-items: center; gap: 6px; font-size: 11px; color: #444; white-space: nowrap; }
.slider-label i { color: #4d7a1f; }
.slider-label input[type=range] { width: 96px; }

/* ── ViewCube ── */
#viewcube-wrap { position: absolute; top: 12px; right: 12px; z-index: 12; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.viewcube-canvas { cursor: pointer; filter: drop-shadow(0 2px 5px rgba(0,0,0,.25)); }
#vc-home { width: 30px; height: 26px; border: 1px solid #aab; background: rgba(255,255,255,.9); border-radius: 4px; cursor: pointer; color: #456; font-size: 12px; }
#vc-home:hover { background: var(--nw-sel); }

#nav-axis { position: absolute; bottom: 14px; right: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; z-index: 10; }
#nav-axis button { width: 34px; height: 28px; border: 1px solid #aab; background: rgba(255,255,255,.85); border-radius: 3px; cursor: pointer; font-size: 11px; font-weight: 600; color: #456; }
#nav-axis button:hover { background: var(--nw-sel); }

/* ── Icon picker modal ── */
#icon-modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 100; }
#icon-modal.hidden { display: none; }
.icon-modal-box { background: #fff; border-radius: 8px; width: 340px; max-width: 90vw; box-shadow: 0 10px 40px rgba(0,0,0,.3); overflow: hidden; }
.icon-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: #f3f6f9; border-bottom: 1px solid var(--nw-border); font-weight: 600; color: #345; }
.icon-modal-head button { border: none; background: transparent; cursor: pointer; font-size: 16px; color: #789; }
.icon-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; padding: 14px; }
.icon-grid button { aspect-ratio: 1; border: 1px solid #dde; background: #fafcff; border-radius: 5px; cursor: pointer; font-size: 18px; color: #4d7a1f; display: flex; align-items: center; justify-content: center; }
.icon-grid button:hover { background: var(--nw-sel); border-color: var(--nw-accent); }

/* dark bg mode */
body.dark-viewport #viewport-container { --canvas-user-bg: #10161d; }

/* ── 내보내기 컨트롤 ── */
.export-controls { display: flex; align-items: center; gap: 6px; }
.export-controls select {
  height: 30px; border: 1px solid #b9c6d2; border-radius: 5px;
  background: #fff; font-size: 12px; padding: 0 6px; max-width: 170px;
}
/* 2D 모드에서 상태바 강조 */
#st-mode { color: #2b6cb0; font-weight: 600; }

/* ── 문서 탭바 (ABViewer 멀티 문서) ──
   viewport-container 최상단에 고정 배치되므로, 탭바가 나타나면
   나머지 오버레이(ViewCube/측정힌트/드롭안내 등)를 겹치지 않게
   아래로 밀어내기 위해 컨테이너에 --doc-tabs-h 만큼 padding-top 부여. */
#viewport-container { --doc-tabs-h: 0px; }
#viewport-container.has-doc-tabs { --doc-tabs-h: 34px; }
#doc-tabs {
  position: absolute; top: 0; left: 0; right: 0; z-index: 15; height: 34px;
  display: flex; gap: 2px; padding: 4px 6px 0;
  background: linear-gradient(var(--surface-raised), var(--surface-soft));
  border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: thin;
}
#doc-tabs.hidden { display: none; }
/* 탭바 아래로 밀려나야 하는 오버레이 요소들 */
#viewcube-wrap { top: calc(12px + var(--doc-tabs-h)); }
#measure-hint { top: calc(10px + var(--doc-tabs-h)); }
.doc-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; font-size: 12px; border: 1px solid #c3ccd4; border-bottom: none;
  border-radius: 6px 6px 0 0; background: var(--surface-soft); color: var(--text-muted); cursor: pointer;
  white-space: nowrap; max-width: 220px;
}
.doc-tab span { overflow: hidden; text-overflow: ellipsis; }
.doc-tab.doc-visible { background: var(--surface-raised); color: var(--text); font-weight: 600; }
.doc-tab.doc-all { background: #86b93f; color: #fff; font-weight: 700; }
.doc-tab .doc-close { opacity: .55; padding: 2px; border-radius: 3px; }
.doc-tab .doc-close:hover { opacity: 1; background: #e05252; color: #fff; }

/* ── 레이어 패널 ── */
#layer-list { list-style: none; margin: 0; padding: 4px; }
.layer-item {
  display: flex; align-items: center; gap: 7px; padding: 5px 8px;
  border-radius: 5px; font-size: 12.5px; cursor: default;
}
.layer-item:hover { background: var(--hover); }
.layer-item.layer-off .layer-name { opacity: .45; text-decoration: line-through; }
.layer-swatch { width: 13px; height: 13px; border-radius: 3px; border: 1px solid rgba(0,0,0,.25); flex: none; }
.layer-name { cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-name:hover { color: #2470b8; text-decoration: underline; }

/* ── 찾기 그룹 ── */
.find-controls { display: flex; align-items: center; gap: 6px; }
.find-controls input[type=text] {
  width: 170px; padding: 6px 9px; font-size: 12.5px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface-inset); color: var(--text);
}

/* ── 분해도 슬라이더 ── */
.explode-controls .slider-label { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #45525e; }
.explode-controls input[type=range] { width: 130px; }

/* ── Model Info 패널 ── */
.minfo-toolbar { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid #dfe6ec; }
.minfo-toolbar button {
  padding: 6px 12px; font-size: 12.5px; border: none; border-radius: 6px;
  background: #4a90d9; color: #fff; font-weight: 700; cursor: pointer;
}
.minfo-toolbar button:hover { background: #2470b8; }
.minfo-toolbar select {
  flex: 1; min-width: 0; font-size: 12px; padding: 4px 6px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface-inset); color: var(--text);
}
#minfo-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
#minfo-table td { padding: 6px 10px; border-bottom: 1px solid #edf1f5; }
#minfo-table .prop-key { color: #5c6b78; width: 46%; }
#minfo-table .prop-val { font-weight: 600; color: #1d2b38; word-break: break-all; }

/* ══════════════════════════════════════════════════════════
   모바일 반응형 (≤768px) — 데스크톱 요소는 기본 숨김
   ══════════════════════════════════════════════════════════ */
#mobile-topbar { display: none; }
#mobile-convert-bar { display: none; }

@media (max-width: 768px) {
  html, body { font-size: 14px; }

  /* 모바일 상단 앱바 */
  #mobile-topbar {
    display: flex; align-items: center; gap: 10px;
    flex: 0 0 auto; height: 48px; padding: 0 10px;
    background: var(--title-bg); color: var(--text);
  }
  #mobile-topbar .m-title { flex: 1; text-align: center; font-size: 15px; color: var(--nw-green); }
  #mobile-topbar .m-title b { color: #fff; }
  #mobile-topbar button {
    width: 40px; height: 40px; border: none; background: rgba(255,255,255,.1);
    color: #cfe6f7; border-radius: 8px; font-size: 17px; cursor: pointer;
  }
  #mobile-topbar button:active { background: var(--nw-accent); color: #fff; }

  /* 데스크톱 타이틀바는 숨기고 리본은 가로 스크롤로 유지 */
  #title-bar { display: none; }
  #app-header { flex: 0 0 auto; }
  #ribbon-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 0 4px; }
  .ribbon-tab { padding: 8px 14px; white-space: nowrap; flex: none; }
  #ribbon-content { min-height: 76px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .ribbon-panel.active { flex-wrap: nowrap; }
  .ribbon-group { flex: none; }
  /* 터치 타겟 확대 */
  .rbtn { min-width: 56px; min-height: 48px; }
  .rbtn.big { min-width: 62px; }

  /* 워크스페이스: 좌/우 패널을 오버레이 드로어로 전환 */
  #workspace { position: relative; }
  #left-panel, #right-panel {
    position: absolute; top: 0; bottom: 0; z-index: 60;
    width: 82%; max-width: 320px;
    box-shadow: 0 0 24px rgba(0,0,0,.35);
    transition: transform .25s ease;
  }
  #left-panel { left: 0; transform: translateX(-102%); }
  #right-panel { right: 0; transform: translateX(102%); }
  #left-panel.m-open { transform: translateX(0); }
  #right-panel.m-open { transform: translateX(0); }
  /* 드로어 열림 시 딤 배경 */
  #workspace.m-drawer::after {
    content: ''; position: absolute; inset: 0; z-index: 55;
    background: color-mix(in srgb, var(--app-bg) 76%, transparent);
  }
  /* 뷰포트는 항상 전체 폭 */
  #viewport-container { flex: 1 1 100%; min-width: 0; }

  /* ViewCube/네비축은 모바일에서 작게, 겹침 방지 */
  #viewcube-wrap { transform: scale(.8); transform-origin: top right; }
  #nav-axis { bottom: 76px; }

  /* 모바일 파일 변환 바 (하단 고정 영역) */
  #mobile-convert-bar {
    display: flex; align-items: center; gap: 8px;
    flex: 0 0 auto; padding: 10px; min-height: 64px;
    background: var(--surface-raised); border-top: 1px solid var(--nw-border);
  }
  #mobile-convert-bar .m-cbtn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 44px; padding: 0 12px; border: none; border-radius: 10px;
    font-size: 14px; font-weight: 700; cursor: pointer; white-space: nowrap;
  }
  #mobile-convert-bar .m-cbtn.primary { background: var(--nw-green); color: #fff; }
  #mobile-convert-bar .m-cbtn.accent { background: var(--nw-accent); color: #fff; }
  #mobile-convert-bar .m-cbtn:active { filter: brightness(.9); }
  #mobile-convert-bar .m-cbtn:disabled { opacity: .45; }
  #mobile-convert-bar select {
    flex: 1; min-width: 0; height: 44px; padding: 0 8px;
    border: 1px solid var(--border); border-radius: 10px; background: var(--surface-inset); color: var(--text); font-size: 14px;
  }

  /* 상태바는 모바일에서 핵심 정보만 */
  #status-bar { gap: 10px; font-size: 11px; }
  #st-fps, #st-tris { display: none; }
}

/* 초소형 화면(≤420px): 변환 바 라벨 축약 */
@media (max-width: 420px) {
  #mobile-convert-bar .m-cbtn span.lbl { display: none; }
}

@media (max-height: 620px) {
  #ribbon-content { min-height: 64px; }
  .rbtn, .rbtn.big { min-height: 40px; padding-block: 3px; }
  .rbtn i, .rbtn.big i { font-size: 15px; }
  .ribbon-group-label { display: none; }
  #mobile-convert-bar { min-height: 52px; padding-block: 4px; }
  #mobile-convert-bar .m-cbtn, #mobile-convert-bar select { height: 40px; }
}

/* ── 샘플 다운로드 모달 ── */
#samples-modal { position: fixed; inset: 0; background: color-mix(in srgb, var(--app-bg) 76%, transparent); display: flex; align-items: center; justify-content: center; z-index: 110; }
#samples-modal.hidden { display: none; }
.samples-box { background: #fff; border-radius: 10px; width: 480px; max-width: 92vw; max-height: 84vh; overflow: auto; box-shadow: 0 12px 44px rgba(0,0,0,.32); }
.samples-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: #f3f6f9; border-bottom: 1px solid var(--nw-border); font-weight: 700; color: #2a3a48; }
.samples-head button { border: none; background: transparent; cursor: pointer; font-size: 17px; color: #789; }
.samples-hint { padding: 10px 16px 4px; font-size: 12.5px; color: #667; }
.samples-list { list-style: none; padding: 8px 12px 16px; margin: 0; }
.samples-list li { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-bottom: 1px solid #eef1f4; }
.samples-list .s-fmt { flex: none; width: 66px; font-weight: 700; color: var(--nw-green-dark); font-size: 13px; }
.samples-list .s-desc { flex: 1; font-size: 12px; color: #556; }
.samples-list .s-dl { flex: none; background: var(--nw-accent); color: #fff; text-decoration: none; padding: 7px 14px; border-radius: 7px; font-size: 12.5px; font-weight: 600; }
.samples-list .s-dl:hover { background: #1668a0; }

/* ── 전역 숨김 클래스 & 모달 오버레이 강제 (화면 가림 방지) ── */
.hidden, [hidden] {
  display: none !important;
}

#scan-modal, #drawing-modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 24, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
#scan-modal.hidden, #drawing-modal.hidden {
  display: none !important;
}

.conversion-modal { position: fixed; inset: 0; z-index: 1200; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(15,23,32,.68); }
.conversion-modal.hidden { display: none; }
.conversion-box { width: min(920px, 96vw); max-height: 92vh; overflow: auto; border-radius: 14px; background: #f7f9fb; box-shadow: 0 24px 80px rgba(0,0,0,.42); }
.conversion-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 20px 24px; color: #fff; background: linear-gradient(135deg,#263746,#16232e); }
.conversion-head h2 { margin: 0 0 5px; font-size: 20px; }
.conversion-head h2 i { margin-right: 8px; color: #a8d363; }
.conversion-head p { margin: 0; color: #c4d1dc; font-size: 12.5px; }
.conversion-head button { flex: none; width: 36px; height: 36px; border: 0; border-radius: 8px; color: #dbe5ec; background: rgba(255,255,255,.1); cursor: pointer; }
.conversion-status { display: flex; gap: 9px; align-items: center; padding: 10px 24px; font-weight: 700; font-size: 12.5px; border-bottom: 1px solid #dce3e9; }
.conversion-status.ready { color: #35671d; background: #eaf5df; }
.conversion-status.blocked { color: #924229; background: #fff0e9; }
.conversion-source-section { display: flex; gap: 14px; align-items: center; padding: 18px 24px; background: #fff; border-bottom: 1px solid #dce3e9; }
.conversion-file-button, .conversion-actions button { border: 0; border-radius: 8px; padding: 10px 14px; font-weight: 700; cursor: pointer; }
.conversion-file-button { flex: none; color: #fff; background: #426d24; }
.conversion-source-summary { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.conversion-source-summary strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #1f2d38; }
.conversion-source-summary small { color: #667784; }
.conversion-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 16px 24px 6px; }
.conversion-grid section, .conversion-policy { border: 1px solid #dce3e9; border-radius: 10px; background: #fff; overflow: hidden; }
.conversion-grid h3, .conversion-policy h3 { margin: 0; padding: 10px 13px; color: #354654; font-size: 13px; background: #edf2f5; border-bottom: 1px solid #dce3e9; }
.conversion-pipeline { list-style: none; margin: 0; padding: 8px 12px; }
.conversion-pipeline li { display: flex; align-items: center; gap: 9px; padding: 6px 2px; color: #455865; font-size: 12px; }
.conversion-pipeline li b { display: grid; place-items: center; flex: none; width: 21px; height: 21px; border-radius: 50%; color: #fff; background: #5b7e3b; font-size: 10px; }
.conversion-pipeline li.blocked { color: #a13c2b; }
.conversion-pipeline li.blocked b { background: #c65b45; }
.conversion-preservation { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px; }
.preserve-chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 7px; border-radius: 6px; font-size: 11px; border: 1px solid; }
.preserve-chip.ok { color: #315c24; background: #eff8ea; border-color: #c7dfba; }
.preserve-chip.loss { color: #97402f; background: #fff0ec; border-color: #efc6bc; }
.conversion-policy { margin: 10px 24px; }
.conversion-policy ul { margin: 0; padding: 9px 14px 12px 30px; max-height: 150px; overflow: auto; font-size: 12px; color: #596a76; }
.conversion-policy li { margin: 5px 0; }
.conversion-policy li.error { color: #a23428; font-weight: 700; }
.conversion-policy li.warn { color: #8a5b13; }
.conversion-policy li.ok { color: #2c6a25; }
.conversion-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 24px 20px; }
.conversion-actions p { flex: 1; margin: 0; color: #667784; font-size: 11.5px; }
.conversion-actions button { color: #344956; background: #dfe7ec; }
.conversion-actions button.primary { color: #fff; background: #447b25; }
.conversion-actions button:disabled { opacity: .45; cursor: not-allowed; }

@media (max-width: 768px) {
  .conversion-modal { align-items: stretch; padding: 0; }
  .conversion-box { width: 100%; max-height: 100vh; max-height: 100dvh; border-radius: 0; }
  .conversion-head { padding: 16px; }
  .conversion-source-section { align-items: stretch; flex-direction: column; padding: 14px 16px; }
  .conversion-grid { grid-template-columns: 1fr; padding: 12px 16px 4px; }
  .conversion-policy { margin: 8px 16px; }
  .conversion-actions { align-items: stretch; flex-direction: column; padding: 12px 16px 18px; }
  .conversion-actions p { margin-bottom: 4px; }
  .conversion-actions button { min-height: 44px; }
}
