:root {
  --bg: #121316;
  --panel: #1a1c20;
  --panel-2: #202227;
  --line: #2b2e34;
  --text: #d9dbe0;
  --muted: #8a8f99;
  --accent: #d4a85a;
  --accent-2: #f0c97f;
  --focus: #5b8cff;
  --radius: 6px;
  font-family: Inter, system-ui, sans-serif;
  font-size: 12.5px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
kbd { font-family: Inter, sans-serif; font-size: 10px; background: #2a2d33; border: 1px solid #383c44; border-bottom-width: 2px; padding: 0 4px; border-radius: 3px; color: #b9bdc6; }

#app { display: grid; height: 100vh; grid-template-columns: 230px 1fr 320px; grid-template-rows: 42px 1fr 24px; grid-template-areas: "top top top" "left vp right" "status status status"; }
#app.no-panels { grid-template-columns: 0 1fr 0; }
#app.no-panels .panel { display: none; }

#topbar { grid-area: top; display: flex; align-items: center; gap: 10px; padding: 0 10px; background: #16171a; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--accent-2); font-size: 13.5px; letter-spacing: 0.02em; padding-right: 8px; }
.brand span { color: var(--text); } .brand b { color: var(--accent-2); font-weight: 600; }
.menus { display: flex; gap: 2px; }
.menu { position: relative; }
.menu > button { padding: 6px 10px; border-radius: 5px; color: #c2c6ce; }
.menu > button:hover, .menu.open > button { background: #262930; color: #fff; }
.dropdown { display: none; position: absolute; top: 100%; left: 0; min-width: 240px; background: #1f2126; border: 1px solid #33363e; border-radius: 8px; padding: 5px; box-shadow: 0 14px 40px rgba(0,0,0,.5); z-index: 50; }
.menu.open .dropdown { display: block; }
.dropdown button { display: flex; justify-content: space-between; width: 100%; padding: 7px 10px; border-radius: 5px; text-align: left; }
.dropdown button:hover { background: #2d3139; }
.dropdown hr { border: 0; border-top: 1px solid #2f323a; margin: 4px 2px; }
.design-name { background: transparent; border: 1px solid transparent; color: var(--text); font: inherit; font-weight: 500; padding: 5px 8px; border-radius: 5px; width: 200px; }
.design-name:hover, .design-name:focus { border-color: #3a3e46; outline: none; background: #1d1f23; }
.spacer { flex: 1; }
.seg { display: flex; background: #1f2125; border: 1px solid #30333a; border-radius: 7px; padding: 2px; }
.seg button { padding: 5px 12px; border-radius: 5px; color: var(--muted); }
.seg button.on { background: #30343c; color: #fff; }
.primary { background: linear-gradient(180deg, #e2b665, #c39446); color: #1b1407 !important; font-weight: 600; padding: 7px 14px; border-radius: 6px; }
.primary:hover { filter: brightness(1.08); }

.panel { background: var(--panel); overflow-y: auto; overflow-x: hidden; }
#left { grid-area: left; border-right: 1px solid var(--line); }
#right { grid-area: right; border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.panel-title { padding: 12px 12px 6px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); display: flex; justify-content: space-between; }
.panel-title .hint { text-transform: none; letter-spacing: 0; opacity: .7; }
.oitem { display: flex; align-items: center; gap: 8px; padding: 6px 12px; cursor: pointer; border-left: 2px solid transparent; }
.oitem:hover { background: #20232a; }
.oitem.sel { background: #262a33; border-left-color: var(--accent); color: #fff; }
.oitem .ico { width: 16px; text-align: center; color: var(--accent); opacity: .85; }
.oitem .name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.oitem .eye { opacity: .55; padding: 0 2px; } .oitem .eye:hover { opacity: 1; }
.oitem.hidden .name { opacity: .4; }
.shortcuts { padding: 0 12px 14px; color: var(--muted); line-height: 2; font-size: 11.5px; }
#partsList:empty::after { content: 'No custom parts yet'; display: block; padding: 4px 12px 8px; color: #666b74; font-style: italic; }

.tabs { display: flex; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 2; }
.tabs button { flex: 1; padding: 10px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: #fff; border-bottom-color: var(--accent); }
.props-header { padding: 12px 14px 4px; font-size: 15px; font-weight: 600; color: #fff; display: flex; align-items: center; gap: 8px; }
.props-header small { font-weight: 400; color: var(--muted); font-size: 11px; }
.props { padding: 0 0 30px; }
.section { padding: 6px 14px 10px; border-bottom: 1px solid #23262c; }
.section-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--accent); margin: 8px 0 8px; }
.field { display: grid; grid-template-columns: 108px 1fr; align-items: center; gap: 8px; margin: 6px 0; min-height: 26px; }
.field.tall { align-items: start; }
.field > label { color: #aeb2bb; font-size: 12px; }
.field select, .field input[type=text], .field textarea, .field input.num {
  width: 100%; background: #121316; border: 1px solid #30333a; border-radius: 5px; color: var(--text); padding: 5px 7px; font: inherit; }
.field textarea { resize: vertical; min-height: 44px; }
.field select:focus, .field input:focus, .field textarea:focus { outline: none; border-color: var(--focus); }
.range { display: grid; grid-template-columns: 1fr 54px 22px; align-items: center; gap: 6px; }
.range .unit { color: var(--muted); font-size: 10.5px; }
.field input.num { padding: 4px 5px; text-align: right; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; background: #33363e; border-radius: 2px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%; background: var(--accent-2); margin-top: -5px; box-shadow: 0 0 0 3px rgba(212,168,90,.18); }
input[type=range]::-moz-range-track { height: 3px; background: #33363e; }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--accent-2); border: 0; }
.colorrow { display: flex; gap: 6px; align-items: center; }
.colorrow input[type=color] { width: 34px; height: 26px; border: 1px solid #30333a; border-radius: 5px; background: #121316; padding: 2px; cursor: pointer; }
.colorrow .hex { flex: 1; font-family: ui-monospace, monospace; font-size: 11.5px; }
.mini { background: #262930; border: 1px solid #343840 !important; padding: 4px 9px; border-radius: 5px; font-size: 11px; }
.matrow { display: flex; gap: 6px; align-items: center; }
.matrow .swatch { width: 16px; height: 16px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2), inset -3px -3px 6px rgba(0,0,0,.35); }
.switch { position: relative; width: 34px; height: 19px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #33363e; border-radius: 10px; transition: .15s; cursor: pointer; }
.switch span::after { content: ''; position: absolute; width: 15px; height: 15px; left: 2px; top: 2px; background: #c9ccd3; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(15px); background: #fff; }
.btnrow { display: flex; gap: 6px; margin-top: 8px; }
.btnrow button { flex: 1; }

#viewport { grid-area: vp; position: relative; overflow: hidden; background: #0d0d0f; }
#c { width: 100%; height: 100%; display: block; outline: none; }
.vp-toolbar { position: absolute; left: 12px; top: 12px; display: flex; flex-direction: column; gap: 2px; background: rgba(26,28,32,.85); border: 1px solid #30333a; border-radius: 8px; padding: 3px; backdrop-filter: blur(6px); }
.vp-toolbar button { width: 30px; height: 28px; border-radius: 5px; color: #b8bcc5; font-size: 15px; }
.vp-toolbar button.on { background: #383c45; color: var(--accent-2); }
.vp-toolbar .sep { height: 1px; background: #33363e; margin: 2px 4px; }
.vp-views { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 2px; background: rgba(26,28,32,.8); border: 1px solid #30333a; border-radius: 8px; padding: 3px; backdrop-filter: blur(6px); }
.vp-views button { padding: 4px 10px; border-radius: 5px; color: #b8bcc5; font-size: 11.5px; }
.vp-views button:hover { background: #2f333b; color: #fff; }
.vp-explode { position: absolute; right: 12px; bottom: 12px; display: flex; align-items: center; gap: 8px; background: rgba(26,28,32,.85); border: 1px solid #30333a; border-radius: 8px; padding: 6px 10px; color: var(--muted); font-size: 11px; }
.vp-explode input { width: 130px; }
#app.mode-render .vp-toolbar, #app.mode-render .vp-views, #app.mode-render .vp-explode { opacity: 0; pointer-events: none; transition: opacity .2s; }
#app.mode-render #viewport:hover .vp-views { opacity: .9; pointer-events: auto; }
#loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: #0d0d0f; color: var(--muted); transition: opacity .4s; z-index: 5; }
#loading.done { opacity: 0; pointer-events: none; }
.spinner { width: 34px; height: 34px; border: 2px solid #2a2d33; border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#fitPanel { position: absolute; left: 12px; bottom: 12px; max-width: 440px; background: rgba(40,16,18,.92); border: 1px solid #a3343d; color: #ffd9dc; border-radius: 8px; padding: 9px 12px; font-size: 12px; line-height: 1.45; z-index: 5; }
#fitPanel b { color: #fff; display: block; margin-bottom: 3px; }
#fitPanel .ok { color: #9fd8a6; }
#fitPanel .dim { color: #c9a3a7; }
#toast { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px); background: #24272d; border: 1px solid #3a3e46; padding: 8px 14px; border-radius: 8px; opacity: 0; transition: .25s; pointer-events: none; }
#toast.show { opacity: 1; transform: translateX(-50%); }

#status { grid-area: status; display: flex; align-items: center; gap: 12px; padding: 0 12px; background: #16171a; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }

dialog { background: #1d1f24; color: var(--text); border: 1px solid #353941; border-radius: 12px; padding: 18px 20px; min-width: 380px; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
dialog::backdrop { background: rgba(0,0,0,.55); backdrop-filter: blur(3px); }
dialog h3 { margin: 0 0 12px; font-weight: 600; }
#photoDlg .hint { font-size: 12px; opacity: .7; margin: -4px 0 12px; max-width: 420px; }
.photo-angles { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }
.photo-angles label { display: flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap; }
.ask-dlg { max-width: 460px; }
.ask-dlg p { margin: 0; line-height: 1.5; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dlg-actions button { padding: 7px 14px; border-radius: 6px; background: #2a2d34; }
/* the action a dialog is for keeps its gold: the rule above is more specific than .primary */
.dlg-actions button.primary { background: linear-gradient(#e2b665, #c39446); }
.preset-grid { display: grid; grid-template-columns: repeat(4, 150px); gap: 10px; }
.preset-card { background: #15161a; border: 1px solid #30333a; border-radius: 10px; padding: 10px; text-align: left; display: flex; flex-direction: column; gap: 6px; }
.preset-card:hover { border-color: var(--accent); }
.preset-card .dot { width: 100%; aspect-ratio: 1; border-radius: 50%; box-shadow: inset 0 0 0 5px rgba(255,255,255,.12), inset 0 0 0 7px rgba(0,0,0,.4), 0 6px 14px rgba(0,0,0,.4); }
.preset-card b { font-weight: 600; font-size: 12px; }
@media (max-width: 1100px) { #app { grid-template-columns: 190px 1fr 290px; } .vp-views { display: none; } }

.info { color: var(--muted); font-size: 11.5px; line-height: 1.6; margin: 4px 0 6px; }
.bench-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.bench-tools input[type=search] { flex: 1; min-width: 180px; background: #121316; border: 1px solid #30333a; border-radius: 6px; color: var(--text); padding: 7px 9px; font: inherit; }
.bench-tools select { background: #121316; border: 1px solid #30333a; border-radius: 6px; color: var(--text); padding: 6px; font: inherit; }
.bench-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; max-height: 58vh; overflow: auto; padding-right: 4px; }
.bench-group { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 8px; margin: 8px 2px 0; font-size: 12.5px; font-weight: 600; }
.bench-group:first-child { margin-top: 0; }
.bench-group small { margin-left: auto; color: var(--muted); font-weight: 400; font-size: 11px; }
.bench-card { display: flex; gap: 10px; align-items: center; text-align: left; background: #15161a; border: 1px solid #30333a; border-radius: 10px; padding: 8px 10px; }
.bench-card:hover { border-color: var(--accent); }
.bench-card .dot { width: 38px; height: 38px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 3px rgba(255,255,255,.18), 0 3px 8px rgba(0,0,0,.4); }
.bench-card b { display: block; font-weight: 600; font-size: 12.5px; }
.bench-card small { color: var(--muted); font-size: 11px; line-height: 1.4; display: block; }
.bench-card small.saved-here { color: var(--accent); }
.bench-card input { margin-left: auto; }
.bench-status { color: var(--muted); font-size: 12px; margin-top: 10px; min-height: 18px; }
#benchDlg { width: min(980px, 92vw); }
#designDlg { width: 96vw; height: 94vh; max-width: none; max-height: none; padding: 12px 14px; }
#designDlg[open] { display: flex; flex-direction: column; gap: 8px; }
.design-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.design-head h3 { margin: 0 8px 0 0; }
.design-head .bench-status { flex: 1; margin: 0; }
#designFrame { flex: 1; width: 100%; border: 1px solid #30333a; border-radius: 8px; background: #f4f1ea; }
#designDlg .info { margin: 0; font-size: 11.5px; }
#cadDlg { width: min(720px, 92vw); }
.cad-progress { height: 4px; background: #2a2d33; border-radius: 2px; margin: 12px 0 8px; overflow: hidden; }
.cad-progress div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.cad-log { max-height: 280px; overflow: auto; background: #121316; border: 1px solid #2b2e34; border-radius: 6px; padding: 8px 10px; font: 11.5px/1.5 ui-monospace, Consolas, monospace; color: #b8bdc6; white-space: pre-wrap; min-height: 60px; }

/* properties: find a setting, level of detail, looks, colour helper */
.props-tools { display: flex; gap: 6px; padding: 8px 10px 4px; align-items: center; }
.props-tools input[type=search] { flex: 1; min-width: 0; background: #121316; border: 1px solid #30333a; border-radius: 6px; color: var(--text); padding: 6px 8px; font: inherit; }
.props-tools input[type=search]:focus { outline: none; border-color: var(--focus); }
.props-tools .seg button { padding: 4px 7px; font-size: 11px; }
.look-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.look { display: flex; align-items: center; gap: 7px; text-align: left; padding: 5px 7px; border-radius: 6px; background: #1e2025; border: 1px solid #2c2f36; font-size: 11.5px; line-height: 1.25; }
.look:hover { border-color: var(--accent); background: #23262c; }
.look-sw { width: 18px; height: 18px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.colorcol { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sw-toggle { padding: 3px 7px; }
.sw-toggle.on { border-color: var(--accent) !important; color: var(--accent-2); }
.swatches { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.swatches[hidden] { display: none; }
.swatches .sw { width: 17px; height: 17px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.22); }
.swatches .sw:hover { outline: 2px solid var(--accent); outline-offset: 1px; }
.swatches .sw-label { width: 100%; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 2px; }
.section.more { border-bottom: 0; }
.linkbtn { color: var(--accent-2); padding: 4px 0; font-size: 11.5px; }
.linkbtn:hover { text-decoration: underline; }
.field:has(.colorcol) { align-items: start; }
.field:has(.colorcol) > label { padding-top: 6px; }
/* Engineering controls extend the existing property panels without changing their layout. */
.field-error{color:#ffb6a4;font-size:11px;line-height:1.5;grid-column:1/-1;overflow-wrap:anywhere}
.field-help,.parameter-mm{font-size:10px;color:var(--muted,#a1a1aa);line-height:1.5}
.parameter-auto{font-size:10px;padding:3px 6px;margin-left:4px}
.field input[aria-invalid="true"]{outline:1px solid #dc8a76}
.edit-feedback{position:absolute;top:12px;left:12px;right:12px;z-index:15;background:#30221f;border:1px solid #af6e5d;border-radius:6px;padding:10px 12px;font-size:12px;line-height:1.5;max-height:120px;overflow:auto}
.engineering-panel{position:absolute;left:12px;bottom:62px;max-width:min(480px,calc(100% - 24px));z-index:8;font-size:11px;line-height:1.5;background:rgba(23,25,29,.95);border:1px solid #45464b;border-radius:6px;padding:8px 10px;color:#e4e4e7}
.engineering-panel summary{cursor:pointer;font-weight:500}.engineering-panel details[open]{max-height:280px;overflow:auto}
.engineering-panel p,.engineering-dims{margin:6px 0;color:#b3b4bc}.engineering-issue{display:block;width:100%;text-align:left;white-space:normal;background:transparent;border:0;border-top:1px solid #37383e;padding:7px 0;font-size:11px;line-height:1.4;color:#dfc28f}.engineering-issue.error{color:#ffb6a4}
.inspection-tools{position:absolute;left:12px;bottom:23px;display:flex;gap:5px;z-index:9;flex-wrap:wrap}.inspection-tools button{font-size:10px;padding:5px 8px;background:#23252b;border:1px solid #45464b;border-radius:4px;color:#d4d4d8}.inspection-tools button.on{border-color:#b8a474;color:#f4e2b5}
.dimension-dialog{width:min(590px,90vw);max-height:85vh;overflow:auto;background:#202127;color:#e4e4e7;border:1px solid #555762;border-radius:8px;padding:20px}.dimension-dialog::backdrop{background:#0009}.dimension-dialog label{display:flex;justify-content:space-between;gap:15px;margin:10px 0;font-size:12px}.dimension-dialog input{width:120px}.dimension-dialog p{font-size:12px;line-height:1.6}
