:root {
  --bg: #0f1115;
  --glass: rgba(22, 25, 32, 0.72);
  --glass-border: rgba(255, 255, 255, 0.08);
  --text: #e8ebf2;
  --muted: #8a92a6;
  --accent: #7c9cff;
  --accent-2: #4be3c2;
  --hover: rgba(255, 255, 255, 0.06);
  --on: rgba(124, 156, 255, 0.18);
  --radius: 12px;
  --x: #ff5d6c; --y: #5ee07a; --z: #5aa7ff;
  font-family: "Inter", "Cantarell", "Ubuntu", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
body.light-ui {
  --glass: rgba(255, 255, 255, 0.78);
  --glass-border: rgba(0, 0, 0, 0.08);
  --text: #1b1f2a;
  --muted: #5d6578;
  --hover: rgba(0, 0, 0, 0.05);
  --on: rgba(80, 110, 230, 0.15);
  --accent: #4b6bff;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-size: 13px; }
#viewport { position: fixed; inset: 0; }
#viewport canvas { display: block; outline: none; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.glass {
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.28);
}

/* top bar */
.topbar {
  position: fixed; top: 12px; left: 12px; right: 12px; height: 52px;
  display: flex; align-items: center; gap: 10px; padding: 0 10px 0 14px;
  border-radius: 14px; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 15px; letter-spacing: .2px; font-weight: 500; }
.brand b { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 700; }
.divider { width: 1px; height: 24px; background: var(--glass-border); margin: 0 4px; }
.spacer { flex: 1; }
.filename { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.filename.has { color: var(--text); font-weight: 500; }

button { font: inherit; color: inherit; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px;
  border-radius: 9px; border: 1px solid var(--glass-border); background: var(--hover);
  transition: transform .12s, background .15s, box-shadow .15s;
}
.btn.primary { background: linear-gradient(135deg, var(--accent), #6a7dff 60%, var(--accent-2)); border: 0; color: #fff; font-weight: 600; box-shadow: 0 4px 16px rgba(124, 156, 255, .35); }
.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 6px 22px rgba(124, 156, 255, .5); }
.btn svg { width: 16px; height: 16px; }
.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px;
  border: 0; background: transparent; color: var(--muted); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.on { color: var(--accent); background: var(--on); }
.icon-btn.small { width: 30px; height: 30px; }

.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--hover); gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; color: var(--muted); font-weight: 500; transition: all .15s; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--on); color: var(--text); box-shadow: inset 0 0 0 1px rgba(124, 156, 255, .35); }
.seg.small button { padding: 5px 11px; }

