/* SolidAxis 3D Viewer — giao diện kiểu SolidWorks, theme sáng / tối */
:root {
  --ui-bg: #eef0f3;
  --ui-panel: #f7f8fa;
  --ui-panel-2: #ffffff;
  --ui-bar: linear-gradient(#fbfbfc, #eceef2);
  --ui-border: #c9ced6;
  --ui-border-soft: #dde1e7;
  --ui-text: #1f2733;
  --ui-muted: #6a7482;
  --hover: #e5ecf7;
  --hover-border: #b9cbe8;
  --accent: #2563eb;
  --accent-soft: #dbe7fd;
  --accent-border: #93b4ef;
  --brand: #d52b1e;
  --status: #e4e7ec;
  --tree-w: 260px;
  --pm-w: 300px;
  --vp-top: #b4c2d4;
  --vp-bottom: #eef1f5;
  --radius: 6px;
  --shadow: 0 6px 24px rgba(0,0,0,.18);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --ui-bg: #1b2029;
  --ui-panel: #232a35;
  --ui-panel-2: #2a3240;
  --ui-bar: linear-gradient(#2a3240, #232a35);
  --ui-border: #3a4352;
  --ui-border-soft: #333b49;
  --ui-text: #e4e8ef;
  --ui-muted: #98a2b1;
  --hover: #2f3b50;
  --hover-border: #44587a;
  --accent: #5b95f7;
  --accent-soft: #2a3d60;
  --accent-border: #4a6fae;
  --status: #1e242e;
  --vp-top: #3b4759;
  --vp-bottom: #1e242d;
  --shadow: 0 6px 24px rgba(0,0,0,.5);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { font: 13px/1.35 var(--font); color: var(--ui-text); background: var(--ui-bg); -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
input, select { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; flex: none; }
[hidden] { display: none !important; }
kbd { font: 11px/1 var(--font); padding: 2px 5px; border: 1px solid var(--ui-border); border-bottom-width: 2px; border-radius: 4px; background: var(--ui-panel-2); color: var(--ui-muted); }
[data-theme="dark"] symbol path[fill="#fff"], [data-theme="dark"] symbol rect[fill="#fff"] { fill: #3a4352; }

#app {
  display: grid;
  height: 100vh; height: 100dvh;
  grid-template-columns: var(--tree-w) minmax(0, 1fr) auto;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-areas: "cmd cmd cmd" "docs docs docs" "tree vp pm" "status status status";
}

/* ---------- CommandManager ---------- */
#cmd { grid-area: cmd; background: var(--ui-bar); border-bottom: 1px solid var(--ui-border); min-width: 0; }
.cmd-top { display: flex; align-items: center; gap: 10px; padding: 4px 10px 0; min-height: 38px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 15px; white-space: nowrap; padding-right: 6px; }
.brand b { color: var(--brand); font-weight: 700; }
.tabs { display: flex; gap: 2px; align-self: flex-end; }
.tab { border: 1px solid transparent; border-bottom: none; background: none; padding: 6px 14px; border-radius: 6px 6px 0 0; color: var(--ui-muted); }
.tab:hover { color: var(--ui-text); background: var(--hover); }
.tab.active { background: var(--ui-panel); border-color: var(--ui-border); color: var(--ui-text); font-weight: 600; position: relative; top: 1px; }
.spacer { flex: 1; }
.top-btn { display: inline-flex; align-items: center; gap: 4px; border: 1px solid transparent; background: none; border-radius: var(--radius); padding: 4px 8px; min-height: 32px; }
.top-btn:hover { background: var(--hover); border-color: var(--hover-border); }
.lang-btn span { font-weight: 600; font-size: 12px; }
.open-btn { display: none; align-items: center; gap: 6px; border: 1px solid var(--ui-border); background: var(--ui-panel-2); border-radius: var(--radius); padding: 6px 12px; min-height: 36px; }

.ribbon { display: flex; align-items: stretch; padding: 4px 6px 2px; background: var(--ui-panel); border-top: 1px solid var(--ui-border); overflow-x: auto; scrollbar-width: thin; }
.grp { flex: none; display: flex; flex-wrap: nowrap; align-items: flex-start; gap: 2px; padding: 0 8px 16px; border-right: 1px solid var(--ui-border-soft); position: relative; }
.grp .col { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.grp-label { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; font-size: 11px; color: var(--ui-muted); white-space: nowrap; }
.rb { display: flex; align-items: center; border: 1px solid transparent; background: none; border-radius: 4px; }
.rb:hover:not(:disabled) { background: var(--hover); border-color: var(--hover-border); }
.rb.big { flex-direction: column; gap: 3px; width: 74px; padding: 4px 2px; font-size: 11.5px; text-align: center; line-height: 1.15; }
.rb.big svg { width: 28px; height: 28px; }
.rb.sm { gap: 5px; padding: 2px 6px; font-size: 12px; min-width: 92px; white-space: nowrap; }
.rb.sm svg { width: 18px; height: 18px; }
.rb.toggle.on, .rb.on { background: var(--accent-soft); border-color: var(--accent-border); }
.views { display: grid; grid-template-columns: repeat(4, auto); gap: 1px 2px; }
.dstyles { display: grid; grid-template-columns: repeat(2, auto); gap: 1px 2px; }
.seg { display: inline-flex; border: 1px solid var(--ui-border); border-radius: var(--radius); overflow: hidden; margin-top: 10px; background: var(--ui-panel-2); }
.seg.small { margin-top: 0; }
.seg button { border: none; background: none; padding: 6px 12px; border-right: 1px solid var(--ui-border); }
.seg.small button { padding: 4px 9px; font-size: 12px; }
.seg button:last-child { border-right: none; }
.seg button.on { background: var(--accent); color: #fff; }

/* ---------- FeatureManager tree ---------- */
#tree { grid-area: tree; display: flex; flex-direction: column; background: var(--ui-panel); border-right: 1px solid var(--ui-border); min-height: 0; }
.tree-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; font-weight: 600; border-bottom: 1px solid var(--ui-border-soft); min-height: 38px; }
.tree-search { padding: 6px 8px; border-bottom: 1px solid var(--ui-border-soft); }
.tree-search input { width: 100%; padding: 6px 8px; border: 1px solid var(--ui-border); border-radius: 5px; background: var(--ui-panel-2); }
.tree-body { flex: 1; overflow: auto; padding: 4px 2px 12px; min-height: 0; }
.tree-empty { color: var(--ui-muted); padding: 10px 8px; }
.tnode { user-select: none; }
.trow { display: flex; align-items: center; gap: 3px; padding: 1px 4px; border-radius: 3px; white-space: nowrap; min-height: 24px; cursor: default; }
.trow:hover { background: var(--hover); }
.trow.sel { background: var(--accent-soft); }
.trow.hid .tname, .trow.hid > svg { opacity: .45; }
.trow .tw { width: 16px; height: 18px; display: inline-flex; align-items: center; justify-content: center; border: none; background: none; padding: 0; color: var(--ui-muted); font-size: 10px; flex: none; }
.trow .tw.leaf { visibility: hidden; }
.trow .eye { width: 22px; height: 20px; display: inline-flex; align-items: center; justify-content: center; border: none; background: none; padding: 0; color: var(--ui-muted); flex: none; border-radius: 3px; }
.trow .eye:hover { color: var(--accent); }
.trow .eye svg { width: 15px; height: 15px; }
.trow.part-partial .eye { opacity: .6; }
.trow > svg { width: 16px; height: 16px; }
.trow .tname { overflow: hidden; text-overflow: ellipsis; }
.trow .tcount { color: var(--ui-muted); font-size: 11px; margin-left: 2px; }
.trow .dup { font-size: 10.5px; color: var(--accent); background: var(--accent-soft); border-radius: 8px; padding: 0 5px; margin-left: 3px; }
.tchildren { padding-left: 14px; }
.tnode.file > .trow { font-weight: 600; }
.tnode.filtered { display: none; }
#treeBackdrop { display: none; }

/* ---------- Vùng 3D ---------- */
#viewport { grid-area: vp; position: relative; overflow: hidden; min-width: 0; min-height: 0; background: linear-gradient(180deg, var(--vp-top) 0%, var(--vp-bottom) 100%); }
#viewport[data-bg="white"] { background: #ffffff; }
#viewport[data-bg="dark"] { background: #1b1f27; }
#viewport[data-bg="dark"] #emptyHint { color: #e4e8ef; }
#viewport[data-bg="white"] #emptyHint { color: #1f2733; }
#c3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#c3d.measuring { cursor: crosshair; }
#overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.dimlabel { position: absolute; transform: translate(-50%, -50%); background: rgba(255,255,255,.95); color: #1f2733; border: 1px solid #e07b00; border-radius: 4px; padding: 2px 6px; font-size: 12px; font-weight: 600; white-space: nowrap; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
#hud, #hud2d { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 2px; padding: 3px; background: color-mix(in srgb, var(--ui-panel) 85%, transparent); border: 1px solid var(--ui-border); border-radius: 6px; backdrop-filter: blur(4px); box-shadow: 0 1px 4px rgba(0,0,0,.12); z-index: 5; }
#hud button, #hud2d button { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border: 1px solid transparent; background: none; border-radius: 4px; }
#hud button:hover:not(:disabled), #hud2d button:hover:not(:disabled) { background: var(--hover); border-color: var(--hover-border); }
#hud button.on, #hud2d button.on { background: var(--accent-soft); border-color: var(--accent-border); }
#hud .sep, #hud2d .sep { width: 1px; height: 22px; background: var(--ui-border); margin: 0 3px; }
.hud-dd { position: relative; }
.dd { position: absolute; top: 38px; left: 50%; transform: translateX(-50%); background: var(--ui-panel-2); border: 1px solid var(--ui-border); border-radius: 6px; padding: 4px; box-shadow: var(--shadow); min-width: 210px; z-index: 20; }
#hud .dd button { width: 100%; height: auto; min-height: 34px; justify-content: flex-start; gap: 8px; padding: 4px 8px; white-space: nowrap; }
#hud .dd button.on { background: var(--accent-soft); }
#viewcube { position: absolute; top: 6px; right: 6px; width: 120px; height: 120px; touch-action: none; z-index: 4; }
#triad { position: absolute; left: 8px; bottom: 8px; width: 84px; height: 84px; pointer-events: none; overflow: visible; }
#triad text { font: bold 12px var(--font); }

#emptyHint { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; padding: 24px; color: var(--ui-text); }
#emptyHint h2 { margin: 14px 0 6px; font-size: 20px; font-weight: 600; }
#emptyHint p { margin: 4px 0; }
#emptyHint .mb { display: none; }
#emptyHint .link { pointer-events: auto; border: none; background: none; color: var(--accent); text-decoration: underline; padding: 0; }
#emptyHint .privacy { margin-top: 12px; font-size: 12px; color: var(--ui-muted); }
#dropOverlay { position: absolute; inset: 8px; display: none; align-items: center; justify-content: center; border: 3px dashed var(--accent); border-radius: 10px; background: rgba(37,99,235,.08); font-size: 20px; font-weight: 600; color: var(--accent); pointer-events: none; }
body.dragging #dropOverlay { display: flex; }

#progress { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(240,243,247,.25); z-index: 8; }
.pcard { width: min(380px, 88%); background: var(--ui-panel-2); border: 1px solid var(--ui-border); border-radius: 8px; padding: 14px 16px; box-shadow: var(--shadow); }
.pname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pstage { color: var(--ui-muted); margin: 4px 0 8px; }
.pbar { height: 8px; background: var(--ui-border-soft); border-radius: 4px; overflow: hidden; }
#pFill { height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.pbar.indet #pFill { width: 35% !important; animation: indet 1.1s ease-in-out infinite; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(290%); } }
.pqueue { margin-top: 6px; font-size: 11.5px; color: var(--ui-muted); }
.pnote { margin-top: 6px; font-size: 12px; color: #b45309; }
.pfoot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.pfoot .pqueue { margin-top: 0; }
#pCancel { min-height: 28px; padding: 3px 12px; }
#pCancel:disabled { opacity: .5; }
.lg-card { width: min(470px, 100%); }
.lg-text { white-space: pre-line; line-height: 1.45; margin: 12px 0 14px; }
.lg-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

#orientMenu { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: color-mix(in srgb, var(--ui-panel-2) 96%, transparent); border: 1px solid var(--ui-border); border-radius: 8px; padding: 10px; box-shadow: var(--shadow); z-index: 10; }
.om-title { font-weight: 600; margin: 0 4px 8px; }
.om-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.om-grid button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 6px; min-width: 84px; min-height: 44px; border: 1px solid transparent; background: none; border-radius: 6px; }
.om-grid button:hover { background: var(--hover); border-color: var(--hover-border); }
.om-grid svg { width: 30px; height: 30px; }

/* ---------- PropertyManager ---------- */
#pm { grid-area: pm; width: var(--pm-w); display: flex; flex-direction: column; background: var(--ui-panel); border-left: 1px solid var(--ui-border); min-height: 0; }
.pm-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 4px 12px; font-weight: 600; border-bottom: 1px solid var(--ui-border-soft); min-height: 40px; }
.pm-body { flex: 1; min-height: 0; overflow: auto; padding: 10px 12px 16px; }
.pm-grip { display: none; }
.pm-head-btns { display: inline-flex; align-items: center; gap: 2px; }
.pm-sec { border: 1px solid var(--ui-border-soft); border-radius: 6px; padding: 8px 10px; margin-bottom: 10px; background: var(--ui-panel-2); }
.pm-sec h4 { margin: 0 0 6px; font-size: 12.5px; }
.pm-help { color: var(--ui-muted); font-size: 12px; margin: 0 0 10px; }
.pm-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 0; }
.pm-row label { color: var(--ui-muted); }
.pm-row b { font-weight: 600; text-align: right; }
.pm-kv { display: grid; grid-template-columns: fit-content(58%) minmax(0, 1fr); gap: 3px 10px; font-size: 12.5px; }
.pm-kv > :nth-child(odd) { color: var(--ui-muted); }
.pm-kv > :nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; overflow-wrap: break-word; min-width: 0; }
.pm-kv > :nth-child(odd) { min-width: 0; overflow-wrap: break-word; }
.pm-body input[type="number"], .pm-body select { width: 100%; padding: 5px 6px; border: 1px solid var(--ui-border); border-radius: 5px; background: var(--ui-panel-2); }
.pm-body input[type="range"] { width: 100%; }
.pm-body input[type="color"] { width: 46px; height: 30px; border: 1px solid var(--ui-border); border-radius: 5px; padding: 1px; background: var(--ui-panel-2); }
.pm-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.btn { border: 1px solid var(--ui-border); background: var(--ui-panel-2); border-radius: 5px; padding: 6px 12px; min-height: 32px; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { border: 1px solid var(--ui-border); background: var(--ui-panel-2); border-radius: 14px; padding: 4px 10px; font-size: 12px; min-height: 30px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.check { display: flex; align-items: center; gap: 6px; padding: 4px 0; }
.ent { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 4px; background: var(--hover); margin-bottom: 4px; font-size: 12.5px; }
.ent .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.warn { color: #b45309; font-size: 12px; margin-top: 6px; }

/* ---------- Status bar ---------- */
#status { grid-area: status; display: flex; align-items: center; gap: 4px; padding: 3px 10px; background: var(--status); border-top: 1px solid var(--ui-border); font-size: 12px; white-space: nowrap; overflow: hidden; }
.st-msg { flex: 1; overflow: hidden; text-overflow: ellipsis; color: var(--ui-muted); }
.st-item { padding: 0 10px; border-left: 1px solid var(--ui-border); }

#mobileBar { display: none; }

/* ---------- Menu ngữ cảnh, modal, toast ---------- */
.ctx { position: fixed; z-index: 70; background: var(--ui-panel-2); border: 1px solid var(--ui-border); border-radius: 6px; padding: 4px; box-shadow: var(--shadow); min-width: 200px; }
.ctx button { display: flex; align-items: center; gap: 8px; width: 100%; border: none; background: none; text-align: left; padding: 6px 10px; border-radius: 4px; min-height: 32px; }
.ctx button:hover { background: var(--hover); }
.ctx hr { border: none; border-top: 1px solid var(--ui-border-soft); margin: 4px 2px; }
.ctx .ctx-title { font-size: 11.5px; color: var(--ui-muted); padding: 4px 10px 2px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.modal { position: fixed; inset: 0; background: rgba(15,23,42,.4); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-card { background: var(--ui-panel-2); border-radius: 10px; width: min(580px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--ui-border-soft); position: sticky; top: 0; background: var(--ui-panel-2); }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 4px 16px 16px; }
.modal-body h4 { margin: 14px 0 6px; font-size: 13px; }
.modal-body table { width: 100%; border-collapse: collapse; }
.modal-body td { padding: 5px 4px; border-bottom: 1px solid var(--ui-border-soft); vertical-align: top; }
.modal-body td:first-child { width: 44%; }
.muted { color: var(--ui-muted); font-size: 12px; }
.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 12px; }
.more-grid button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; min-height: 72px; border: 1px solid var(--ui-border-soft); background: var(--ui-panel); border-radius: 8px; font-size: 12px; text-align: center; }
.more-grid button.on { background: var(--accent-soft); border-color: var(--accent-border); }
.more-grid svg { width: 26px; height: 26px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: none; background: none; border-radius: 6px; }
.icon-btn:hover { background: var(--hover); }

#toasts { position: fixed; right: 12px; bottom: 34px; display: flex; flex-direction: column; gap: 8px; z-index: 80; max-width: min(420px, calc(100vw - 24px)); }
.toast { background: #1f2733; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.25); animation: tin .2s ease-out; white-space: pre-line; }
.toast.err { background: #b42318; color: #fff; }
.toast.warn { background: #b45309; color: #fff; }
.toast.ok { background: #15803d; color: #fff; }
.sec-preview { display: block; width: 100%; height: 150px; margin: 6px 0 2px; background: var(--panel-2, #f3f5f8); border: 1px solid var(--line, #dde1e7); border-radius: 6px; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

.only-mobile { display: none; }

/* ---------- Điện thoại / màn hình hẹp ---------- */
@media (max-width: 820px) {
  #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto auto; grid-template-areas: "cmd" "docs" "vp" "status" "mbar"; }
  .only-mobile { display: inline-flex; }
  .hide-mobile { display: none !important; }
  .tabs, .ribbon { display: none !important; }
  .cmd-top { padding: 4px 6px; padding-top: max(4px, env(safe-area-inset-top)); gap: 4px; }
  .brand { font-size: 14px; gap: 6px; min-width: 0; flex: 0 1 auto; padding-right: 0; }
  .brand span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  @media (max-width: 380px) { .brand { font-size: 13px; } .open-btn span { display: none; } }
  .open-btn { display: inline-flex; min-height: 44px; }
  .top-btn { min-height: 44px; min-width: 44px; justify-content: center; }
  #tree { position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: min(86vw, 320px); transform: translateX(-102%); transition: transform .22s ease; box-shadow: 4px 0 20px rgba(0,0,0,.25); padding-top: env(safe-area-inset-top); }
  #tree.open { transform: none; }
  #treeBackdrop { position: fixed; inset: 0; z-index: 39; background: rgba(15,23,42,.3); }
  #tree.open + #treeBackdrop { display: block; }
  .trow { min-height: 40px; }
  .trow .eye { width: 40px; height: 36px; }
  #hud, #hud2d { top: 6px; left: 8px; transform: none; }
  #hud button, #hud2d button { width: 44px; height: 44px; }
  #hud .sep, #hud2d .sep { display: none; }
  .dd { left: 0; transform: none; }
  #viewcube { width: 96px; height: 96px; }
  #triad { width: 64px; height: 64px; }
  #pm { position: fixed; z-index: 30; left: 0; right: 0; bottom: calc(56px + env(safe-area-inset-bottom)); width: auto; max-height: 48vh; border-left: none; border-top: 1px solid var(--ui-border); border-radius: 12px 12px 0 0; box-shadow: 0 -6px 24px rgba(0,0,0,.2); }
  /* bảng thông số dạng ngăn kéo: mặc định thu thấp sát thanh nút để chọn mặt trên mô hình, kéo / bấm để mở */
  #pm { transition: max-height .22s ease; overflow: hidden; }
  #pm[data-sheet="collapsed"] { max-height: 132px; }
  #pm[data-sheet="half"] { max-height: 48vh; }
  #pm[data-sheet="full"] { max-height: calc(100% - 140px); }
  #pm.dragging { transition: none; }
  #pm .pm-grip { display: flex; justify-content: center; align-items: center; height: 20px; flex: none; touch-action: none; cursor: grab; }
  #pm .pm-grip::before { content: ''; width: 44px; height: 5px; border-radius: 3px; background: var(--ui-muted); opacity: .55; }
  #pm .pm-head { touch-action: none; min-height: 44px; padding-top: 0; }
  #pmToggle svg { transition: transform .2s ease; }
  #pm:not([data-sheet="collapsed"]) #pmToggle svg { transform: rotate(180deg); }
  #status .st-item:not(.st-mob) { display: none; }
  #mobileBar { grid-area: mbar; display: flex; justify-content: space-around; background: var(--ui-panel); border-top: 1px solid var(--ui-border); padding-bottom: env(safe-area-inset-bottom); }
  #mobileBar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; border: none; background: none; font-size: 11px; }
  #mobileBar button svg { width: 24px; height: 24px; }
  .om-grid { grid-template-columns: repeat(2, 1fr); }
  .sheet { align-items: flex-end; padding: 0; }
  .sheet .modal-card { border-radius: 14px 14px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  #toasts { bottom: 90px; left: 12px; right: 12px; }
  #emptyHint h2 { font-size: 17px; }
  #emptyHint .dt { display: none; }
  #emptyHint .mb { display: inline; }
  .ctx button { min-height: 44px; }
}
@media (max-width: 1180px) and (min-width: 821px) {
  :root { --tree-w: 220px; --pm-w: 270px; }
  .rb.sm { min-width: 80px; }
}

/* ---------- Chế độ 2D (DXF / DWG) ---------- */
body:not([data-mode="2d"]) .only2d { display: none !important; }
body[data-mode="2d"] .only3d { display: none !important; }
#c2d, #c2dOver { position: absolute; inset: 0; display: block; outline: none; }
#c2dOver { cursor: none; touch-action: none; }
body:not([data-mode="2d"]) #c2d, body:not([data-mode="2d"]) #c2dOver { display: none; }
body[data-mode="2d"] #c3d, body[data-mode="2d"] #overlay { display: none; }
body[data-mode="2d"] #viewport { background: #212830; }
.mode-sw { margin: 0 4px; }
.mode-sw button { padding: 4px 10px; font-weight: 600; }

.layer-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ly-tools { display: flex; gap: 4px; flex-wrap: wrap; padding: 6px 8px 0; }
.ly-tools .btn { padding: 3px 8px; min-height: 28px; font-size: 12px; }
.ly-search { margin: 6px 8px; padding: 6px 8px; border: 1px solid var(--ui-border); border-radius: 5px; background: var(--ui-panel-2); }
.ly-list { flex: 1; overflow: auto; padding: 0 2px 12px; min-height: 0; }
.ly-row { display: flex; align-items: center; gap: 4px; padding: 1px 4px; border-radius: 3px; min-height: 26px; white-space: nowrap; }
.ly-row:hover { background: var(--hover); }
.ly-row.off .ly-name, .ly-row.off .ly-sw { opacity: .45; }
.ly-eye, .ly-frz { width: 24px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border: none; background: none; padding: 0; border-radius: 3px; color: var(--ui-muted); flex: none; font-size: 12px; }
.ly-eye svg { width: 15px; height: 15px; }
.ly-frz { opacity: .35; }
.ly-frz.on { opacity: 1; color: #0ea5e9; }
.ly-sw { width: 12px; height: 12px; border-radius: 2px; border: 1px solid rgba(0,0,0,.3); flex: none; }
.ly-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.ly-n { color: var(--ui-muted); font-size: 11px; }

#layoutTabs { position: absolute; left: 8px; bottom: 6px; display: flex; gap: 2px; z-index: 5; max-width: calc(100% - 16px); overflow-x: auto; }
#layoutTabs .lt { border: 1px solid var(--ui-border); background: color-mix(in srgb, var(--ui-panel) 90%, transparent); padding: 3px 10px; border-radius: 4px 4px 0 0; font-size: 12px; white-space: nowrap; }
#layoutTabs .lt.on { background: var(--accent); border-color: var(--accent); color: #fff; }

#cmdline { position: absolute; left: 50%; transform: translateX(-50%); bottom: 34px; width: min(760px, calc(100% - 16px)); z-index: 6; background: color-mix(in srgb, var(--ui-panel-2) 88%, transparent); border: 1px solid var(--ui-border); border-radius: 6px; box-shadow: 0 2px 10px rgba(0,0,0,.2); backdrop-filter: blur(4px); font: 12.5px/1.35 ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace; }
/* thu gọn: chỉ dòng kết quả cuối; mở rộng khi đang gõ lệnh (hoặc F2 / bấm vào lịch sử) */
.cl-hist { max-height: 1.6em; overflow: hidden; padding: 3px 8px 0; color: var(--ui-muted); cursor: pointer; transition: max-height .12s ease; }
#cmdline.exp .cl-hist { max-height: 9.5em; overflow: auto; cursor: auto; }
.cl-hist:empty { display: none; }
.cl-line { white-space: pre-wrap; overflow-wrap: anywhere; }
.cl-line.res { color: var(--ui-text); }
.cl-line.err { color: #dc2626; }
.cl-line.cmd { color: var(--accent); }
.cl-line button { border: none; background: none; color: var(--accent); text-decoration: underline; padding: 0 2px; font: inherit; }
.cl-row { display: flex; align-items: center; gap: 6px; padding: 3px 6px 4px 8px; border-top: 1px solid var(--ui-border-soft); }
.cl-prompt { flex: 0 1 auto; max-width: 62%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ui-text); }
.cl-kw { border: none; background: none; color: var(--accent); padding: 0 1px; font: inherit; text-decoration: underline; }
#cmdInput { flex: 1; min-width: 60px; border: none; background: transparent; outline: none; font: inherit; padding: 3px 0; }
.cl-esc, .cl-enter { flex: none; border: 1px solid var(--ui-border); background: var(--ui-panel); border-radius: 4px; padding: 1px 8px; font-size: 11px; min-height: 24px; }
.cl-suggest { position: absolute; left: 0; right: 0; bottom: 100%; margin-bottom: 4px; background: var(--ui-panel-2); border: 1px solid var(--ui-border); border-radius: 6px; box-shadow: var(--shadow); padding: 3px; max-height: 240px; overflow: auto; }
.cl-suggest button { display: block; width: 100%; text-align: left; border: none; background: none; padding: 5px 8px; border-radius: 4px; font: inherit; }
.cl-suggest button:hover { background: var(--hover); }
.cl-last { display: none; }

.st-tog { display: inline-flex; gap: 2px; padding: 0 6px; border-left: 1px solid var(--ui-border); }
.st-tog button { border: 1px solid transparent; background: none; border-radius: 3px; padding: 0 5px; font-size: 11px; font-weight: 600; color: var(--ui-muted); min-height: 20px; }
.st-tog button.on { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-border); }
.st-coord b { font-variant-numeric: tabular-nums; min-width: 150px; display: inline-block; }
.st-item.warn b { color: #b45309; }
.sn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
@media (max-width: 820px) {
  #cmdline { display: none; bottom: 36px; }
  #cmdline.open { display: block; }
  .cl-row { min-height: 44px; }
  .cl-esc, .cl-enter { min-height: 36px; min-width: 44px; font-size: 14px; }
  #cmdInput { font-size: 16px; }
  .cl-last { position: absolute; left: 8px; right: 8px; bottom: 40px; display: block; pointer-events: none; text-align: center; z-index: 5; font: 13px/1.3 ui-monospace, Menlo, monospace; }
  .cl-last:empty, #cmdline.open ~ .cl-last { display: none; }
  .cl-last.res { color: #fde047; text-shadow: 0 1px 2px #000, 0 0 4px #000; }
  .cl-last.err { color: #fca5a5; text-shadow: 0 1px 2px #000; }
  .st-tog button { min-height: 32px; padding: 0 7px; }
  .st-coord b { min-width: 0; }
  .ly-row { min-height: 40px; }
  .ly-eye, .ly-frz { width: 40px; height: 36px; }
  .sn-grid { grid-template-columns: 1fr; }
}
@media (min-width: 821px) { #cmdline.dt-off { display: none; } }

/* ---------- Thu gọn thanh lệnh, kéo độ rộng cây (máy tính) ---------- */
.rb-toggle { align-self: center; display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; margin-left: 2px; border: 1px solid transparent; background: none; border-radius: 4px; color: var(--ui-muted); }
.rb-toggle:hover { background: var(--hover); border-color: var(--hover-border); color: var(--ui-text); }
.rb-toggle svg { width: 16px; height: 16px; transition: transform .15s; }
.tree-split { display: none; }
@media (min-width: 821px) {
  #cmd { position: relative; z-index: 20; }
  body.rb-off .rb-toggle svg { transform: rotate(180deg); }
  body.rb-off:not(.rb-pop) .ribbon { display: none !important; }
  body.rb-off .tab.active { border-color: transparent; background: none; font-weight: 600; color: var(--ui-text); top: 0; box-shadow: inset 0 -2px 0 var(--brand); }
  body.rb-off.rb-pop .tab.active { border-color: var(--ui-border); background: var(--ui-panel); box-shadow: none; top: 1px; }
  body.rb-off.rb-pop .ribbon { position: absolute; left: 0; right: 0; top: 100%; box-shadow: 0 6px 16px rgba(0,0,0,.18); border-bottom: 1px solid var(--ui-border); }

  #tree { position: relative; }
  .tree-split { display: block; position: absolute; top: 0; bottom: 0; right: -4px; width: 8px; cursor: col-resize; z-index: 8; touch-action: none; user-select: none; }
  .tree-split::after { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 2px; background: transparent; transition: background .12s; }
  .tree-split:hover::after, body.tree-drag .tree-split::after { background: var(--brand); }
  .tree-split svg { display: none; }
  body.tree-drag, body.tree-drag * { cursor: col-resize !important; user-select: none !important; }
  body.tree-off #tree { border-right: none; overflow: visible; }
  body.tree-off #tree > :not(.tree-split) { display: none !important; }
  body.tree-off .tree-split { right: -14px; width: 14px; top: 50%; bottom: auto; height: 56px; transform: translateY(-50%); cursor: pointer; background: var(--ui-panel); border: 1px solid var(--ui-border); border-left: none; border-radius: 0 6px 6px 0; box-shadow: 1px 0 4px rgba(0,0,0,.12); display: flex; align-items: center; justify-content: center; }
  body.tree-off .tree-split::after { display: none; }
  body.tree-off .tree-split svg { display: block; width: 12px; height: 12px; transform: rotate(90deg); color: var(--ui-muted); }
  body.tree-off .tree-split:hover svg { color: var(--brand); }
}

/* ---------- Tab tài liệu (mỗi file mở là một tab độc lập) ---------- */
.doc-tabs { grid-area: docs; display: flex; align-items: flex-end; gap: 2px; padding: 4px 6px 0; background: var(--ui-bg, var(--ui-panel)); border-bottom: 1px solid var(--ui-border); overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; min-width: 0; }
.doc-tabs[hidden] { display: none; }
.doc-tabs .dt { display: flex; align-items: center; gap: 6px; max-width: 240px; min-width: 0; flex: 0 0 auto; padding: 4px 4px 4px 8px; border: 1px solid var(--ui-border); border-bottom: none; border-radius: 6px 6px 0 0; background: color-mix(in srgb, var(--ui-panel) 70%, var(--ui-border)); color: var(--ui-muted); font-size: 12.5px; cursor: pointer; user-select: none; position: relative; top: 1px; }
.doc-tabs .dt:hover { color: var(--ui-text); }
.doc-tabs .dt.on { background: var(--ui-panel); color: var(--ui-text); font-weight: 600; box-shadow: inset 0 2px 0 var(--brand); }
.doc-tabs .dt-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.doc-tabs .dt-k { font-size: 10px; font-weight: 700; padding: 1px 4px; border-radius: 3px; color: #fff; flex: 0 0 auto; }
.doc-tabs .dt-3d { background: #3f6fb5; }
.doc-tabs .dt-2d { background: #4f8a4b; }
.doc-tabs .dt-x { border: none; background: none; color: inherit; width: 20px; height: 20px; line-height: 18px; border-radius: 4px; font-size: 16px; padding: 0; flex: 0 0 auto; cursor: pointer; }
.doc-tabs .dt-x:hover { background: var(--hover); color: #c62828; }
@media (max-width: 820px) {
  .doc-tabs { padding: 4px 4px 0; }
  .doc-tabs .dt { padding: 6px 4px 6px 8px; max-width: 200px; }
  .doc-tabs .dt-n { max-width: 130px; }
  .doc-tabs .dt-x { width: 30px; height: 30px; font-size: 20px; line-height: 28px; }
}

/* ---------- V1: Tổng chiều dài 2D ---------- */
.pm-row.wide > label { white-space: nowrap; flex: none; }
.pm-row.wide > select, .pm-row.wide > input { flex: 1; min-width: 0; }
.tl-filter { border: 1px solid var(--ui-border-soft); border-radius: var(--radius); padding: 4px 8px; margin: 4px 0; }
.tl-filter summary { cursor: pointer; font-size: 12.5px; padding: 2px 0; }
.tl-list { max-height: 180px; overflow: auto; display: flex; flex-direction: column; gap: 1px; }
.tl-list .check { font-size: 12px; margin: 0; }
.tl-sw { display: inline-block; width: 12px; height: 12px; border: 1px solid #8a94a3; border-radius: 2px; margin-right: 5px; vertical-align: -2px; }
.tl-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 4px 0; }
.tl-table th { text-align: left; font-weight: 600; color: var(--ui-muted); border-bottom: 1px solid var(--ui-border); padding: 3px 4px; }
.tl-table th:not(:first-child), .tl-table td:not(:first-child) { text-align: right; white-space: nowrap; }
.tl-table td { border-bottom: 1px solid var(--ui-border-soft); padding: 4px; cursor: pointer; word-break: break-word; }
.tl-table tr:hover td { background: var(--hover); }
.tl-table tr.on td { background: #ffedd5; color: #9a3412; font-weight: 600; }
.tl-table tr.tot td { font-weight: 700; cursor: default; border-top: 1px solid var(--ui-border); background: transparent; color: inherit; }

/* ---------- V1: BOM 3D ---------- */
.bom-sum { font-weight: 600; margin: 2px 0 6px; }
.bom-list { display: flex; flex-direction: column; gap: 2px; max-height: 46vh; overflow: auto; margin-bottom: 6px; }
.bom-asm { font-weight: 700; font-size: 12px; color: var(--accent); margin: 6px 0 2px; }
.bom-row { display: grid; grid-template-columns: 42px 1fr auto; gap: 6px; align-items: center; text-align: left; border: 1px solid var(--ui-border-soft); background: var(--ui-panel-2); border-radius: var(--radius); padding: 5px 7px; min-height: 40px; }
.bom-row:hover { background: var(--hover); border-color: var(--hover-border); }
.bom-row .q { font-weight: 700; color: var(--accent); }
.bom-row .n { display: flex; flex-direction: column; min-width: 0; }
.bom-row .n b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bom-row .n small { color: var(--ui-muted); font-size: 11.5px; }
.bom-row .k { font-size: 12px; white-space: nowrap; }
.bom-modal .modal-card { width: min(1180px, 97vw); display: flex; flex-direction: column; overflow: hidden; background: #fff; color: #1f2733; }
.bom-modal .modal-body { overflow: auto; padding: 0 14px 14px; }
.bom-modal .bom-actions { display: flex; gap: 6px; align-items: center; margin-left: auto; }
@media (max-width: 820px) { .bom-modal .modal-card { width: 100vw; height: 100%; max-height: 100%; border-radius: 0; } }

/* ---------- V1: Góc nhìn đã lưu ---------- */
.vw-item { display: grid; grid-template-columns: 96px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--ui-border-soft); }
.vw-thumb { padding: 0; border: 1px solid var(--ui-border); border-radius: 4px; overflow: hidden; width: 96px; height: 60px; background: #fff; }
.vw-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vw-noimg { width: 100%; height: 100%; background: repeating-linear-gradient(45deg, #eef1f5 0 6px, #e2e7ee 6px 12px); }
.vw-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.vw-name { text-align: left; font-weight: 600; border: 0; background: none; padding: 0; color: var(--ui-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: 24px; }
.vw-name:hover { color: var(--accent); }
.vw-name-in { width: 100%; }
.vw-acts { display: flex; gap: 4px; flex-wrap: wrap; }
.vw-acts .chip { min-height: 28px; padding: 2px 8px; }
.vw-dirty { color: #b45309; font-size: 12px; margin: 4px 0; }
@media (pointer: coarse) { .vw-acts .chip { min-height: 36px; } .tl-table td { padding: 8px 4px; } }

/* ---------- V2: Ghi chú / markup ---------- */
#mk3d { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
body[data-mode="2d"] #mk3d { display: none; }
#c3d.mk-draw, #c2dOver.mk-draw { cursor: crosshair; }
#c3d.mk-move, #c2dOver.mk-move { cursor: move; }
.mk-tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.mk-tool { display: flex; flex-direction: column; align-items: center; gap: 1px; border: 1px solid var(--ui-border-soft); background: var(--ui-panel-2); border-radius: var(--radius); padding: 4px 2px; min-height: 48px; font-size: 11px; line-height: 1.15; color: var(--ui-text); }
.mk-tool:hover { border-color: var(--accent); }
.mk-tool.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.mk-ico { width: 20px; height: 20px; flex: none; }
.mk-row { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.mk-row > input { flex: 1; min-width: 0; }
.mk-ur { display: inline-flex; align-items: center; gap: 4px; }
.mk-help { margin: 6px 0 0; }
.mk-colors { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.mk-sw { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--ui-border); padding: 0; }
.mk-sw.on { outline: 2px solid var(--accent); outline-offset: 2px; }
.mk-li { display: grid; grid-template-columns: 28px 1fr auto; gap: 6px; align-items: center; width: 100%; text-align: left; border: 1px solid var(--ui-border-soft); background: var(--ui-panel-2); border-radius: var(--radius); padding: 5px 7px; margin-top: 4px; min-height: 44px; color: var(--ui-text); }
.mk-li:hover { border-color: var(--accent); }
.mk-li.on { background: var(--accent-soft); border-color: var(--accent); }
.mk-li.done { opacity: .7; }
.mk-li-m { min-width: 0; overflow: hidden; overflow-wrap: anywhere; font-size: 12.5px; }
.mk-li-m small { display: block; }
.mk-no { width: 24px; height: 24px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 11.5px; display: flex; align-items: center; justify-content: center; }
.mk-pill { font-size: 11px; border-radius: 10px; padding: 1px 7px; white-space: nowrap; }
.mk-pill.open { background: #fde8e8; color: #b42318; }
.mk-pill.done { background: #dcfae6; color: #067647; }
.mk-sel { border: 1px solid var(--accent-border); border-radius: var(--radius); padding: 8px; background: var(--ui-panel-2); }
.mk-sel textarea, .mk-ta2 { width: 100%; box-sizing: border-box; resize: vertical; font: inherit; }
.mk-reps { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.mk-rep { position: relative; border-left: 3px solid var(--accent-border); padding: 2px 22px 2px 6px; font-size: 12.5px; overflow-wrap: anywhere; }
.mk-rep-x { position: absolute; right: 0; top: 0; border: 0; background: none; color: var(--ui-muted); font-size: 16px; line-height: 1; padding: 2px 4px; }
.btn.danger { color: #b42318; border-color: #f0b3ad; }
.mk-ed { position: absolute; z-index: 30; width: 240px; background: var(--ui-panel-2); border: 1px solid var(--accent); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0,0,0,.25); padding: 6px; }
.mk-ed textarea { width: 100%; box-sizing: border-box; resize: vertical; font: 14px/1.35 system-ui, sans-serif; min-height: 52px; }
.mk-ed-b { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 4px; }
.mk-ed-b small { margin-right: auto; font-size: 11px; }
@media (pointer: coarse) { .mk-tool { min-height: 52px; } .mk-sw { width: 34px; height: 34px; } .mk-ed { width: min(300px, 86vw); } .mk-ed textarea { font-size: 16px; } }
.mk-sel > small, .mk-sel > label.muted { display: block; margin-top: 4px; }

/* ---------- V3: In / PDF theo tỉ lệ, trích thuộc tính block ---------- */
.pr-prev { display: flex; justify-content: center; padding: 8px; background: #8f959c; border-radius: var(--radius); }
.pr-cv { box-shadow: 0 2px 8px rgba(0,0,0,.35); background: #fff; max-width: 100%; height: auto !important; }
.pr-info { font-weight: 600; margin: 6px 0 0; }
.pr-custom span { display: inline-flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.pr-pens { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; margin: 4px 0; }
.pr-pen { display: flex; align-items: center; gap: 5px; font-size: 12px; }
.pr-pen input { width: 56px; }
.pr-sw { width: 12px; height: 12px; border: 1px solid #888; border-radius: 2px; flex: none; }
.pr-bdoc { font-weight: 600; margin-top: 8px; overflow-wrap: anywhere; }
.pr-bitem { margin-left: 10px; }
.ax-tabs { margin-bottom: 4px; }
.ax-list { max-height: 220px; overflow: auto; border: 1px solid var(--ui-border-soft); border-radius: var(--radius); padding: 4px 6px; }
.ax-list .check { overflow-wrap: anywhere; }
.ax-extra { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
.ax-sum { font-weight: 600; margin: 0 0 4px; }
.ax-wrap { overflow: auto; max-height: 340px; border: 1px solid var(--ui-border-soft); border-radius: var(--radius); }
.ax-t { border-collapse: collapse; font-size: 12px; min-width: 100%; }
.ax-t th { position: sticky; top: 0; background: var(--ui-panel-2); text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--ui-border); white-space: nowrap; }
.ax-t td { padding: 3px 6px; border-bottom: 1px solid var(--ui-border-soft); white-space: nowrap; }
.ax-t td.n { text-align: right; font-weight: 600; }
.ax-t tbody tr { cursor: pointer; }
.ax-t tbody tr:hover { background: var(--accent-soft); }
.ax-grid td { border: 1px solid var(--ui-border); white-space: pre-wrap; vertical-align: top; cursor: default; }
.ax-grid tbody tr { cursor: default; }
.ax-tbl { display: block; width: 100%; text-align: left; border: 1px solid var(--ui-border-soft); background: var(--ui-panel-2); border-radius: var(--radius); padding: 6px 8px; margin-top: 4px; min-height: 40px; color: var(--ui-text); overflow-wrap: anywhere; }
.ax-tbl.on { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- V5: chiều dày thành, va chạm / khe hở ---------- */
.mc-prog { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.mc-bar { height: 8px; border-radius: 4px; background: var(--ui-border-soft); overflow: hidden; }
.mc-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.mc-prow { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mc-legend { margin: 4px 0 8px; }
.mc-grad { height: 14px; border-radius: 3px; border: 1px solid var(--ui-border-soft); }
.mc-ticks { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ui-muted); margin-top: 2px; }
.mc-keys { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; margin-top: 4px; }
.mc-keys span { display: inline-flex; align-items: center; gap: 5px; }
.mc-keys i { width: 14px; height: 10px; border-radius: 2px; display: inline-block; }
.mc-probe-val { font-weight: 700; color: #b3261e; }
.mc-row .q { min-width: 46px; }
.mc-row.thin { border-color: #e0201b; }
.mc-row.thin .k { color: #e0201b; font-weight: 700; }
.mc-ok { color: #1f9d3a; font-weight: 600; }
.cl3-row .k { font-weight: 700; }
.cl3-row.hit { border-left: 4px solid #e0201b; }
.cl3-row.hit .k { color: #e0201b; }
.cl3-row.gap { border-left: 4px solid #e07b00; }
.cl3-row.gap .k { color: #c96a00; }
.cl3-row.touch { border-left: 4px solid #1d5fe0; }
.cl3-row.on { background: var(--hover); border-color: var(--hover-border); }
.mc-label { pointer-events: none; }
