/* Local project tools and optional spatial viewer. */
.spatial{margin:1.7rem 0;padding:clamp(1rem,3vw,2rem);overflow:hidden}
.spatial-heading{display:flex;align-items:center;justify-content:space-between;gap:1rem}
.spatial-heading h2{margin:.3rem 0}.preview-tag{font-size:.78rem;border:1px solid #91b4a7;border-radius:2rem;padding:.3rem .65rem;white-space:nowrap}
.view-switch{display:flex;flex-wrap:wrap;gap:.4rem;margin:1rem 0}
.view-switch button,.spatial-tools button,.action-row button,.file-button{font:inherit;font-size:.88rem;border:1px solid #859f95;border-radius:.6rem;padding:.6rem .8rem;background:transparent;color:inherit;cursor:pointer}
.view-switch button[aria-pressed=true]{background:#236356;color:white;border-color:#236356}
.spatial-stage{position:relative;background:linear-gradient(150deg,rgba(110,155,138,.12),rgba(103,152,181,.07));border:1px solid rgba(120,150,140,.3);border-radius:1rem;overflow:hidden}
#spatial-flat svg{width:100%;height:auto;max-height:420px;display:block;color:inherit}
#spatial-flat svg text{font:14px system-ui,sans-serif;fill:currentColor}
#spatial-3d{height:380px;width:100%;touch-action:none}
#spatial-3d canvas{display:block;width:100%;height:100%}
.spatial-status{margin:.6rem 1rem;min-height:1.5em;font-size:.87rem;overflow-wrap:anywhere}
.spatial-tools{display:flex;flex-wrap:wrap;gap:.5rem;align-items:center;margin:.8rem 0}
.spatial-tools label{font-size:.88rem;display:flex;gap:.4rem;align-items:center}
.spatial-notes{font-size:.87rem;padding-left:1.3rem;line-height:1.6}
.product-library{border:1px solid #93b0a3;border-radius:1rem;padding:1rem;margin:1rem 0;background:rgba(125,167,147,.08)}
.product-library h3{margin-top:0}.product-library select{max-width:100%;width:100%;padding:.65rem;font:inherit;color:inherit;background:transparent;border:1px solid #859f95;border-radius:.5rem}
.product-library option{color:#172a25;background:#fff}
.source-manufacturer{color:#205b4d;background:#e4f2e8}
.coefficient-audit{margin:1.5rem 0;border-top:1px solid rgba(130,150,140,.45);padding-top:1rem}
.coefficient-audit summary{font-weight:650;cursor:pointer}
.coefficient-audit table{min-width:600px}
.project-actions{border-top:1px solid rgba(130,150,140,.45);margin-top:1.5rem;padding-top:1rem}
.project-actions h3{margin-top:0}.project-actions input[type=text],#project-name{width:100%;box-sizing:border-box;font:inherit;padding:.6rem;border-radius:.5rem;border:1px solid #859f95;background:transparent;color:inherit}
.action-row{display:flex;flex-wrap:wrap;gap:.5rem;align-items:center;margin:.8rem 0}
.file-button{display:inline-block}.saved-project{padding:.8rem 0;border-top:1px solid rgba(130,150,140,.3)}
.saved-project h4{margin:.3rem 0;overflow-wrap:anywhere}.saved-result{white-space:pre-line;font-size:.85rem;max-height:260px;overflow:auto;overflow-wrap:anywhere}
.spatial button:focus-visible,.action-row button:focus-visible,.file-button:focus-visible{outline:3px solid #d39142;outline-offset:3px}
[hidden]{display:none!important}
@media(max-width:600px){.spatial-heading{align-items:flex-start}.preview-tag{white-space:normal}.spatial-heading h2{font-size:1.25rem}#spatial-3d{height:300px}.view-switch button{flex:1}#spatial-flat svg text{font-size:17px}}
@media(prefers-color-scheme:dark){.source-manufacturer{background:#1b4036;color:#c6ebda}.view-switch button[aria-pressed=true]{background:#a5d2bf;color:#142e25}.product-library option{background:#172c24;color:#e6f0ea}}

.spatial-legend{display:flex;flex-wrap:wrap;gap:1rem;margin:1rem 0;font-size:.86rem}.spatial-legend span{display:inline-flex;align-items:center;gap:.4rem}.spatial-legend i{display:inline-block;width:.8rem;height:.8rem;border:1px solid #607d72;border-radius:.2rem}