/* side panel */
.panel {
  position: fixed; top: 76px; left: 12px; bottom: 12px; width: 280px; border-radius: 14px; z-index: 9;
  display: flex; flex-direction: column; overflow: hidden; transition: transform .25s cubic-bezier(.2, .8, .2, 1), opacity .2s;
}
.panel.hidden { transform: translateX(-310px); opacity: 0; pointer-events: none; }
.panel section { padding: 14px 16px; border-bottom: 1px solid var(--glass-border); }
.panel section.grow { flex: 1; min-height: 0; display: flex; flex-direction: column; border: 0; }
.panel h3 { margin: 0 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); font-weight: 600; }
.panel h3 small { text-transform: none; letter-spacing: 0; font-weight: 400; opacity: .8; }
.stats { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.stats div { min-width: 0; }
.stats dt { color: var(--muted); font-size: 11px; }
.stats dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dims { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.dim { background: var(--hover); border-radius: 9px; padding: 7px 8px; display: flex; flex-direction: column; gap: 2px; border-top: 2px solid; }
.dim span { font-size: 10px; font-weight: 700; }
.dim b { font-variant-numeric: tabular-nums; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dim.x { border-color: var(--x); } .dim.x span { color: var(--x); }
.dim.y { border-color: var(--y); } .dim.y span { color: var(--y); }
.dim.z { border-color: var(--z); } .dim.z span { color: var(--z); }

.toggles { display: grid; grid-template-columns: 1fr; gap: 7px; }
.tgl { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.tgl input { display: none; }
.tgl i { width: 30px; height: 17px; border-radius: 10px; background: rgba(127, 127, 127, .3); position: relative; transition: background .2s; flex: none; }
.tgl i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.tgl input:checked + i { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.tgl input:checked + i::after { transform: translateX(13px); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.row:first-child { margin-top: 0; }
.lbl { color: var(--muted); }
.swatches { display: flex; gap: 6px; }
.swatches button { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; background: var(--c); box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .4); }
.swatches button.on { border-color: var(--accent); }

input[type=range] { width: 100%; margin-top: 12px; accent-color: var(--accent); }
input[type=range]:disabled { opacity: .35; }

.tree { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; min-height: 0; margin-right: -8px; padding-right: 4px; }
.tree li { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 7px; cursor: pointer; }
.tree li:hover { background: var(--hover); }
.tree li.off { opacity: .4; }
.tree li.empty { color: var(--muted); cursor: default; }
.tree li.empty:hover { background: none; }
.tree .sw { width: 12px; height: 12px; border-radius: 4px; flex: none; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .2); }
.tree .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree .eye { color: var(--muted); display: grid; }
.tree .eye svg { width: 15px; height: 15px; }
.tree::-webkit-scrollbar { width: 6px; }
.tree::-webkit-scrollbar-thumb { background: rgba(127, 127, 127, .35); border-radius: 3px; }

/* quick views */
.views {
  position: fixed; top: 72px; right: 12px; z-index: 8; display: flex; align-items: center; gap: 1px; padding: 3px; border-radius: 10px;
}
.views button { border: 0; background: transparent; color: var(--muted); padding: 3px 7px; border-radius: 6px; font-size: 11px; font-weight: 500; line-height: 16px; display: grid; place-items: center; }
.views button svg { width: 13px; height: 13px; }
.views button:hover { background: var(--hover); color: var(--text); }
.vdiv { width: 1px; height: 14px; background: var(--glass-border); margin: 0 3px; }
.hint { position: fixed; right: 14px; bottom: 16px; padding: 5px 9px; border-radius: 8px; color: var(--muted); font-size: 10px; z-index: 7; }

/* empty / drop */
.empty-state { position: fixed; inset: 0; display: grid; place-items: center; z-index: 5; pointer-events: none; transition: opacity .3s; }
body.panel-open .empty-state { left: 292px; }
.empty-state.hidden { display: none; }
.empty-state.hidden .card { pointer-events: none; }
.card { pointer-events: auto; text-align: center; padding: 44px 48px; border-radius: 22px; border: 1.5px dashed rgba(124, 156, 255, .35); background: rgba(20, 23, 30, .45); max-width: 560px; backdrop-filter: blur(6px); }
body.light-ui .card { background: rgba(255, 255, 255, .55); }
.logo-big { width: 96px; height: 96px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 26px; background: radial-gradient(circle at 30% 20%, rgba(124, 156, 255, .25), transparent 70%); animation: float 4s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px); } }
.card h1 { margin: 0 0 6px; font-size: 22px; font-weight: 650; }
.card p { margin: 6px 0; color: var(--muted); }
.card .muted { font-size: 12px; margin-top: 16px; }
.link { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 0; }
.link:hover { text-decoration: underline; }
.formats { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; margin-top: 18px; }
.formats span { font-size: 10.5px; font-weight: 600; letter-spacing: .4px; padding: 3px 7px; border-radius: 6px; background: var(--hover); color: var(--muted); border: 1px solid var(--glass-border); }
.drop-overlay { position: fixed; inset: 0; z-index: 50; display: none; place-items: center; background: rgba(124, 156, 255, .12); border: 3px dashed var(--accent); font-size: 22px; font-weight: 600; backdrop-filter: blur(3px); }
.drop-overlay.on { display: grid; }

/* loading */
.loading { position: fixed; inset: 0; z-index: 40; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: rgba(10, 12, 16, .55); backdrop-filter: blur(4px); }
.loading.on { display: flex; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .12); border-top-color: var(--accent); border-right-color: var(--accent-2); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading .bar { width: 220px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.loading .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .15s; }
#loadingText { color: #e8ebf2; }

.toast { position: fixed; top: 80px; left: 50%; transform: translate(-50%, -10px); opacity: 0; z-index: 60; padding: 10px 16px; border-radius: 10px; background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(14px); transition: all .25s; pointer-events: none; max-width: 70vw; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(255, 93, 108, .5); }

@media (max-width: 760px) {
  .seg#modeSeg, .hint, .filename { display: none; }
  .panel { width: calc(100% - 24px); }
  body.panel-open .empty-state { left: 50%; }
  body.panel-open .empty-state { left: 0; }
}

/* ---------------------------------------------------------------- design */
.tbtn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 11px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); font-weight: 550; transition: background .15s, color .15s; }
.tbtn:hover { background: var(--hover); color: var(--text); }
.tbtn.on { background: var(--on); color: var(--text); box-shadow: inset 0 0 0 1px rgba(124, 156, 255, .35); }
.tbtn svg { width: 17px; height: 17px; }
.menu-wrap { position: relative; }
.menu { position: absolute; top: 42px; left: 0; min-width: 220px; padding: 6px; border-radius: 12px; display: none; flex-direction: column; gap: 2px; z-index: 30; }
.menu.on { display: flex; }
.menu button { border: 0; background: transparent; text-align: left; padding: 8px 10px; border-radius: 8px; display: flex; flex-direction: column; gap: 1px; }
.menu button:hover { background: var(--hover); }
.menu button span { color: var(--muted); font-size: 11.5px; }

