:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #f7f8fa;
  --line: #e3e7ed;
  --line-2: #d3d9e1;
  --text: #1c2430;
  --muted: #6b7686;
  --accent: #2563eb;
  --accent-soft: #e6eefe;
  --danger: #dc2626;
  --hole: #8f99a6;
  --radius: 8px;
  --viewport-bg: #eef2f7;
  font-family: "IBM Plex Sans Thai", system-ui, sans-serif;
  font-size: 13px;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

/* loading: dark stage so the neon logo glows */
#loading {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(ellipse at 50% 42%, #1a1440 0%, #0b1020 45%, #05070f 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  color: #cbd5e1;
}
#loading-text { margin-top: 14px; font-size: 13px; color: #94a3b8; }
#loading-version { font-size: 11px; color: #64748b; letter-spacing: .1em; }

/* account button (top bar) */
.topbar .account-btn {
  height: 30px; padding: 0 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--text); cursor: pointer;
}
.topbar .account-btn.state-guest, .topbar .account-btn.state-basic { background: linear-gradient(90deg, #22d3ee, #a855f7); color: #fff; border-color: transparent; }
.topbar .account-btn.state-trial { border-color: #22d3ee; color: #0e7490; }
.topbar .account-btn.state-member, .topbar .account-btn.state-owner { border-color: #a855f7; color: #7e22ce; }
.topbar .account-btn.state-dev { color: var(--muted); border-style: dashed; }
/* premium items in the shape library show a lock while not unlocked */
.lib-item.locked { position: relative; }
.lib-item.locked::after { content: '🔒'; position: absolute; top: 3px; right: 4px; font-size: 11px; opacity: .85; }
.lib-item.locked img { filter: grayscale(.6); opacity: .75; }
/* paywall / account / payment dialogs */
.paywall { text-align: center; }
.pw-lock { font-size: 34px; }
.acct-user { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.acct-user img { width: 40px; height: 40px; border-radius: 50%; }
.acct-state { padding: 8px 10px; border-radius: 8px; background: var(--panel-2); font-size: 13px; }
.acct-state.state-trial { background: rgba(34,211,238,.12); }
.acct-state.state-member, .acct-state.state-owner { background: rgba(168,85,247,.12); }
.pay-row { font-size: 12px; padding: 3px 0; }
.pay-approved { color: #1d7a4e; } .pay-rejected { color: #c2410c; }
.pay { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.pp-months { width: 100%; }
.pp-months button { white-space: nowrap; padding: 0 6px; }
.pp-box { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
.pp-qr { width: 220px; height: 220px; image-rendering: pixelated; }
.pp-amount { font-size: 20px; font-weight: 700; }
.pp-demo { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border: 2px dashed var(--line-2); border-radius: 10px; color: var(--muted); font-size: 13px; }
.legal-note { font-size: 11.5px; color: var(--muted); margin-top: 10px; }
.legal-note a { color: var(--accent); }
.pp-file { cursor: pointer; }

/* about / what's new */
.about-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.about-name { font-size: 20px; }
.changelog { max-height: 46vh; overflow-y: auto; font-size: 12.5px; line-height: 1.55; }
.cl-entry + .cl-entry { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.cl-head { margin-bottom: 4px; }
.changelog ul { margin: 0; padding-left: 18px; }
/* "new version available" */
.update-bar {
  position: fixed; right: 16px; bottom: 44px; z-index: 60; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px; background: #0b1020; color: #e2e8f0; font-size: 13px;
  box-shadow: 0 8px 28px rgba(0,0,0,.25), 0 0 0 1px rgba(168,85,247,.45);
}
.update-bar .btn { height: 28px; }
.update-bar .btn:not(.primary) { background: transparent; color: #e2e8f0; border-color: rgba(226,232,240,.35); }
.update-bar .ic { background: none; border: 0; color: #94a3b8; font-size: 18px; cursor: pointer; }
.update-dot { width: 9px; height: 9px; border-radius: 50%; background: #22d3ee; box-shadow: 0 0 10px #22d3ee; animation: kfHot .7s ease-in-out 6 alternate; }

/* ---- KaiForge logo: a cube of printed layers, hot nozzle, running neon light ---- */
.kf-logo { display: block; flex: none; overflow: visible; }
.kf-tile { fill: #0b1020; }
.kf-top { fill: #1a2742; }
.kf-left { fill: #111b30; }
.kf-right { fill: #0d1526; }
.kf-layers polyline { stroke: url(#kfGrad); stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.kf-edge { stroke: #33436a; stroke-width: 1.2; fill: none; stroke-linejoin: round; }
.kf-run { stroke: url(#kfGrad); stroke-width: 2.8; fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 18 82; opacity: 0; filter: url(#kfGlow); }
.kf-nozzle { fill: #e2e8f0; }
.kf-flow { stroke: #fbbf24; stroke-width: 1.2; stroke-linecap: round; opacity: .8; }
.kf-hot { fill: #fbbf24; filter: url(#kfGlow); }
.kf-word { font-weight: 800; letter-spacing: .08em; font-size: 14px; color: var(--text, #1c2024); }
.kf-word b {
  font-weight: 800;
  background: linear-gradient(90deg, #22d3ee, #a855f7, #f472b6, #22d3ee); background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.kf-word b { margin-left: .4em; }
.kf-dot { color: #22d3ee; margin: 0 .04em; }
.kf-big { font-size: 34px; letter-spacing: .12em; color: #f1f5f9; margin-top: 8px; }
.kf-tag { font-size: 11px; letter-spacing: .5em; color: #7dd3fc; opacity: .8; }

/* the light runs round the cube, the layers light up bottom → top like a print, the name shimmers */
@keyframes kfRun { 0% { stroke-dashoffset: 0; opacity: 0 } 8%, 88% { opacity: 1 } 100% { stroke-dashoffset: -100; opacity: 0 } }
@keyframes kfLayer { 0%, 100% { opacity: .2 } 30% { opacity: 1; stroke-width: 2.6 } 60% { opacity: .85 } }
@keyframes kfHot { from { opacity: .45 } to { opacity: 1 } }
@keyframes kfShine { from { background-position: 0% 0 } to { background-position: 100% 0 } }
.kf-layers polyline:nth-child(2) { animation-delay: .18s !important; }
.kf-layers polyline:nth-child(3) { animation-delay: .36s !important; }
.kf-layers polyline:nth-child(4) { animation-delay: .54s !important; }
.kf-layers polyline:nth-child(5) { animation-delay: .72s !important; }
/* loading screen: loops */
.kf-live .kf-run { animation: kfRun 1.8s linear infinite; }
.kf-live .kf-layers polyline { animation: kfLayer 1.8s ease-in-out infinite; }
.kf-live .kf-hot { animation: kfHot .5s ease-in-out infinite alternate; }
.kf-live .kf-word b { animation: kfShine 3s linear infinite; }
/* top bar: one pass now and then (and on hover) so it costs nothing while idle */
.brand.run .kf-run { animation: kfRun 1.8s linear 1; }
.brand.run .kf-layers polyline { animation: kfLayer 1.8s ease-in-out 1; }
.brand.run .kf-hot { animation: kfHot .45s ease-in-out 4 alternate; }
.brand.run .kf-word b { animation: kfShine 1.8s linear 1; }
@media (prefers-reduced-motion: reduce) {
  .kf-live *, .brand.run * { animation: none !important; }
  .kf-run { opacity: 0 !important; }
}
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--line-2); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* top bar */
.topbar {
  height: 48px; display: flex; align-items: center; gap: 6px; padding: 0 10px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  overflow-x: auto; overflow-y: hidden; white-space: nowrap;
}
.brand { display: flex; flex: none; align-items: center; gap: 8px; margin-right: 8px; cursor: default; }
.tb-group { display: flex; gap: 2px; padding: 0 6px; border-left: 1px solid var(--line); }
.topbar button, .view-tools button {
  display: inline-flex; align-items: center; gap: 5px; height: 32px; min-width: 32px; padding: 0 8px;
  border: 1px solid transparent; border-radius: 6px; background: transparent; cursor: pointer;
}
.topbar button:hover, .view-tools button:hover { background: var(--panel-2); border-color: var(--line); }
.topbar button.active, .view-tools button.active { background: var(--accent-soft); color: var(--accent); border-color: #c9dafc; }
.topbar button:disabled { opacity: .35; cursor: default; }
.topbar svg, .view-tools svg { width: 17px; height: 17px; stroke-width: 1.8; }
.topbar .tb-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.topbar .tb-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
.tb-quick { border-left: 0; }

/* menus: the commands sorted by what they do; the pop-ups are fixed-position (the bar scrolls sideways) */
.menubar { display: flex; gap: 1px; padding: 0 6px; border-left: 1px solid var(--line); }
.topbar .menu-btn { font-weight: 500; }
.topbar .menu-btn svg { width: 16px; height: 16px; color: var(--muted); }
.menu.open > .menu-btn { background: var(--accent-soft); color: var(--accent); border-color: #c9dafc; }
.menu.open > .menu-btn svg { color: var(--accent); }
.menu-btn:has(~ .menu-pop .active) { color: var(--accent); }
.menu-pop {
  display: none; position: fixed; z-index: 80; min-width: 290px; max-width: calc(100vw - 16px);
  max-height: calc(100vh - 64px); overflow-y: auto; padding: 5px; white-space: normal;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .16), 0 2px 6px rgba(15, 23, 42, .08);
}
.menu.open > .menu-pop { display: block; }
.topbar .menu-pop button {
  display: flex; width: 100%; height: auto; min-height: 40px; padding: 5px 10px; gap: 10px; text-align: left;
  border: 0; border-radius: 7px;
}
.topbar .menu-pop button:hover:not(:disabled) { background: var(--accent-soft); border-color: transparent; }
.topbar .menu-pop button.active { background: var(--accent-soft); }
.topbar .menu-pop svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.topbar .menu-pop button:hover:not(:disabled) svg, .topbar .menu-pop button.active svg { color: var(--accent); }
.menu-pop .mi { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.menu-pop .mi b { font-weight: 500; font-size: 13px; }
.menu-pop .mi small { font-size: 11.5px; color: var(--muted); }
.menu-pop kbd, .menu-kbd {
  flex: none; font: 11px/1 ui-monospace, Consolas, monospace; color: var(--muted);
  padding: 3px 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; background: var(--panel-2);
}
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }
.menu-cap { font-size: 11.5px; color: var(--muted); padding: 4px 10px 6px; }
/* narrower windows: menu names without icons, then the quick buttons as icons only */
@media (max-width: 1380px) { .topbar .menu-btn svg { display: none; } }
@media (max-width: 1180px) { .tb-quick span, .brand .kf-word { display: none; } }
@media (max-width: 1000px) {
  .topbar { gap: 2px; padding: 0 6px; scrollbar-width: thin; }
  .topbar button { min-width: 29px; padding: 0 5px; }
  .topbar .menu-btn { padding: 0 4px; font-size: 12px; }
  .menubar, .topbar .tb-group { padding: 0 3px; }
  .topbar .account-btn { max-width: 96px; overflow: hidden; text-overflow: ellipsis; padding: 0 9px; }
}

/* layout */
.workspace { display: flex; height: calc(100% - 48px - 28px); }
.panel { background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.panel.left { width: 216px; border-right: 1px solid var(--line); }
.panel.right { width: 280px; border-left: 1px solid var(--line); }
.panel-head { padding: 10px; border-bottom: 1px solid var(--line); }
.panel-head input {
  width: 100%; height: 30px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--panel-2);
}
.panel-section { display: flex; flex-direction: column; min-height: 0; flex: 1; border-bottom: 1px solid var(--line); }
.panel-section.grow-0 { flex: 0 1 auto; max-height: 62%; }
.section-title {
  padding: 9px 12px; font-weight: 600; font-size: 12px; letter-spacing: .02em;
  border-bottom: 1px solid var(--line); background: var(--panel-2); display: flex; gap: 6px;
}

/* library */
.library { overflow-y: auto; padding: 6px 10px 16px; }
.lib-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.lib-tabs button {
  display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 8px;
  border: 1px solid var(--line-2); border-radius: 999px; background: var(--panel); color: var(--muted);
  font-size: 11.5px; cursor: pointer; white-space: nowrap;
}
.lib-tabs button:hover { border-color: var(--accent); color: var(--accent); }
.lib-tabs button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.lib-tabs svg { width: 13px; height: 13px; stroke-width: 2; flex: none; }
.lib-cat {
  display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); font-weight: 600;
  margin: 12px 0 6px; padding: 3px 2px; border-radius: 5px; cursor: pointer; user-select: none;
}
.lib-cat:hover { color: var(--text); }
.lib-chev { width: 10px; flex: none; font-size: 10px; transition: transform .12s; }
.lib-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-count:not(:empty) { flex: none; font-weight: 500; font-size: 10.5px; padding: 0 5px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); }
.lib-head .lib-cat { margin-bottom: 1px; }
.lib-hint { font-size: 10.5px; line-height: 1.4; color: var(--muted); margin: 0 2px 6px 17px; }
[data-cat].folded .lib-chev { transform: rotate(-90deg); }
[data-cat].folded > :not(.lib-cat):not(.lib-head), [data-cat].folded .lib-hint { display: none; }
[data-cat].folded .lib-cat { margin-bottom: 0; }
.lib-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.lib-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 2px 6px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); cursor: grab;
  font-size: 11px; user-select: none; transition: border-color .12s, background .12s;
}
.lib-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.lib-item.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px #c9dafc; }
.lib-item img { width: 52px; height: 52px; pointer-events: none; }

/* viewport */
.viewport { position: relative; flex: 1; min-width: 0; background: var(--viewport-bg); overflow: hidden; }
.viewport canvas { display: block; outline: none; }
.view-tools {
  position: absolute; top: 10px; right: 10px; display: flex; gap: 2px; align-items: center; padding: 3px;
  background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 2px 8px rgba(20,30,50,.06);
}
.view-tools button { height: 28px; min-width: 28px; font-size: 12px; }
.view-tools button.vt-label { font-weight: 600; }
.view-tools .sep { width: 1px; height: 18px; background: var(--line); margin: 0 3px; }
.tool-hint {
  position: absolute; bottom: 58px; left: 50%; transform: translateX(-50%);
  background: #1c2430; color: #fff; padding: 7px 14px; border-radius: 8px; font-size: 12.5px;
  box-shadow: 0 4px 14px rgba(0,0,0,.18); pointer-events: none; max-width: 70%; text-align: center;
}
.dim-label, .measure-label {
  position: absolute; pointer-events: none; transform: translate(-50%, -100%);
  background: rgba(255,255,255,.95); border: 1px solid var(--line-2); border-radius: 6px;
  padding: 2px 7px; font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.measure-label { background: #fff7e6; border-color: #f0c36a; }
.toast {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: #1c2430; color: #fff; padding: 8px 16px; border-radius: 8px; font-size: 12.5px;
  box-shadow: 0 4px 14px rgba(0,0,0,.2);
}
.toast.error { background: var(--danger); }
/* pieces being built on the other CPU cores (js/build-pool.js) */
.build-busy {
  position: absolute; top: 56px; right: 12px; pointer-events: none;
  background: rgba(28, 36, 48, .82); color: #fff; padding: 5px 11px; border-radius: 14px; font-size: 11.5px;
}
.build-busy.hidden { display: none; }

/* props */
.props { overflow-y: auto; padding: 10px 12px 14px; }
.props .empty { color: var(--muted); line-height: 1.6; }
.prop-row { display: grid; grid-template-columns: 84px 1fr; align-items: center; gap: 8px; margin-bottom: 6px; }
.prop-row > label { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prop-group-title { font-size: 11.5px; font-weight: 600; color: var(--muted); margin: 12px 0 6px; }
.prop-sec { border-top: 1px solid var(--line); margin-top: 10px; }
.prop-sec > .fold-head {
  display: flex; align-items: center; gap: 5px; margin: 0 -4px; padding: 8px 4px 6px;
  cursor: pointer; user-select: none; border-radius: 5px; color: var(--text);
}
.prop-sec > .fold-head:hover { color: var(--accent); }
.prop-sec > .fold-head .lib-chev { color: var(--muted); }
.prop-sec.folded .lib-chev { transform: rotate(-90deg); }
.prop-sec.folded > .prop-body { display: none; }
.prop-body { padding-bottom: 2px; }
.prop-sub { font-size: 11px; color: var(--muted); margin: 8px 0 4px; }
.prop-body > .prop-sub:first-child { margin-top: 0; }
.xyz { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.num {
  position: relative; display: flex; align-items: center; height: 28px;
  border: 1px solid var(--line-2); border-radius: 6px; background: var(--panel); overflow: hidden;
}
.num:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.num b { font-size: 10px; padding: 0 0 0 6px; color: var(--muted); cursor: ew-resize; user-select: none; font-weight: 600; }
.num b.x { color: #d83b3b; } .num b.y { color: #2f9e44; } .num b.z { color: #2563eb; }
.num input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; padding: 0 6px; font-variant-numeric: tabular-nums; }
.txt {
  width: 100%; height: 28px; border: 1px solid var(--line-2); border-radius: 6px; padding: 0 8px; background: var(--panel);
}
textarea.txt { height: 54px; padding: 6px 8px; resize: vertical; }
.txt:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.seg { display: flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; }
.seg button { flex: 1; height: 28px; border: 0; background: var(--panel); cursor: pointer; font-size: 12px; }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.on { background: var(--accent); color: #fff; }
.seg button.on.hole { background: #6b7686; }
.color-row { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.fit-info { font-size: 11.5px; line-height: 1.5; padding: 7px 9px; margin: 8px 0 4px; border-radius: 7px; background: rgba(48, 164, 108, .1); color: #1d7a4e; }
.fit-info.warn { background: rgba(229, 72, 77, .1); color: #c62a2f; }
.swatch-select { display: flex; align-items: center; gap: 6px; }
.swatch-select .swatch { flex: none; cursor: default; }
.slot-note { font-size: 11.5px; line-height: 1.5; color: var(--muted, #6b7280); margin: 0 0 8px; }
.mylib-head { display: flex; justify-content: space-between; align-items: center; }
.mylib-actions { display: flex; gap: 8px; margin-left: auto; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font-size: 11px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.mylib-empty { font-size: 11px; line-height: 1.5; color: var(--muted, #6b7280); padding: 4px 2px 10px; }
.mylib-item { position: relative; }
.mylib-del { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border: 0; border-radius: 50%; background: rgba(0,0,0,.45); color: #fff; font-size: 12px; line-height: 18px; padding: 0; cursor: pointer; opacity: 0; }
.mylib-item:hover .mylib-del { opacity: 1; }
.sample-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 5px; margin-bottom: 8px; }
.sample-item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 3px 3px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel); cursor: pointer; min-width: 0; }
.sample-item img { width: 44px; height: 44px; background: #fff; border-radius: 6px; }
.sample-item small { font-size: 10px; line-height: 1.2; text-align: center; color: var(--muted, #6b7280); }
.sample-item:hover { border-color: var(--accent); }
.sample-item.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.drop-zone { border: 1.5px dashed var(--line-2); border-radius: 8px; padding: 12px 8px; text-align: center; font-size: 12px; color: var(--muted, #6b7280); cursor: pointer; margin-bottom: 8px; }
.drop-zone:hover, .drop-zone.over { border-color: var(--accent); background: var(--accent-soft); }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 3px; max-height: 180px; overflow-y: auto; margin-bottom: 8px; }
.emoji-grid button { font-size: 20px; height: 34px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--panel); cursor: pointer; }
.emoji-grid button:hover { border-color: var(--accent); }
.layer-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.kc-add { flex-wrap: wrap; }
.kc-add button { flex: 1 1 40%; }
.kc-join { flex-wrap: wrap; margin-bottom: 4px; }
.kc-join button { flex: 1 1 22%; padding-left: 2px; padding-right: 2px; white-space: nowrap; }
.kc-join-note { font-size: 11.5px; line-height: 1.5; margin-bottom: 8px; }
.kc-items { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.kc-item { border: 1px solid var(--line-2); border-radius: 8px; padding: 6px; background: var(--panel); }
.kc-item.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.kc-item-head { display: flex; align-items: center; gap: 5px; font-size: 12px; margin-bottom: 5px; }
.kc-item-head img { width: 24px; height: 24px; flex: none; background: #fff; border-radius: 5px; border: 1px solid var(--line-2); }
.kc-item-head .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.kc-item-head .ic { width: 24px; height: 24px; flex: none; border: 1px solid var(--line-2); border-radius: 6px; background: var(--panel); cursor: pointer; padding: 0; font-size: 12px; }
.kc-item-head .ic:hover { background: var(--panel-2); }
.kc-item > .txt { width: 100%; margin-bottom: 5px; }
.kc-item-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.layer-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.font-label { font-size: 12px; color: var(--muted, #6b7280); margin: 6px 0 4px; }
.font-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 5px; max-height: 214px; overflow-y: auto; padding: 2px; margin-bottom: 8px; }
.font-chip { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 4px 3px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--panel); cursor: pointer; min-width: 0; }
.font-chip:hover { border-color: var(--accent); }
.font-chip.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.font-sample { font-size: 17px; line-height: 1.35; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.font-chip small { font-size: 10.5px; color: var(--muted, #6b7280); white-space: nowrap; }
.swatch { width: 20px; height: 20px; border-radius: 5px; border: 1px solid rgba(0,0,0,.12); cursor: pointer; padding: 0; }
.swatch.on { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }
input[type=color] { width: 26px; height: 22px; padding: 0; border: 1px solid var(--line-2); border-radius: 5px; background: none; cursor: pointer; }
.info-grid { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 12px; font-variant-numeric: tabular-nums; }
.info-grid span:nth-child(odd) { color: var(--muted); }
.btn {
  height: 30px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--panel); cursor: pointer;
}
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }
.cmd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.cmd-grid .btn { min-width: 0; padding: 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.warn { background: #fff4e5; border: 1px solid #f5c67a; color: #8a5300; border-radius: 6px; padding: 6px 8px; font-size: 12px; margin-bottom: 8px; }

/* outliner */
.outliner { overflow-y: auto; padding: 4px 0; flex: 1; }
.ol-item {
  display: flex; align-items: center; gap: 6px; height: 28px; padding-right: 6px; cursor: pointer; user-select: none;
}
.ol-item:hover { background: var(--panel-2); }
.ol-item.sel { background: var(--accent-soft); }
.ol-item .dot { width: 11px; height: 11px; border-radius: 3px; flex: none; border: 1px solid rgba(0,0,0,.15); }
.ol-item .dot.hole { background: repeating-linear-gradient(45deg, #b8c0ca 0 2px, #fff 2px 4px) !important; }
.ol-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ol-item .name input { width: 100%; height: 22px; border: 1px solid var(--accent); border-radius: 4px; padding: 0 4px; }
.ol-item .ic { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 4px; color: var(--muted); border: 0; background: none; cursor: pointer; padding: 0; }
.ol-item .ic:hover { background: var(--line); color: var(--text); }
.ol-item .ic svg { width: 14px; height: 14px; }
.ol-item .tw { width: 14px; flex: none; color: var(--muted); font-size: 10px; text-align: center; }
.ol-item.child { color: var(--muted); cursor: default; }
.ol-item.dim .name { opacity: .45; }

/* resizable side panels */
.splitter { width: 5px; margin: 0 -2px; flex: none; cursor: col-resize; position: relative; z-index: 5; }
.splitter::after { content: ''; position: absolute; top: 0; bottom: 0; left: 2px; width: 1px; background: transparent; transition: background .12s; }
.splitter:hover::after, .splitter.dragging::after { background: var(--accent); width: 2px; left: 1px; }
.panel.collapsed { display: none; }
.panel { flex: none; }

/* status */
.statusbar {
  height: 28px; display: flex; align-items: center; gap: 16px; padding: 0 12px;
  border-top: 1px solid var(--line); background: var(--panel); font-size: 12px; font-variant-numeric: tabular-nums;
}
.st-btn { height: 22px; padding: 0 8px; border: 1px solid var(--line-2); border-radius: 5px; background: var(--panel); cursor: pointer; font-size: 12px; }
.st-btn:hover { border-color: var(--accent); color: var(--accent); }
.hud-warn { color: #b45309; font-weight: 500; }
.statusbar select { height: 22px; border: 1px solid var(--line-2); border-radius: 5px; background: var(--panel); margin-left: 4px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(16,24,40,.35); display: grid; place-items: center; z-index: 50; }
.modal-card {
  width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 60px); overflow-y: auto;
  background: var(--panel); border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.25); padding: 18px 20px;
}
.modal-card h3 { margin: 0 0 12px; font-size: 16px; }
.modal-card .prop-row { grid-template-columns: 120px 1fr; }
.modal-card .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; font-size: 12.5px; }
kbd {
  display: inline-block; padding: 1px 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px;
  background: var(--panel-2); font-family: inherit; font-size: 11.5px; white-space: nowrap;
}
.choice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.choice-grid .btn { height: 34px; }

/* measuring & reference annotations */
.annot-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.axis-tick, .axis-end {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap; pointer-events: none;
  font-size: 10.5px; font-weight: 500; font-variant-numeric: tabular-nums;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 2px #fff;
}
.axis-end { font-size: 13px; font-weight: 700; }
.guide-tag, .measure-tag, .ruler-tag, .dim-tag {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap; pointer-events: auto;
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 6px; border-radius: 6px;
  font-size: 11.5px; font-variant-numeric: tabular-nums; box-shadow: 0 1px 4px rgba(20, 30, 50, .12);
}
.guide-tag { background: #ecfeff; border: 1px solid #67e8f9; color: #0e7490; }
.guide-tag.preview { background: #fff7e6; border-color: #f0c36a; color: #8a5300; pointer-events: none; }
.guide-tag span { cursor: pointer; }
.measure-tag { background: #fff7e6; border: 1px solid #f0c36a; }
.ruler-tag { background: #f1f5f9; border: 1px solid #cbd5e1; color: #334155; font-size: 11px; }
.guide-tag button, .measure-tag button, .ruler-tag button {
  border: 0; background: none; cursor: pointer; padding: 0 2px; font-size: 13px; line-height: 1; color: inherit; opacity: .6;
}
.guide-tag button:hover, .measure-tag button:hover, .ruler-tag button:hover { opacity: 1; }
.dim-tag { background: #fff; border: 1px solid #94a3b8; color: #1e293b; }
.dim-tag .dl { color: #64748b; font-size: 10.5px; }
.dim-tag.editable { cursor: text; }
.dim-tag.editable:hover { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.dim-input { width: 64px; border: 0; outline: 0; font: inherit; text-align: center; }
.coord-hud {
  position: absolute; left: 112px; bottom: 10px; display: flex; flex-direction: column; gap: 2px;
  background: rgba(255, 255, 255, .94); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px;
  font-size: 12px; font-variant-numeric: tabular-nums; box-shadow: 0 2px 8px rgba(20, 30, 50, .06);
}
.coord-hud > div { display: flex; align-items: center; gap: 10px; }
.coord-hud .hl { color: var(--muted); min-width: 74px; font-size: 11.5px; }
.coord-hud .hv { font-weight: 500; }
.hud-btn { height: 20px; padding: 0 8px; border: 1px solid var(--line-2); border-radius: 5px; background: var(--panel); cursor: pointer; font-size: 11px; }

/* floating tool panels (sketch, fillet) */
.float-bar {
  position: absolute; top: 56px; left: 12px; width: 270px; padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 4px 14px rgba(20,30,50,.1);
}
/* pre-print check (js/print-panel.js) */
.check-panel {
  position: absolute; top: 52px; right: 10px; width: 300px; max-height: calc(100% - 120px); overflow-y: auto;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px;
  background: rgba(255,255,255,.97); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 4px 14px rgba(20,30,50,.12);
}
.check-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.check-head b { font-size: 13.5px; }
.check-head .check-busy { flex: 1; font-size: 11.5px; }
.check-row { display: grid; grid-template-columns: 16px 12px 1fr auto; gap: 6px; align-items: center; padding: 3px 2px; border-radius: 6px; cursor: pointer; }
.check-row:hover { background: rgba(20,30,50,.04); }
.check-row input { margin: 0; }
.check-row.bad .check-val { color: #c62a2f; font-weight: 600; }
.check-sw { width: 12px; height: 12px; border-radius: 3px; }
.check-label { line-height: 1.35; }
.check-val { white-space: nowrap; color: #60646c; }
.check-summary { margin: 6px 0 2px; padding: 6px 9px; border-radius: 7px; font-weight: 600; }
.check-summary.good { background: rgba(48,164,108,.12); color: #1d7a4e; }
.check-summary.bad { background: rgba(245,158,11,.14); color: #9a5b00; }
.check-list { display: flex; flex-direction: column; gap: 6px; }
.check-tip { display: flex; gap: 8px; align-items: center; line-height: 1.45; }
.check-tip span { flex: 1; }
.check-tip .btn { flex: none; height: 26px; padding: 0 10px; }
.check-note { color: #60646c; padding: 4px 0; }
.check-note.warn { color: #c62a2f; }
.check-foot { display: flex; align-items: center; gap: 8px; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 11.5px; }
.check-foot span { flex: 1; }
.check-foot .btn { height: 26px; padding: 0 10px; }
/* cost and selling price (main.js costDialog) */
.cost-out { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.cost-line { display: flex; justify-content: space-between; gap: 12px; padding: 4px 2px; font-size: 13px; border-bottom: 1px dashed var(--line); }
.cost-line b { font-weight: 600; text-align: right; }
.cost-line.total { border-bottom: 1px solid var(--line-2); margin-top: 4px; }
.cost-line.price { font-size: 15px; color: #1d7a4e; background: rgba(48,164,108,.1); border-radius: 7px; padding: 7px 8px; border: 0; margin: 4px 0; }
.cost-settings summary { cursor: pointer; font-size: 12.5px; color: var(--accent); margin: 4px 0 8px; }
.litho-preview { display: block; width: 100%; height: auto; border-radius: 8px; margin: 4px 0 10px; box-shadow: 0 0 0 1px var(--line), 0 6px 18px rgba(255, 190, 90, .25); background: #111; }
/* clearance test prints: pick the slot that fitted best */
.calib-slots { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 2px; }
.calib-slots button { min-width: 42px; height: 30px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--panel); cursor: pointer; font-size: 12.5px; }
.calib-slots button.on { background: #2563eb; border-color: #2563eb; color: #fff; font-weight: 600; }
.calib-slots button small { display: block; font-size: 9.5px; opacity: .7; line-height: 1; }
.wp-badge {
  position: absolute; top: 10px; left: 10px; display: flex; align-items: center; gap: 8px;
  background: #fff4e5; border: 1px solid #f5c67a; color: #8a5300; border-radius: 8px; padding: 4px 6px 4px 10px; font-size: 12px;
}
.wp-badge button { height: 24px; padding: 0 8px; border-radius: 5px; border: 1px solid #f0c36a; background: #fff; cursor: pointer; font-size: 12px; }
.rot-block { margin-top: 6px; }
.rot-row { display: grid; grid-template-columns: 14px 50px repeat(4, 1fr); gap: 4px; margin-bottom: 4px; align-items: center; }
.rot-axis { font-size: 12px; text-align: center; }
.rot-axis.x, .rot-cur.x { color: #d83b3b; } .rot-axis.y, .rot-cur.y { color: #2f9e44; } .rot-axis.z, .rot-cur.z { color: #2563eb; }
.rot-cur {
  height: 26px; display: grid; place-items: center; border-radius: 6px; background: var(--panel-2);
  border: 1px solid var(--line); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.rot-btn {
  height: 26px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--panel); cursor: pointer;
  font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap; padding: 0;
}
.rot-btn:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.size-chips { display: flex; gap: 4px; }
.size-chips button {
  flex: 1; height: 26px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--panel);
  cursor: pointer; font-size: 12px; font-variant-numeric: tabular-nums;
}
.size-chips button:hover { background: var(--panel-2); }
.size-chips button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.feat-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.feat-row .feat-name { flex: 1; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feat-row .num { width: 92px; flex: none; }
.feat-row.sub { margin-top: -2px; padding-left: 14px; }
.feat-row.sub .num { width: 74px; }
.feat-row .ic { width: 26px; height: 26px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--panel); cursor: pointer; padding: 0; }
.feat-row .ic:hover { background: var(--panel-2); }

.check-row { display: flex; align-items: center; gap: 8px; font-size: 12px; margin: 2px 0 8px; cursor: pointer; }

/* inside the SketchUp plugin window (body.in-sketchup, see js/sketchup.js) */
body:not(.in-sketchup) .sk-only { display: none !important; }
#sk-group button { background: rgba(0, 144, 255, .08); }
.sk-badge { font-size: 9.5px; font-weight: 700; color: #fff; background: #d6452b; border-radius: 4px; padding: 0 4px; line-height: 15px; flex: none; }

@media (max-width: 900px) {
  .panel.left { width: 160px; }
  .panel.right { width: 230px; }
  .lib-grid { grid-template-columns: repeat(2, 1fr); }
}

/* SketchUp panel mode (body.sk-panel, ?host=sketchup — js/main.js): SketchUp's own viewport is the
   workspace; this window is a narrow panel with two tabs, the shape library and the properties of
   the K·CAD pieces selected in SketchUp. The 3D view and everything that works on it is hidden. */
.sk-tabs { display: none; }
body.sk-panel .topbar > .tb-group:not(#sk-group):not(.keep),
body.sk-panel .topbar > .menubar,
body.sk-panel .topbar [data-action="help"],
body.sk-panel .splitter,
body.sk-panel #viewport,
body.sk-panel #outliner-section,
body.sk-panel .panel.right .section-title,
body.sk-panel #library [data-cat="holes"],
body.sk-panel .statusbar > :not(#st-sel):not(.spacer):not(#st-ver),
body.sk-panel[data-sk-tab="library"] .panel.right,
body.sk-panel:not([data-sk-tab="library"]) .panel.left { display: none !important; }
body.sk-panel .topbar { gap: 4px; padding: 0 8px; }
body.sk-panel .brand { margin-right: 2px; }
body.sk-panel .brand .kf-word { font-size: 12.5px; letter-spacing: .05em; }
body.sk-panel .topbar .tb-group { padding: 0 4px; }
body.sk-panel .workspace { flex-direction: column; }
body.sk-panel .sk-tabs {
  display: flex; flex: none; gap: 6px; padding: 7px 10px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.sk-tabs button {
  flex: 1; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px;
  border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel); color: var(--muted);
  font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.sk-tabs button:hover { border-color: var(--accent); color: var(--accent); }
.sk-tabs button.on { background: var(--accent-soft); border-color: #c9dafc; color: var(--accent); }
.sk-tabs svg { width: 16px; height: 16px; stroke-width: 1.8; flex: none; }
.sk-count:not(:empty) {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff;
  font-size: 11px; line-height: 18px; text-align: center;
}
body.sk-panel .panel { width: auto !important; flex: 1 1 auto; border: 0; }
.sk-check { display: none; }
body.sk-panel[data-sk-tab="check"] .panel.right { display: none !important; }
body.sk-panel[data-sk-tab="check"] .sk-check { display: block; flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px 12px 18px; font-size: 12.5px; }
.sk-check .btn-row .btn { flex: 1; }
.sk-check-rows { margin-top: 8px; }
body.sk-panel .panel-section.grow-0 { flex: 1 1 auto; max-height: none; border-bottom: 0; }
body.sk-panel .props { padding: 12px 12px 18px; }
body.sk-panel .lib-grid { grid-template-columns: repeat(3, 1fr); }
body.sk-panel .lib-item { cursor: pointer; font-size: 11.5px; text-align: center; }
body.sk-panel .lib-item img { width: 60px; height: 60px; }
body.sk-panel .toast, body.sk-panel .tool-hint {
  position: fixed; z-index: 70; width: max-content; max-width: calc(100vw - 24px); text-align: center;
}
body.sk-panel .toast { bottom: 38px; }
body.sk-panel .tool-hint { bottom: 84px; }
body.sk-panel .update-bar { left: 8px; right: 8px; flex-wrap: wrap; }
.sk-pieces { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.sk-piece {
  display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; text-align: left;
  border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel); cursor: pointer;
}
.sk-piece:hover:not(:disabled) { border-color: var(--accent); }
.sk-piece.on { background: var(--accent-soft); border-color: var(--accent); }
.sk-piece:disabled { cursor: default; background: var(--panel-2); }
.sk-piece .dot { width: 12px; height: 12px; border-radius: 3px; flex: none; border: 1px solid rgba(0,0,0,.15); }
.sk-piece .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sk-piece .muted { font-size: 11.5px; flex: none; }
.sk-note { font-size: 11.5px; line-height: 1.5; color: var(--muted); margin: 0 0 8px; padding: 6px 9px; border-radius: 7px; background: var(--panel-2); }
.sk-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 28px 10px; text-align: center; color: var(--muted); line-height: 1.6; }
.sk-empty .sk-note { align-self: stretch; }
.sk-empty p { margin: 0 0 8px; }
@media (max-width: 430px) {
  body.sk-panel .brand .kf-word { display: none; }
}
@media (min-width: 560px) {
  body.sk-panel .lib-grid { grid-template-columns: repeat(4, 1fr); }
}
