/* Four surfaces, one hierarchy. Document colors and user paint are independent. */
body { --surface-shell:#17181c; --surface-canvas:#1e2026; --surface-panel:#24272e; --surface-control:#343943; --surface-text:#f2f3f5; }
body:not([data-theme=light]), body[data-custom-surfaces=true] {
 --shell:var(--surface-shell); --canvas:var(--surface-canvas); --panel:var(--surface-panel); --control:var(--surface-control);
 --text:var(--surface-text); --muted:color-mix(in srgb,var(--text) 78%,var(--panel)); --subtle:var(--muted);
 --raised:var(--canvas); --hover:var(--control); --overlay:var(--panel); --line:var(--control);
 --menu-bg:var(--panel); --menu-text:var(--text); --menu-control:var(--control);
 --selection:var(--control); --selection-ink:var(--text); --accent:var(--selection); --default-background:var(--panel); --default-text:var(--text);
}
body[data-theme=light] { --selection:#c8cdd1; --selection-ink:#25282b; }
body .topbar{height:48px;padding:0 14px;gap:14px;align-items:center}.app{grid-template-rows:48px minmax(0,1fr) 28px}
body .brand,body .header-end{align-self:center;display:flex;align-items:center;height:32px}body .brand{padding:0;line-height:1}body .brand>svg{display:block}.brand{font-size:10px}.header-end{gap:6px}
body .flow.plan-tabs{height:38px;align-self:end;align-items:end;gap:4px;overflow-x:auto}
body .plan-tab{height:32px;border:0;border-radius:6px 6px 0 0;background:var(--control)}
body .plan-tab.is-active{background:var(--selection);color:var(--selection-ink)}
body .plan-tab.is-active button{color:var(--selection-ink)}
body .plan-tab button{height:32px;min-height:0;background:transparent}
body .plan-tab-name{padding:0 10px;max-width:180px}body .plan-tab-menu{width:24px;padding:3px}
body .add-plan-button{align-self:center;width:24px;height:24px;border-radius:4px;padding:2px}
body .plan-menu-actions{margin-left:auto;justify-content:flex-end;gap:5px}
body .plan-menu-actions button,body .tree-direct-actions button{width:20px;height:20px;padding:0;min-height:20px;border:0;background:transparent}
body .plan-menu-actions svg,body .tree-direct-actions svg{width:16px;height:16px}
body .plan-tree-menu,body .surface-menu,body dialog,body .floating-tool,body .inspector{border-radius:8px;box-shadow:0 8px 24px #0003}
body .plan-menu-caption{padding:6px 10px;font-size:10px}
body .tree-row{min-height:28px}body .tree-display-controls{gap:3px}
body .tree-display-controls button{width:20px;height:20px;padding:2px}
body .surface-menu{width:66px;padding:8px}
body .display-compact{display:flex;flex-direction:column;gap:7px;width:100%;padding:0}
body .display-mini-tools{display:grid;grid-template-columns:repeat(2,20px);gap:5px}
body .display-mini-button,body .display-mini-static{width:20px;height:20px;padding:2px;border-radius:3px}
body .display-mini-styles{height:20px;display:flex}.display-mini-divider,.display-mini-context{display:none!important}
body .display-style-pill{width:20px;height:20px;border-radius:4px}
body .tool-rail{width:40px;padding:8px 6px;gap:6px;background:var(--panel);border-radius:7px}
body .tool-rail button{width:28px;height:28px;border:0;background:transparent;border-radius:4px}
body .tool-rail .rail-divider{width:22px;height:1px;margin:3px;background:var(--muted);opacity:.35}
body .tool-rail button.active{background:var(--selection);color:var(--selection-ink)}
body .tool-rail .icon{width:20px;height:20px}
body .icon-button{min-height:0;width:24px;height:24px;padding:3px;border-radius:4px;border:0}
body .icon{width:18px;height:18px}
body .board-actions button{width:25px;height:24px;border-radius:4px}
body .inspector{width:270px;padding:14px 12px;max-height:calc(100% - 16px);overflow:auto}
body .inspector h1{font-size:13px;margin:2px 0 12px}body .eyebrow{display:none}
body input:not([type=checkbox]):not([type=range]),body select,body .control-select{height:25px;min-height:0;padding:2px 7px;font-size:11px;border-radius:4px}
body button.primary,body button.secondary,body button.small-button,body button.export-button,body button.danger{min-height:0;padding:4px 8px;font-size:11px;border-radius:4px;line-height:18px}
body .primary{background:var(--control);border-color:var(--line);color:var(--text)}
body .primary:hover{background:var(--hover);color:var(--text)}
body dialog{padding:14px;max-height:calc(100dvh - 32px)}body dialog h2{font-size:15px;margin:6px 0 12px}body dialog h3{font-size:12px;margin:3px 0 8px}
body .field{margin:8px 0}body .section-head{font-size:11px;margin:10px 0 7px;padding-top:10px}
body .float-header{min-height:30px;padding:5px 8px}body .float-body{padding:7px 9px}
body .icon-choice{height:24px;min-width:24px;padding:2px 4px;border-radius:4px}
body .settings-tabs{padding:3px;margin:9px 0 12px;border-radius:5px}body .settings-tabs button{padding:4px 7px;border-radius:3px}
body #settings-dialog{width:500px}body #settings-content{margin-bottom:9px}body #done-settings{width:auto;min-width:45px;float:right}
body .vehicle-settings-grid{display:flex;flex-wrap:wrap;gap:5px}
body .vehicle-setting-row.compact-model{min-height:0!important;height:22px;width:66px;padding:0 3px!important;gap:3px!important;background:transparent;border:0;border-radius:3px;overflow:hidden}
body .vehicle-setting-row .drag-handle{height:20px;width:14px;min-width:14px;flex-basis:14px;font-size:13px;padding:0;border:0;background:transparent}
body .vehicle-setting-row strong{font-size:10px!important;overflow:hidden;text-overflow:ellipsis}
body .vehicle-dropzone{padding:6px;margin:7px 0;border-radius:5px;background:var(--canvas)}
body .vehicle-dropzone .section-head{margin:0 0 6px;padding:0;border:0}.model-drag-ghost{width:66px!important}
body .palette-settings{display:grid;grid-template-columns:1fr 1fr;gap:8px}body .palette-settings label{display:flex;align-items:center;justify-content:space-between;gap:7px;font-size:11px}
body .palette-settings input[type=color]{width:36px;padding:2px}body .compact-property{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:11px;min-height:25px}
body .model-card{padding:4px 6px;border:0;border-radius:4px;background:var(--canvas)}body .model-card img{max-height:40px;width:24px}
body .info-bar{height:28px;padding:0 12px;background:var(--shell)}
body .showcase-layout{padding:5px 8px;border:1px solid var(--line);background:var(--control);color:var(--text);border-radius:4px}body .showcase-layout span{display:none}
body [aria-pressed=true]:not(.palette-swatch):not(.plan-tab-name){color:var(--selection-ink)}
body .palette-popover [aria-pressed=true]{color:var(--text)}
body .export-page-options{padding:7px;border-radius:5px}body .export-page-options header{gap:6px}body .export-options-head h2{font-size:12px;margin:3px 0 8px}
body .export-include strong{font-size:11px}body .export-preview-button{width:24px;height:24px;padding:2px;border:0;background:transparent}
.output-actions{display:flex;gap:7px;margin-top:12px}.output-actions button{flex:1;display:flex;align-items:center;justify-content:center;gap:6px}
@media(max-width:700px){body .topbar{gap:6px;padding:0 8px}body .brand span{font-size:9px}.header-end #save-top{display:flex}body .inspector{width:min(270px,calc(100vw - 66px))}body .plan-tab-name{max-width:90px}}

body [hidden]{display:none!important}
body .settings-tabs button[aria-selected=true],body .settings-tabs button.active,body button.icon-choice.active,body .view-switch button.active,body .segmented button.active,body .label-options button.active{background:var(--selection);color:var(--selection-ink)}
body .project-menu button[aria-selected=true]{color:var(--selection-ink)}
body #project-menu-button{align-self:center}
body .settings-link{display:inline-flex;align-items:center;padding:3px 6px;min-height:24px;border:0;border-radius:4px;margin:4px 0;background:var(--control)}
body .settings-link.demo-link{width:24px;height:24px;padding:3px}
body .settings-color-preview{background:var(--canvas);color:var(--text)}
body .surface-menu .display-mini-button[aria-pressed=true],body .tree-display-controls button[aria-pressed=true]{background:var(--selection);color:var(--selection-ink)}
body #save-top{display:flex;align-items:center;justify-content:center;width:25px;height:25px;padding:3px;background:linear-gradient(90deg,color-mix(in srgb,var(--text) 22%,var(--control)) 0%,var(--control) var(--autosave-progress,0%),transparent var(--autosave-progress,0%));transition:background-color .15s}body #save-top[data-autosave-state=error]{outline:1px solid #e19280}

#message-log .is-error{color:#f99668}

#pointer-position{margin-left:auto;white-space:nowrap;font-variant-numeric:tabular-nums;font-size:10px;color:var(--muted)}
@media(max-width:640px){#pointer-position{display:none}}

/* Compact rail must size its buttons within the padded content box. */
body.canvas-workspace .tool-rail{overflow-x:hidden;overflow-y:auto;align-items:center;padding:5px;}
body.canvas-workspace .tool-rail button{width:28px;min-width:0;height:28px;min-height:28px;flex-shrink:0;}
body.canvas-workspace .tool-rail .rail-divider{flex-shrink:0;margin:3px 0;}

/* History and grid have their own compact content geometry. */
body #history-menu{width:210px;padding:5px;border-radius:7px}
body #history-menu .section-head{margin:0 0 4px;padding:3px 5px;font-size:10px}
body #history-menu button{min-height:23px;padding:3px 6px;gap:6px;font-size:10px;line-height:17px;border-radius:3px}
body #history-menu button.active{background:var(--selection);color:var(--selection-ink)}
body #history-menu button.active small{color:inherit}
body #grid-menu{width:max-content;padding:6px;border-radius:6px}
body #grid-menu strong{display:block;font-size:10px;font-weight:500;margin:0 0 4px}
body #grid-menu .tool-row{display:flex;gap:4px;margin:0}
body #grid-menu button{width:46px;min-width:0;height:23px;padding:2px 4px;font-size:10px}

/* Narrow screens place the complete tool set in one horizontal scrolling row. */
@media(max-width:700px),(max-height:500px) and (orientation:landscape){
 body.canvas-workspace .topbar{height:48px;gap:6px;padding:0 8px}
 body.canvas-workspace .brand,body.canvas-workspace .header-end{height:32px;flex:none}
 body.canvas-workspace .header-end .icon-button{display:flex;align-items:center;justify-content:center;width:25px;height:25px}
 body.canvas-workspace .tool-rail{left:8px;right:auto;top:104px;width:max-content;max-width:calc(100% - 16px);max-height:none;height:40px;display:flex;flex-direction:row;align-items:center;justify-content:flex-start;gap:5px;padding:5px;overflow-x:auto;overflow-y:hidden;border-radius:6px}
 body.canvas-workspace .tool-rail button{width:28px;min-width:28px;height:28px;min-height:28px;flex:0 0 28px}
 body.canvas-workspace .tool-rail .rail-divider{width:1px;height:22px;margin:0 4px;flex:none}
 body.canvas-workspace .inspector{top:150px;left:auto;right:8px;max-width:calc(100% - 16px)}
 body.canvas-workspace .floating-tool{top:150px;left:8px;max-width:calc(100% - 16px)}
 body.canvas-workspace .plan-tabs{min-width:50px}
}
@media(max-height:500px) and (orientation:landscape){
 body.canvas-workspace .tool-rail{top:54px}
 body.canvas-workspace .inspector,body.canvas-workspace .floating-tool{top:100px;bottom:50px;max-height:calc(100% - 150px)}
 body.canvas-workspace .board-top{display:flex;align-items:center;justify-content:space-between}
}

/* Links and buttons share the same start-action geometry. */
body .empty-actions > :is(button,a){box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;width:116px;height:30px;min-height:30px;margin:0;padding:4px 8px;font-family:inherit;font-size:11px;font-weight:500;line-height:18px;border:1px solid var(--line);border-radius:4px;background:var(--control);color:var(--text);text-decoration:none;}
body .empty-actions > :is(button,a):hover{background:var(--hover);}
body .model-count{margin-left:auto;min-width:20px;text-align:center;font-size:11px;font-variant-numeric:tabular-nums;color:var(--text);}
body .vehicle-total{display:inline-block;margin-left:8px;font-size:11px;font-variant-numeric:tabular-nums;color:var(--muted);}

/* Keep each output card inside the inspector; do not rely on horizontal scrolling. */
body.canvas-workspace .inspector{width:270px;padding:14px 12px;overflow-x:hidden;overflow-y:auto;}
body .export-options,body .export-page-list,body .export-page-options{min-width:0;max-width:100%;}
body .export-page-options{background:var(--canvas);gap:6px;}
body .export-page-options > header{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.5fr) 24px;gap:6px;min-width:0;}
body .export-page-options header .export-include{grid-column:1/-1;width:100%;min-height:24px;margin:0;}
body .export-page-options header .export-include input{flex-shrink:0;}
body .export-page-options header .export-include strong{min-width:0;white-space:normal;overflow-wrap:anywhere;}
body .export-page-options header select.export-paper-choice,body .export-page-options header select.export-orientation-choice{width:100%;min-width:0;max-width:100%;}
body .export-page-options .export-preview-button{min-height:0;width:24px;height:24px;padding:2px;}
body .output-actions > button{min-width:0;white-space:normal;}

/* v2.32: tabs meet the workbench edge; handles own reordering gestures. */
body .topbar .flow.plan-tabs{padding:0;height:38px;align-self:end;overflow-y:hidden;transform:translateY(1px);}
body .plan-tabs .plan-tab{position:relative;max-width:235px;}
body .plan-tabs .plan-drag-handle{display:flex;align-items:center;justify-content:center;width:18px;min-width:18px;padding:0;cursor:grab;touch-action:none;border-radius:5px 0 0 0;}
.plan-drag-handle svg{width:12px;height:16px;pointer-events:none;}
body .plan-tabs .plan-drag-handle:active{cursor:grabbing;}
.plan-tab.is-dragging{opacity:.5;}
.plan-tab.drop-before{box-shadow:inset 3px 0 var(--text);}
.plan-tab.drop-after{box-shadow:inset -3px 0 var(--text);}
body .icon,body button > svg:not(.icon),body .tree-display-fixed > svg,body .display-mini-static > svg{scale:1.25;transform-origin:center;}
.measurement-hit,.annotation-hit{cursor:pointer;}
#annotation-panel .annotation-row.is-editing{outline:1px solid var(--selection);outline-offset:2px;}

body .output-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:5px;}

.export-paper-options{display:flex;gap:12px;padding:3px 6px;font-size:11px}.export-paper-options label{display:flex;gap:4px;align-items:center}.export-paper-options input{width:12px;height:12px;margin:0}

/* Keep a long plan tab strip inside the viewport instead of widening the grid. */
.app{grid-template-columns:minmax(0,1fr)}
