:root {
  --bg: #e9edf2; --viewport: #f4f6f9; --panel: #ffffff; --panel2: #f3f5f8; --line: #d7dde5; --text: #1c2530; --muted: #66727f;
  --accent: #e8611f; --accent2: #2f6fde; --accentSoft: #fde6d9; --ok: #2e9b57; --warn: #c98a0b; --err: #d43b3b;
  --bar: #1d2733; --barText: #e7edf3; --barMuted: #93a3b4; --shadow: 0 6px 24px rgba(15, 25, 40, .18);
  --t-blue: #2f6fde; --t-orange: #e0661b; --t-green: #1f9a55; --t-purple: #7a52d6; --t-teal: #0f9a94; --t-red: #d23c3c; --t-yellow: #b88708;
  --r: 12px; --safeB: env(safe-area-inset-bottom, 0px); --safeT: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #11161c; --viewport: #1a2028; --panel: #1f262f; --panel2: #262e38; --line: #343e4a; --text: #e6ebf1; --muted: #93a0ae;
  --accentSoft: #4a2a19; --bar: #0d1217; --shadow: 0 6px 24px rgba(0, 0, 0, .5); color-scheme: dark;
  --t-blue: #63a8ff; --t-orange: #ff9a52; --t-green: #4fd18b; --t-purple: #b592ff; --t-teal: #3fd3cb; --t-red: #ff6f6f; --t-yellow: #f3c94e;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11161c; --viewport: #1a2028; --panel: #1f262f; --panel2: #262e38; --line: #343e4a; --text: #e6ebf1; --muted: #93a0ae;
    --accentSoft: #4a2a19; --bar: #0d1217; --shadow: 0 6px 24px rgba(0, 0, 0, .5); color-scheme: dark;
    --t-blue: #63a8ff; --t-orange: #ff9a52; --t-green: #4fd18b; --t-purple: #b592ff; --t-teal: #3fd3cb; --t-red: #ff6f6f; --t-yellow: #f3c94e;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; user-select: none; -webkit-user-select: none; }
input, select, textarea, button { font: inherit; color: inherit; }
input, textarea { user-select: text; -webkit-user-select: text; }
.ic { width: 22px; height: 22px; flex: none; }
button { cursor: pointer; }

#boot { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; background: var(--bar); color: var(--barText); z-index: 100; transition: opacity .3s; }
#boot.gone { opacity: 0; pointer-events: none; }
.boot-logo { display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 24px; font-weight: 700; letter-spacing: .5px; }
.boot-logo img { width: 84px; height: 84px; }
.boot-msg { color: var(--barMuted); font-size: 14px; }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* top bar */
.topbar { background: var(--bar); color: var(--barText); display: flex; align-items: center; gap: 2px; padding: calc(4px + var(--safeT)) 4px 4px; min-height: 52px; flex: none; z-index: 20; }
.topbar .title { flex: 1; min-width: 0; padding: 0 6px; }
.topbar .title b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title small { color: var(--barMuted); font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ib { background: none; border: 0; width: 44px; height: 44px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; color: inherit; flex: none; position: relative; }
.ib:active { background: rgba(127, 140, 160, .25); }
.ib:disabled { opacity: .35; }
.ib.on { background: var(--accent); color: #fff; }
.tabs { display: flex; background: var(--bar); padding: 0 6px 6px; gap: 6px; flex: none; z-index: 20; }
.tab { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 4px; border-radius: 9px; border: 0; background: rgba(255, 255, 255, .06); color: var(--barMuted); font-weight: 600; font-size: 14px; }
.tab.on { background: var(--accent); color: #fff; }
.tab .ic { width: 18px; height: 18px; }

/* viewport */
.stage { position: relative; flex: 1; min-height: 0; background: var(--viewport); overflow: hidden; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.float { position: absolute; z-index: 5; display: flex; flex-direction: column; gap: 6px; }
.float.right { right: 8px; top: 8px; }
.float.left { left: 8px; top: 8px; }
.fbtn { width: 42px; height: 42px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 2px 8px rgba(0, 0, 0, .1); color: var(--text); display: flex; align-items: center; justify-content: center; padding: 0; }
.fbtn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.fbtn:active { transform: scale(.95); }
.status { position: absolute; left: 50%; top: 8px; transform: translateX(-50%); z-index: 6; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 5px 12px; font-size: 13px; box-shadow: 0 2px 8px rgba(0, 0, 0, .1); display: none; align-items: center; gap: 8px; max-width: 70%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status.show { display: flex; }
.status.err { color: var(--err); }
.spin { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.hint { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 6; background: rgba(29, 39, 51, .88); color: #fff; padding: 7px 14px; border-radius: 18px; font-size: 13px; max-width: 92%; text-align: center; pointer-events: none; display: none; }
.hint.show { display: block; }
.viewcube { position: absolute; right: 58px; top: 8px; width: 74px; height: 74px; z-index: 5; }
.axes-legend { position: absolute; left: 8px; bottom: 8px; z-index: 4; pointer-events: none; }

/* bottom toolbar */
.toolbar { background: var(--panel); border-top: 1px solid var(--line); flex: none; padding-bottom: var(--safeB); z-index: 15; }
.cats { display: flex; gap: 2px; padding: 6px 6px 0; overflow-x: auto; scrollbar-width: none; }
.cats::-webkit-scrollbar, .tools::-webkit-scrollbar { display: none; }
.cat { border: 0; background: none; padding: 6px 12px; border-radius: 16px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.cat.on { background: var(--accentSoft); color: var(--accent); }
.tools { display: flex; gap: 2px; padding: 4px 6px 6px; overflow-x: auto; scrollbar-width: none; }
.tool { border: 0; background: none; min-width: 66px; padding: 6px 4px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11.5px; color: var(--text); flex: none; }
.tool .ic { width: 26px; height: 26px; }
.tool:active { background: var(--panel2); }
.tool.on { background: var(--accent); color: #fff; }
.tool.toggle.on { background: var(--accentSoft); color: var(--accent); }
.tool:disabled { opacity: .35; }
.tool span { white-space: nowrap; }

/* bottom sheet panel */
.sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--panel); border-radius: 18px 18px 0 0; box-shadow: var(--shadow); max-height: 52%; display: flex; flex-direction: column; transform: translateY(105%); transition: transform .22s ease; }
.sheet.open { transform: none; }
.sheet.min .sheet-body { display: none; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 6px 14px; border-bottom: 1px solid var(--line); flex: none; }
.sheet-head .grab { position: absolute; left: 50%; top: 4px; width: 38px; height: 4px; border-radius: 3px; background: var(--line); transform: translateX(-50%); }
.sheet-head h3 { margin: 0; font-size: 16px; flex: 1; display: flex; align-items: center; gap: 8px; }
.sheet-body { overflow-y: auto; padding: 8px 14px 14px; -webkit-overflow-scrolling: touch; }
.btn { border: 1px solid var(--line); background: var(--panel2); border-radius: 10px; padding: 9px 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; justify-content: center; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.blue { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.btn.danger { color: var(--err); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .45; }
.btn .ic { width: 18px; height: 18px; }
.row { display: flex; align-items: center; gap: 10px; padding: 7px 0; min-height: 44px; border-bottom: 1px solid var(--panel2); }
.row:last-child { border-bottom: 0; }
.row > label { flex: 1; min-width: 0; color: var(--text); font-size: 14px; }
.row > label small { display: block; color: var(--muted); font-size: 12px; }
.row .ctl { flex: 0 1 55%; display: flex; gap: 6px; justify-content: flex-end; align-items: center; min-width: 0; }
.num, .txt, select.sel { width: 100%; min-width: 0; border: 1px solid var(--line); background: var(--panel2); border-radius: 9px; padding: 9px 10px; font-size: 15px; outline: none; }
.num:focus, .txt:focus, select.sel:focus { border-color: var(--accent2); background: var(--panel); }
.num.bad { border-color: var(--err); color: var(--err); }
.unit { color: var(--muted); font-size: 13px; flex: none; }
.seg { display: flex; background: var(--panel2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; justify-content: flex-end; }
.seg button { border: 0; background: none; padding: 6px 10px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel2); border: 1px solid var(--line); border-radius: 16px; padding: 5px 10px; font-size: 13px; }
.chip.active { border-color: var(--accent); background: var(--accentSoft); color: var(--accent); font-weight: 600; }
.chip.err { border-color: var(--err); color: var(--err); }
.sw { position: relative; width: 46px; height: 28px; flex: none; }
.sw input { opacity: 0; width: 0; height: 0; position: absolute; }
.sw span { position: absolute; inset: 0; background: var(--line); border-radius: 14px; transition: .2s; }
.sw span::after { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.sw input:checked + span { background: var(--accent); }
.sw input:checked + span::after { transform: translateX(18px); }
.sel-box { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }
.err-msg { color: var(--err); font-size: 13px; padding: 6px 0; }
.note { color: var(--muted); font-size: 12.5px; padding: 6px 0; }
.group-title { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 14px 0 2px; font-weight: 700; }

/* drawer (browser / tree) */
.scrim { position: absolute; inset: 0; background: rgba(10, 15, 22, .35); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.show { opacity: 1; pointer-events: auto; }
.drawer { position: absolute; top: 0; bottom: 0; left: 0; width: min(86vw, 360px); background: var(--panel); z-index: 41; transform: translateX(-102%); transition: transform .22s ease; display: flex; flex-direction: column; box-shadow: var(--shadow); padding-top: var(--safeT); }
.drawer.right { left: auto; right: 0; transform: translateX(102%); }
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; padding: 10px 8px 10px 16px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { margin: 0; flex: 1; font-size: 17px; }
.drawer-body { overflow-y: auto; flex: 1; padding: 6px 0 calc(16px + var(--safeB)); }
.tree-sec { padding: 10px 16px 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; display: flex; align-items: center; }
.tree-sec span { flex: 1; }
.titem { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 16px; min-height: 46px; }
.titem:active { background: var(--panel2); }
.titem .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titem .nm small { display: block; color: var(--muted); font-size: 12px; }
.titem.err .nm { color: var(--err); }
.titem.suppressed .nm { text-decoration: line-through; opacity: .55; }
.titem.rolled { opacity: .4; }
.titem .ic.lead { color: var(--muted); }
.titem.sel { background: var(--accentSoft); }
.swatch { width: 18px; height: 18px; border-radius: 5px; border: 1px solid rgba(0, 0, 0, .15); flex: none; }
.rollbar { margin: 2px 16px; height: 4px; background: var(--accent); border-radius: 2px; }
.menu-item { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border: 0; background: none; width: 100%; text-align: left; font-size: 15px; }
.menu-item:active { background: var(--panel2); }
.menu-item .ic { color: var(--muted); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 0; }

/* popover menu */
.pop { position: absolute; z-index: 60; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px 0; min-width: 210px; max-height: 70vh; overflow-y: auto; }
.pop .menu-item { padding: 10px 16px; }

/* dialogs */
.modal-wrap { position: fixed; inset: 0; z-index: 80; background: rgba(10, 15, 22, .45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--panel); border-radius: 16px; box-shadow: var(--shadow); width: min(100%, 460px); max-height: 88vh; display: flex; flex-direction: column; }
.modal h3 { margin: 0; padding: 16px 18px 6px; font-size: 17px; }
.modal .mbody { padding: 6px 18px; overflow-y: auto; }
.modal .mfoot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px 16px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: calc(130px + var(--safeB)); transform: translateX(-50%); background: #26313d; color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 90; font-size: 14px; box-shadow: var(--shadow); max-width: 90vw; text-align: center; animation: fadein .2s; }
.toast.err { background: #a42b2b; }
@keyframes fadein { from { opacity: 0; transform: translate(-50%, 10px); } }

/* home / projects */
.home { position: absolute; inset: 0; z-index: 50; background: var(--bg); display: flex; flex-direction: column; }
.home-head { background: var(--bar); color: var(--barText); padding: calc(18px + var(--safeT)) 18px 18px; display: flex; align-items: center; gap: 12px; }
.home-head img { width: 44px; height: 44px; }
.home-head h1 { margin: 0; font-size: 22px; flex: 1; }
.home-head h1 small { display: block; font-size: 12.5px; font-weight: 400; color: var(--barMuted); }
.home-body { flex: 1; overflow-y: auto; padding: 14px 14px calc(30px + var(--safeB)); }
.home-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 18px; }
.big-action { border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; text-align: left; font-weight: 600; }
.big-action .ic { width: 28px; height: 28px; color: var(--accent); }
.big-action small { font-weight: 400; color: var(--muted); font-size: 12px; }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.proj { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; position: relative; }
.proj .thumb { aspect-ratio: 4/3; background: var(--viewport); display: flex; align-items: center; justify-content: center; }
.proj .thumb img { width: 100%; height: 100%; object-fit: cover; }
.proj .meta { padding: 8px 10px; }
.proj .meta b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.proj .meta small { color: var(--muted); font-size: 12px; }
.proj .ib { position: absolute; right: 2px; top: 2px; background: rgba(255, 255, 255, .7); width: 36px; height: 36px; color: #333; }
.h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; margin: 6px 2px 10px; }

/* sketch overlay widgets */
.dimedit { position: absolute; z-index: 25; display: flex; gap: 4px; background: var(--panel); border: 2px solid var(--accent2); border-radius: 10px; padding: 3px; box-shadow: var(--shadow); }
.dimedit input { width: 96px; border: 0; background: none; outline: none; padding: 6px; font-size: 16px; }
.dof { position: absolute; left: 8px; bottom: 8px; z-index: 6; font-size: 12px; padding: 4px 10px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.dof.full { color: var(--ok); border-color: var(--ok); }
.subbar { position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 7; display: flex; gap: 6px; overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 6px; box-shadow: var(--shadow); scrollbar-width: none; }
.subbar::-webkit-scrollbar { display: none; }
.subbar .tool { min-width: 58px; }

/* print / cam */
.layer-slider { position: absolute; right: 10px; top: 168px; bottom: 60px; width: 44px; z-index: 6; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.layer-slider input[type=range] { writing-mode: vertical-lr; direction: rtl; flex: 1; width: 36px; }
.layer-slider .lbl { font-size: 11px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 2px 5px; text-align: center; }
.statbar { position: absolute; left: 8px; top: 8px; right: 60px; z-index: 6; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 12.5px; box-shadow: 0 2px 8px rgba(0, 0, 0, .1); line-height: 1.5; }
.statbar b { font-size: 14px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.player { position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 6; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 6px 8px; display: flex; align-items: center; gap: 6px; box-shadow: var(--shadow); }
.player input[type=range] { flex: 1; min-width: 0; }
.player .t { font-size: 12px; color: var(--muted); min-width: 56px; text-align: right; }
.op-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 8px 0; display: flex; align-items: center; gap: 10px; background: var(--panel); }
.op-card .nm { flex: 1; min-width: 0; }
.op-card .nm small { display: block; color: var(--muted); font-size: 12px; }
.op-card.err { border-color: var(--err); }
.empty { text-align: center; color: var(--muted); padding: 24px 12px; font-size: 14px; }
.empty .ic { width: 40px; height: 40px; display: block; margin: 0 auto 8px; opacity: .5; }
pre.code { background: var(--panel2); border-radius: 10px; padding: 10px; font-size: 12px; max-height: 40vh; overflow: auto; white-space: pre; user-select: text; }
textarea.txt { min-height: 90px; font-family: ui-monospace, monospace; font-size: 13px; }
table.ptab { width: 100%; border-collapse: collapse; }
table.ptab td { padding: 4px 3px; }
.kbd-help td { padding: 3px 6px; font-size: 13px; }

@media (min-width: 900px) {
  .sheet { left: auto; right: 12px; bottom: 12px; top: 12px; width: 380px; max-height: none; border-radius: 18px; transform: translateX(110%); }
  .sheet.open { transform: none; }
  .tool { min-width: 74px; }
}

/* drawing workspace */
.drawing-stage { position: absolute; inset: 0; z-index: 3; background: var(--bg); overflow: hidden; touch-action: none; }
.drawing-svg { position: absolute; left: 0; top: 0; transform-origin: 0 0; box-shadow: 0 4px 22px rgba(10, 20, 35, .25); background: #fff; }
.tab { font-size: 13px; padding: 7px 2px; gap: 4px; min-width: 0; }
.tab span.lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 420px) { .tab { font-size: 11.5px; gap: 2px; flex-direction: column; padding: 5px 1px; } .tab .ic { width: 18px; height: 18px; } }
table.bom { border-collapse: collapse; min-width: 640px; font-size: 13px; }
table.bom th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 4px; }
table.bom td { padding: 3px; vertical-align: middle; }
table.bom td:first-child, table.bom td:nth-child(2) { text-align: center; font-weight: 600; width: 34px; }
table.bom .txt { padding: 6px 8px; font-size: 13px; }
.tab .ic { width: 17px; height: 17px; }
/* guided assembly demo */
.demo-card { position: absolute; left: 8px; right: 8px; top: 8px; z-index: 7; max-width: 560px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.demo-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; }
.demo-head b { color: var(--accent); }
.demo-text { font-size: 13px; line-height: 1.3; }
.demo-text.muted { color: var(--muted); font-size: 12px; }
.demo-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.demo-btns .btn { padding: 6px 10px; font-size: 13px; }
.demo-btns .btn .ic { width: 15px; height: 15px; }
.demo-btns .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.demo-off { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.demo-head .ib { width: 30px; height: 30px; }

/* workspace switcher (replaces the tab row) */
.ws-switch { display: flex; align-items: center; gap: 6px; border: 0; background: rgba(255, 255, 255, .08); color: var(--barText); border-radius: 10px; padding: 7px 8px 7px 10px; font-weight: 700; font-size: 14px; flex: none; margin: 0 2px; }
.ws-switch .ic { width: 20px; height: 20px; }
.ws-switch .chev { width: 16px; height: 16px; opacity: .7; }
.ws-switch.ws-design .ic:first-child { color: #63a8ff; } .ws-switch.ws-assembly .ic:first-child { color: #ff9a52; }
.ws-switch.ws-drawing .ic:first-child { color: #3fd3cb; } .ws-switch.ws-print .ic:first-child { color: #b592ff; } .ws-switch.ws-cnc .ic:first-child { color: #4fd18b; }
@media (max-width: 380px) { .ws-switch .lbl { display: none; } }
.menu-item small { display: block; color: var(--muted); font-size: 12px; margin-left: auto; padding-left: 10px; }
.menu-item.ws-item.on { background: var(--accentSoft); }
.menu-item.ws-design .ic { color: var(--t-blue); } .menu-item.ws-assembly .ic { color: var(--t-orange); } .menu-item.ws-drawing .ic { color: var(--t-teal); }
.menu-item.ws-print .ic { color: var(--t-purple); } .menu-item.ws-cnc .ic { color: var(--t-green); }

/* coloured tool icons, one colour per kind of tool */
.tool.t-blue .ic { color: var(--t-blue); } .tool.t-orange .ic { color: var(--t-orange); } .tool.t-green .ic { color: var(--t-green); }
.tool.t-purple .ic { color: var(--t-purple); } .tool.t-teal .ic { color: var(--t-teal); } .tool.t-red .ic, .tool.t-red .glyph { color: var(--t-red); }
.tool.t-yellow .ic { color: var(--t-yellow); }
.tool.on .ic, .tool.on .glyph { color: #fff !important; }
.cat.t-blue.on { color: var(--t-blue); } .cat.t-orange.on { color: var(--t-orange); } .cat.t-green.on { color: var(--t-green); }
.cat.t-purple.on { color: var(--t-purple); } .cat.t-teal.on { color: var(--t-teal); } .cat.t-red.on { color: var(--t-red); } .cat.t-yellow.on { color: var(--t-yellow); }
/* long-press tool guides */
.th-wrap { position: fixed; inset: 0; z-index: 80; background: rgba(5, 10, 16, .45); display: flex; align-items: flex-end; justify-content: center; padding: 10px; padding-bottom: calc(10px + var(--safeB)); }
.th-card { width: 100%; max-width: 460px; max-height: 92%; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 10px 14px 12px; display: flex; flex-direction: column; gap: 8px; animation: thIn .18s ease; }
@keyframes thIn { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.th-head { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.th-head b { flex: 1; }
.th-ic { display: inline-flex; width: 36px; height: 36px; border-radius: 10px; background: var(--panel2); align-items: center; justify-content: center; min-width: 0; padding: 0; }
.th-ic .ic { width: 24px; height: 24px; }
.th-ic .glyph { font-size: 20px; color: var(--t-red); }
.th-canvas { width: 100%; border-radius: 12px; display: block; border: 1px solid var(--line); }
.th-what { font-size: 14px; line-height: 1.4; }
.th-steps { margin: 0; padding-left: 20px; font-size: 13.5px; line-height: 1.4; color: var(--text); }
.th-steps li { margin: 2px 0; }
.th-btns { display: flex; gap: 8px; }
.th-btns .btn { flex: 1; }
.th-tip { font-size: 11.5px; color: var(--muted); text-align: center; }
/* history timeline strip above the toolbar */
.timeline { flex: none; display: flex; align-items: center; gap: 0; overflow-x: auto; scrollbar-width: none; background: var(--panel2); border-top: 1px solid var(--line); padding: 5px 6px; z-index: 15; }
.timeline::-webkit-scrollbar { display: none; }
.tl-head { flex: none; width: 34px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); display: flex; align-items: center; justify-content: center; margin-right: 6px; padding: 0; }
.tl-head .ic { width: 18px; height: 18px; }
.tl-empty { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.tl-chip { flex: none; display: flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px 0 7px; border-radius: 15px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 12.5px; font-weight: 600; white-space: nowrap; max-width: 150px; }
.tl-chip span { overflow: hidden; text-overflow: ellipsis; }
.tl-chip .ic { width: 17px; height: 17px; flex: none; }
.tl-chip.t-blue .ic { color: var(--t-blue); } .tl-chip.t-orange .ic { color: var(--t-orange); } .tl-chip.t-green .ic { color: var(--t-green); }
.tl-chip.t-purple .ic { color: var(--t-purple); } .tl-chip.t-red .ic { color: var(--t-red); }
.tl-chip.on { border-color: var(--accent); background: var(--accentSoft); }
.tl-chip.err { border-color: var(--err); color: var(--err); }
.tl-chip.suppressed span { text-decoration: line-through; opacity: .6; }
.tl-chip.rolled { opacity: .4; }
.tl-link { flex: none; width: 10px; height: 2px; background: var(--line); }
.tl-roll { flex: none; display: flex; align-items: center; height: 30px; margin: 0 4px; padding: 0 8px; border: 0; border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; background: var(--accentSoft); color: var(--accent); font-size: 11.5px; font-weight: 700; white-space: nowrap; }
/* quick tools and view buttons in the top bar (they used to float over the model) */
.quick { flex: 0 1 auto; min-width: 0; display: flex; align-items: center; overflow-x: auto; scrollbar-width: none; gap: 0; }
.quick::-webkit-scrollbar { display: none; }
.quick > div { display: flex; align-items: center; }
.quick .float { position: static; flex-direction: row; gap: 0; z-index: auto; }
.quick .float + .float, .quick > div + div { border-left: 1px solid rgba(255, 255, 255, .12); margin-left: 4px; padding-left: 4px; }
.quick .fbtn { width: 38px; height: 38px; flex: none; background: transparent; border: 0; box-shadow: none; color: var(--barText); border-radius: 10px; }
.quick .fbtn .ic { width: 21px; height: 21px; }
.quick .fbtn.on { background: var(--accent); color: #fff; }
.quick .fbtn.q-teal .ic { color: #3fd3cb; }
.topbar .title { flex: 1 1 70px; }
@media (max-width: 640px) {
  .topbar .title { display: none; }
  .quick { flex: 1 1 auto; -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); padding-right: 18px; }
  .ws-switch .lbl { display: none; }
  .ws-switch { padding: 7px 6px; }
  .topbar .ib { width: 40px; }
}
/* Simple / Full tool sets */
.tool.more-tools .ic { color: var(--muted); }
.menu-item.tone-blue .ic { color: var(--t-blue); } .menu-item.tone-orange .ic { color: var(--t-orange); } .menu-item.tone-green .ic { color: var(--t-green); }
.menu-item.tone-purple .ic { color: var(--t-purple); } .menu-item.tone-teal .ic { color: var(--t-teal); } .menu-item.tone-yellow .ic { color: var(--t-yellow); } .menu-item.tone-red { color: var(--t-red); }
.mode-pick { display: flex; flex-direction: column; gap: 10px; }
.mode-card { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); }
.mode-card b { font-size: 15px; }
.mode-card span { font-size: 13px; color: var(--muted); line-height: 1.35; }
.mode-card.on { border-color: var(--accent); background: var(--accentSoft); }
/* SpaceMouse: on-screen menu and live test */
.sm-menu { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 90; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 10px 12px; max-width: 94vw; }
.sm-title { font-weight: 700; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.sm-items { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.sm-item { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 62px; padding: 8px 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font-size: 12px; }
.sm-item .ic { width: 24px; height: 24px; color: var(--t-teal); }
.sm-item.on { border-color: var(--accent); background: var(--accentSoft); }
.sm-hint { font-size: 11.5px; color: var(--muted); text-align: center; margin-top: 6px; }
.sm-bars { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.sm-bar { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.sm-bar label { width: 92px; flex: none; color: var(--muted); }
.sm-track { position: relative; flex: 1; height: 10px; border-radius: 5px; background: var(--panel2); border: 1px solid var(--line); overflow: hidden; }
.sm-track::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--muted); }
.sm-fill { position: absolute; top: 0; bottom: 0; background: var(--t-teal); }
.sm-btns { display: flex; gap: 8px; margin: 4px 0 8px; }
.sm-btn { font-size: 12px; padding: 4px 10px; border-radius: 10px; border: 1px solid var(--line); color: var(--muted); }
.sm-btn.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* find a tool */
.cat-search { margin-left: auto; display: flex; align-items: center; gap: 4px; color: var(--text); }
.cat-search .ic { width: 16px; height: 16px; }
.ts-wrap { position: fixed; inset: 0; z-index: 90; background: rgba(5, 10, 15, .45); display: flex; justify-content: center; align-items: flex-start; padding: calc(10px + var(--safeT, 0px)) 10px 10px; }
.ts-card { width: 100%; max-width: 560px; max-height: 78vh; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.ts-head { display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 12px; border-bottom: 1px solid var(--line); }
.ts-mag .ic { width: 20px; height: 20px; color: var(--muted); }
.ts-input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font-size: 17px; padding: 8px 4px; outline: none; }
.ts-list { overflow-y: auto; padding: 6px; }
.ts-note { color: var(--muted); font-size: 14px; padding: 8px 6px; }
.ts-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 6px 8px; }
.ts-item { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 10px; cursor: pointer; }
.ts-item:active, .ts-item.first { background: var(--panel2); }
.ts-ic.tool { min-width: 0; width: 40px; height: 40px; padding: 0; justify-content: center; flex: none; pointer-events: none; }
.ts-ic .glyph { font-size: 20px; }
.ts-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ts-txt b { font-size: 15px; }
.ts-txt small { color: var(--muted); font-size: 12.5px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* send to… and printer status */
.send-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--panel2); border-radius: 12px; padding: 10px 12px; margin: 6px 0; color: var(--text); }
.send-item:active { background: var(--accentSoft); }
.send-ic .ic { width: 24px; height: 24px; color: var(--accent); }
.send-txt { display: flex; flex-direction: column; min-width: 0; }
.send-txt b { font-size: 15px; }
.send-txt small { color: var(--muted); font-size: 12.5px; }
.send-check { margin: 8px 0; padding-left: 18px; line-height: 1.5; }
.note.ok { color: var(--ok); }
.pst-state { font-size: 18px; font-weight: 700; margin: 4px 0; }
.pst-bar { height: 10px; border-radius: 6px; background: var(--panel2); border: 1px solid var(--line); overflow: hidden; margin: 8px 0 4px; }
.pst-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.pst-pct, .pst-temps { font-size: 13.5px; color: var(--muted); margin-top: 4px; }
/* messages sit near the top while a bottom panel is open, so they don't cover it */
@media (max-width: 899px) { body:has(.sheet.open) .toast { bottom: auto; top: calc(64px + var(--safeT, 0px)); } }
/* Find stays pinned at the right of the category row, even when the categories scroll */
.cat-search { position: sticky; right: 0; background: var(--panel); box-shadow: -10px 0 10px -4px var(--panel); flex: none; }

/* backup & sync status on the home screen */
.sync-chip { display: flex; align-items: center; gap: 8px; width: 100%; margin: 12px 0 2px; padding: 9px 12px; border-radius: 12px; border: 1px dashed var(--line); background: var(--panel); color: var(--muted); font-size: 13.5px; text-align: left; }
.sync-chip .ic { width: 20px; height: 20px; color: var(--accent2); flex: none; }
.sync-chip.on { border-style: solid; color: var(--text); }
.sync-chip.on .ic { color: var(--ok); }
.sync-chip.err { border-color: var(--err); color: var(--err); }
.sync-chip.err .ic { color: var(--err); }