.floatbar { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 12; display: none; align-items: center; gap: 3px; padding: 6px; border-radius: 13px; white-space: nowrap; }
body.panel-open .floatbar { left: calc(50% + 146px); }
.floatbar.on { display: flex; }
.floatbar button { border: 0; background: transparent; color: var(--muted); padding: 6px 9px; border-radius: 8px; display: inline-flex; align-items: center; gap: 6px; font-weight: 550; }
.floatbar button:hover { background: var(--hover); color: var(--text); }
.floatbar button.on { background: var(--on); color: var(--text); box-shadow: inset 0 0 0 1px rgba(124, 156, 255, .35); }
.floatbar button svg { width: 17px; height: 17px; }
.floatbar .finish { background: linear-gradient(135deg, #2fbf8f, #4be3c2); color: #062b22; font-weight: 700; }
.floatbar .finish:hover { background: linear-gradient(135deg, #36d39f, #6af0d2); color: #062b22; }
.floatbar .vdiv { width: 1px; height: 22px; background: var(--glass-border); margin: 0 4px; }
.floatbar .sides { color: var(--muted); font-size: 12px; display: inline-flex; align-items: center; gap: 4px; margin-right: 4px; }
.floatbar input[type=number], .extpanel input[type=number], .extpanel select { font: inherit; color: var(--text); background: rgba(127, 127, 127, .14); border: 1px solid var(--glass-border); border-radius: 7px; padding: 4px 6px; outline: none; }
.floatbar input[type=number]:focus, .extpanel input:focus, .extpanel select:focus { border-color: var(--accent); }
.floatbar .sides input { width: 46px; }
.floatbar .ttl { font-weight: 650; padding: 0 8px 0 6px; }
.floatbar .sub { color: var(--muted); padding: 0 6px; font-size: 12px; }
.floatbar .pl { color: var(--text); background: var(--hover); }
.floatbar .pl.xy { box-shadow: inset 3px 0 0 #5aa7ff; } .floatbar .pl.xz { box-shadow: inset 3px 0 0 #5ee07a; } .floatbar .pl.yz { box-shadow: inset 3px 0 0 #ff5d6c; }
.floatbar .offset { color: var(--muted); font-size: 12px; display: inline-flex; align-items: center; gap: 5px; padding: 0 6px; }
.floatbar .offset input { width: 64px; }
button.ghost { border: 1px solid var(--glass-border) !important; background: transparent; color: var(--muted); padding: 6px 12px; border-radius: 8px; }
button.ghost:hover { color: var(--text); background: var(--hover); }

.extpanel { position: fixed; right: 14px; top: 108px; width: 250px; padding: 14px 16px 16px; border-radius: 14px; z-index: 12; display: none; flex-direction: column; gap: 6px; }
.extpanel.on { display: flex; }
.extpanel h4 { margin: 0 0 2px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.extpanel h4 svg { color: var(--accent); }
.extpanel .info { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.extpanel label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-top: 6px; font-weight: 600; }
.extpanel .dist { display: flex; align-items: center; gap: 6px; }
.extpanel .dist input { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; padding: 6px 8px; }
.extpanel .dist span { color: var(--muted); }
.extpanel #extFlip.on { color: var(--accent); background: var(--on); }
.extpanel select { width: 100%; padding: 6px; }
.extpanel .seg { width: 100%; display: flex; }
.extpanel .seg button { flex: 1; padding: 6px 4px; font-size: 12px; }
.extpanel .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.extpanel .actions .btn { height: 32px; }

.dimlabel { position: fixed; z-index: 45; pointer-events: none; padding: 4px 8px; border-radius: 7px; background: rgba(10, 12, 18, .82); color: #e8ebf2; font-size: 12px; font-variant-numeric: tabular-nums; display: none; white-space: nowrap; border: 1px solid rgba(124, 156, 255, .35); }
.dimlabel.on { display: block; }
.diminput { position: fixed; z-index: 46; display: none; width: 120px; font: inherit; font-weight: 600; padding: 5px 8px; border-radius: 7px; border: 1.5px solid var(--accent); background: rgba(10, 12, 18, .92); color: #fff; outline: none; box-shadow: 0 6px 20px rgba(0, 0, 0, .4); }

.panel { overflow-y: auto; }
.panel section.grow { min-height: 220px; }
.panel h3 .mini { float: right; border: 0; background: transparent; color: var(--muted); font-size: 11px; text-transform: none; letter-spacing: 0; padding: 0 4px; border-radius: 5px; }
.panel h3 .mini:hover { color: #ff7a8a; background: var(--hover); }
.tree.design { max-height: 260px; flex: none; }
.tree li.hdr { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); cursor: default; padding-top: 8px; }
.tree li.hdr:hover { background: none; }
.tree li.active { background: var(--on); }
.tree .sw { position: relative; overflow: hidden; cursor: pointer; }
.tree .sw input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; border: 0; padding: 0; }
.tree .ic, .tree .act { color: var(--muted); display: grid; place-items: center; }
.tree .ic svg, .tree .act svg { width: 15px; height: 15px; }
.tree .act { opacity: .55; }
.tree li:hover .act { opacity: 1; }
.tree .act:hover { color: var(--text); }
.tree .del:hover { color: #ff7a8a; }
.card .or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; margin: 22px 0 14px; }
.card .or::before, .card .or::after { content: ""; flex: 1; height: 1px; background: var(--glass-border); }
body[data-mode=sketch] .views, body[data-mode=sketch] .hint { opacity: .55; }
@media (max-width: 1500px) { .tbtn span { display: none; } .tbtn { padding: 0 9px; } }
@media (max-width: 1500px) { .tbtn.keep span { display: inline; } }
@media (max-width: 1250px) { .floatbar button span { display: none; } }
.seg button { white-space: nowrap; }

.floatbar .split { position: relative; display: inline-flex; align-items: center; }
.floatbar .split .caret { padding: 6px 3px; margin-left: -4px; }
.floatbar .split .caret svg { width: 14px; height: 14px; }
.floatbar .rmicon { display: inline-grid; }
.floatbar .menu { top: 40px; left: 0; }
.floatbar .menu button { display: flex; flex-direction: column; align-items: flex-start; color: var(--text); }
.floatbar .menu button.on { box-shadow: inset 3px 0 0 var(--accent); }
.floatbar .sides input#filletR { width: 52px; }
.dimlayer { position: fixed; inset: 0; pointer-events: none; z-index: 11; }
.dimtag { position: fixed; left: 0; top: 0; pointer-events: auto; cursor: pointer; padding: 1px 6px; border-radius: 6px; font-size: 11.5px; font-weight: 650; font-variant-numeric: tabular-nums;
  background: rgba(10, 14, 22, .85); color: #9fdcff; border: 1px solid rgba(127, 211, 255, .45); white-space: nowrap; user-select: none; }
.dimtag:hover { border-color: #ffd25d; color: #fff; }
.dimtag.sel { border-color: #ffb547; color: #ffb547; }

.tree li.sel { background: rgba(255, 181, 71, .16); box-shadow: inset 3px 0 0 #ffb547; }

/* history timeline */
.timeline { position: fixed; right: 12px; top: 108px; bottom: 56px; width: 52px; border-radius: 14px; z-index: 9; display: none; flex-direction: column; align-items: center; padding: 8px 0; }
.timeline.on { display: flex; }
.timeline .tlh { font-size: 9px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 700; margin-bottom: 6px; writing-mode: horizontal-tb; }
.timeline ol { list-style: none; margin: 0; padding: 0 6px; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; flex: 1; scrollbar-width: none; }
.timeline ol::-webkit-scrollbar { display: none; }
.timeline li { position: relative; }
.timeline .page { width: 34px; height: 40px; position: relative; cursor: pointer; border-radius: 4px 9px 4px 4px; background: var(--hover); border: 1px solid var(--glass-border); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; transition: transform .12s, border-color .12s, background .12s; }
.timeline .page::after { content: ""; position: absolute; top: -1px; right: -1px; width: 9px; height: 9px; background: linear-gradient(225deg, var(--bg) 50%, rgba(127,127,127,.35) 50%); border-radius: 0 8px 0 2px; }
.timeline .page svg { width: 14px; height: 14px; color: var(--accent); }
.timeline .page b { font-size: 10.5px; font-variant-numeric: tabular-nums; color: var(--text); line-height: 1; }
.timeline .page:hover { transform: translateX(-2px); border-color: var(--accent); background: var(--on); }
.timeline li.sketch .page svg { color: #ffb547; }
.timeline li.fillet .page svg { color: #4be3c2; }
.timeline li.revolve .page svg { color: #c77dff; }
.timeline li.transform .page svg, .timeline li.delete .page svg { color: var(--muted); }
.timeline li.error .page { border-color: #ff5d6c; background: rgba(255, 93, 108, .14); }
.timeline li.error .page svg { color: #ff5d6c; }
.timeline li.rolled .page { opacity: .35; }
.timeline li.editing .page { border-color: #ffd25d; box-shadow: 0 0 0 2px rgba(255, 210, 93, .35); }
.timeline li.marker::before { content: ""; position: absolute; left: -4px; right: -4px; top: -5px; height: 2px; background: #ffd25d; border-radius: 1px; }
.timeline .x { position: absolute; top: -6px; left: -7px; width: 16px; height: 16px; border-radius: 50%; border: 0; background: #ff5d6c; color: #fff; font-size: 11px; line-height: 16px; padding: 0; display: none; }
.timeline li:hover .x { display: block; }
body:has(.timeline.on) .extpanel { right: 74px; }
body:has(.timeline.on) .hint { right: 74px; }

/* selection bar */
.selbar { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 10; display: none; align-items: center; gap: 4px; padding: 5px 6px 5px 12px; border-radius: 12px; white-space: nowrap; }
body.panel-open .selbar { left: calc(50% + 146px); }
.selbar.on { display: flex; }
.selbar #selCount { font-weight: 650; margin-right: 6px; color: #ffb547; }
.selbar button { border: 0; background: transparent; color: var(--muted); padding: 6px 9px; border-radius: 8px; display: inline-flex; align-items: center; gap: 6px; font-weight: 550; }
.selbar button:hover { background: var(--hover); color: var(--text); }
.selbar button.on { background: var(--on); color: var(--text); box-shadow: inset 0 0 0 1px rgba(124,156,255,.35); }
.selbar button:disabled { opacity: .35; pointer-events: none; }
.selbar button svg { width: 16px; height: 16px; }
.selbar .info { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; padding: 0 6px; min-width: 10px; }
.selbar .x { font-size: 16px; padding: 4px 9px; }

/* dimension tags: |<--- 45 --->| */
.dimtag { display: inline-flex; align-items: center; gap: 4px; }
.dimtag i { font-style: normal; display: none; color: #ff7a8a; font-weight: 800; padding: 0 2px; cursor: pointer; }
.dimtag:hover i { display: inline; }
.dimtag.pending { border-color: #ffb547; color: #ffb547; pointer-events: none; }
#filSlider { margin-top: 8px; }

/* editable X/Y/Z */
.dim { cursor: text; }
.dim:hover { background: var(--on); }
.dim input { width: 100%; font: inherit; font-weight: 700; font-size: 13px; border: 0; outline: 1.5px solid var(--accent); border-radius: 4px; background: rgba(0,0,0,.25); color: var(--text); padding: 1px 3px; }
.panel h3 .mini.lock { float: right; }
.panel h3 .mini.lock.on { color: var(--accent); background: var(--on); }
body[data-mode=sketch] .toast { top: 124px; }

/* Hide / Show tab hanging off the panel's top-right corner */
.paneltab { position: fixed; top: 88px; left: 292px; z-index: 10; height: 30px; padding: 0 8px 0 10px; display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--glass-border); border-left: 0; border-radius: 0 10px 10px 0; background: var(--glass); backdrop-filter: blur(18px);
  color: var(--muted); font-size: 11.5px; font-weight: 650; letter-spacing: .3px; box-shadow: 6px 6px 20px rgba(0,0,0,.25);
  transition: left .25s cubic-bezier(.2, .8, .2, 1), color .15s, background .15s; }
.paneltab:hover { color: var(--text); background: var(--on); }
.paneltab svg { width: 14px; height: 14px; transition: transform .25s; }
body:not(.panel-open) .paneltab { left: 0; border-left: 1px solid var(--glass-border); border-radius: 0 10px 10px 0; color: var(--accent); }
body:not(.panel-open) .paneltab svg { transform: rotate(180deg); }
.tbtn.plate.on { background: linear-gradient(135deg, rgba(124,156,255,.3), rgba(75,227,194,.25)); color: var(--text); box-shadow: inset 0 0 0 1px rgba(75,227,194,.5); }
body.plate-mode #viewport canvas { cursor: grab; }
body.plate-mode.plate-dragging #viewport canvas { cursor: grabbing; }

/* 2D drawing sheet */
#drawing { position: fixed; inset: 0; z-index: 60; display: none; flex-direction: column; background: #3a3f4a; }
#drawing.on { display: flex; }
#drawing .dbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px; padding: 6px 10px; border-radius: 12px; font-size: 12px; }
#drawing .dtitle { font-size: 13px; margin-right: 4px; }
#drawing .dbar label { display: flex; align-items: center; gap: 5px; color: var(--muted); }
#drawing .dbar select { background: var(--hover); color: var(--text); border: 1px solid var(--glass-border); border-radius: 6px; padding: 3px 5px; font: inherit; }
#drawing .dbar .dchk input { margin: 0; }
#drawing .dspace { flex: 1; }
#drawing .dwrap { position: relative; flex: 1; overflow: hidden; cursor: grab; }
#drawing .dwrap:active { cursor: grabbing; }
#drawing .dpaper { position: absolute; left: 0; top: 0; transform-origin: 0 0; box-shadow: 0 8px 40px rgba(0,0,0,.45); line-height: 0; }
#drawing .dpaper svg { display: block; background: #fff; stroke: none; }
#drawing .dpaper .empty { fill: #eaf1ff; }
#drawing .dpaper .fld { fill: transparent; cursor: text; }
#drawing .dpaper .fld:hover { fill: rgba(75,107,255,.14); stroke: #4b6bff; stroke-width: .3; }
#drawing .dbusy { color: #fff; font-size: 14px; padding: 40px; line-height: 1.4; }
#drawing .dhint { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); color: rgba(255,255,255,.7); font-size: 11px; pointer-events: none; white-space: nowrap; }
.dedit { position: fixed; z-index: 70; box-sizing: border-box; font: 13px Helvetica, Arial, sans-serif; padding: 3px 6px; border: 2px solid #4b6bff; border-radius: 4px; background: #fff; color: #111; outline: none; resize: both; }
#drawing .dpaper .dtool { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; background: transparent; }
#drawing .dpaper .grab { fill: transparent; cursor: move; }
#drawing .dpaper .grab:hover, #drawing .dpaper .grab.sel { fill: rgba(47,107,255,.08); stroke: #2f6bff; stroke-width: .2; stroke-dasharray: .8 .6; }
#drawing .dpaper .vgrab { fill: transparent; cursor: move; }
#drawing .dpaper .vgrab:hover, #drawing .dpaper .vgrab.sel { stroke: #2f6bff; stroke-width: .25; stroke-dasharray: 1.5 1; }
#drawing .dbar .mini.on { background: var(--accent); color: #fff; }
#drawing.tooling .dwrap { cursor: crosshair; }
#drawing .dbody { flex: 1; display: flex; min-height: 0; }
#drawing .dside { width: 150px; margin: 0 0 8px 8px; padding: 8px; border-radius: 12px; display: flex; flex-direction: column; gap: 8px; }
#drawing .dpages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-right: 2px; }
#drawing .dpg { position: relative; cursor: pointer; border-radius: 6px; padding: 4px; border: 1px solid transparent; }
#drawing .dpg:hover { background: var(--hover); }
#drawing .dpg.on { border-color: var(--accent); background: var(--on); }
#drawing .dthumb { width: 100%; background: #fff; border-radius: 2px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
#drawing .dthumb img { display: block; width: 100%; height: 100%; }
#drawing .dpgname { display: flex; gap: 6px; align-items: baseline; margin-top: 4px; font-size: 11px; color: var(--text); white-space: nowrap; overflow: hidden; }
#drawing .dpgname b { color: var(--muted); font-weight: 600; }
#drawing .dpgname span { overflow: hidden; text-overflow: ellipsis; }
#drawing .dpgren { width: 100%; font: 11px inherit; padding: 1px 3px; border: 1px solid var(--accent); border-radius: 4px; background: var(--bg); color: var(--text); }
#drawing .dpgx { position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border: 0; border-radius: 4px; background: rgba(20,22,28,.75); color: #fff; font-size: 14px; line-height: 18px; cursor: pointer; display: none; }
#drawing .dpg:hover .dpgx { display: block; }
#drawing #dAdd { width: 100%; background: var(--hover); color: var(--text); border: 1px solid var(--glass-border); border-radius: 6px; padding: 5px; font: inherit; font-size: 12px; }
#drawing .dsidehead { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--muted); padding: 0 2px; }
#drawing .dlink { background: none; border: 0; color: var(--accent); font: inherit; font-size: 11px; cursor: pointer; padding: 0 3px; }
#drawing .dlink:hover { text-decoration: underline; }
#drawing .dpg.sel { background: var(--on); }
#drawing .dpg.sel .dthumb { outline: 2px solid var(--accent); outline-offset: 1px; }
#drawing .dpg.on { border-color: var(--accent); }
#drawing .dpgchk { position: absolute; top: 6px; left: 6px; width: 18px; height: 18px; display: none; align-items: center; justify-content: center; background: rgba(20,22,28,.7); border-radius: 4px; cursor: pointer; }
#drawing .dpgchk input { margin: 0; cursor: pointer; accent-color: var(--accent); }
#drawing .dpg:hover .dpgchk, #drawing .dpg.sel .dpgchk, #drawing.multisel .dpgchk { display: flex; }
#drawing .dbar .tbtn svg { width: 15px; height: 15px; }

/* yes/no question (e.g. "Keep original Meshes?" after a boolean) */
.askbox { position: fixed; top: 84px; left: 50%; transform: translateX(-50%); z-index: 70; padding: 14px 16px; border-radius: 12px; min-width: 260px; box-shadow: 0 14px 40px rgba(0,0,0,.35); }
.askbox p { margin: 0 0 12px; font-weight: 550; color: var(--text); }
.askbox .row { display: flex; gap: 8px; justify-content: flex-end; }

/* shown instead of the app when the browser has WebGL turned off */
.nogl { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px;
  background: rgba(10, 12, 17, .92); backdrop-filter: blur(6px); }
.nogl > div { max-width: 560px; background: #151922; border: 1px solid rgba(255,255,255,.1); border-radius: 16px;
  padding: 28px 30px; color: #dfe4ee; line-height: 1.55; font-size: 14px; }
.nogl h2 { margin: 0 0 12px; font-size: 19px; color: #fff; }
.nogl p { margin: 0 0 10px; }
.nogl code { background: rgba(255,255,255,.08); padding: 1px 6px; border-radius: 5px; user-select: all; }
