* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1b1c1f; color: #e6e6e6; font: 13px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
#view { position: fixed; inset: 0 320px 0 0; }
#view canvas { display: block; width: 100%; height: 100%; }

#panel { position: fixed; top: 0; right: 0; bottom: 0; width: 320px; overflow-y: auto; overflow-x: hidden; background: #151618; border-left: 1px solid #2c2e33; padding: 12px 14px 24px; }
#panel h1 { font-size: 16px; margin: 0 0 8px; }
#panel h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: #9aa0a8; margin: 18px 0 8px; }
#panel h2 small { text-transform: none; letter-spacing: 0; color: #666b73; font-weight: 400; }
#panel label { display: block; margin: 4px 0; cursor: pointer; }
#panel label.range { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 8px; }
#panel select, #panel input[type=range] { width: 100%; }
#panel select { background: #22242a; color: #e6e6e6; border: 1px solid #34373e; border-radius: 6px; padding: 5px 6px; }
#model-note { color: #9aa0a8; margin: 6px 0 0; white-space: pre-line; }
.hint { color: #7d838c; font-size: 12px; margin: 8px 0 0; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
button { background: #22242a; color: #e6e6e6; border: 1px solid #34373e; border-radius: 6px; padding: 6px 8px; cursor: pointer; font: inherit; text-align: left; }
button:hover { border-color: #5a606b; }
button.on { background: #3b4a7a; border-color: #6c82c9; }
button.wide { width: 100%; text-align: center; }
button kbd { float: right; color: #8a909a; font: 11px ui-monospace, monospace; }

#stats { width: 100%; border-collapse: collapse; }
#stats td { padding: 2px 0; border-bottom: 1px solid #23252a; }
#stats td:last-child { text-align: right; color: #cfd3d8; font-variant-numeric: tabular-nums; }
#polys { width: 100%; border-collapse: collapse; }
#polys td { padding: 3px 0; border-bottom: 1px solid #23252a; font-size: 12px; white-space: nowrap; }
#polys td:first-child { position: relative; padding-bottom: 5px; }
#polys td:first-child i { position: absolute; left: 0; bottom: 1px; height: 2px; background: #6c82c9; border-radius: 1px; }
#polys td:not(:first-child) { text-align: right; padding-left: 8px; color: #cfd3d8; font-variant-numeric: tabular-nums; white-space: nowrap; }
#polys tr.head td { color: #7d838c; font-size: 11px; }
#polys tr.total td { font-weight: 600; color: #e6e6e6; }

.thumbs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
#refs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.thumbs figure { margin: 0; min-width: 0; cursor: zoom-in; }
.thumbs canvas, .thumbs img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #0e0f11; border: 1px solid #2c2e33; border-radius: 4px; display: block; }
.thumbs figcaption { font-size: 11px; color: #9aa0a8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#loading { position: fixed; left: 0; right: 320px; bottom: 24px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
#loading[hidden] { display: none; }
#bar { width: min(420px, 60%); height: 6px; background: #2a2c31; border-radius: 3px; overflow: hidden; }
#bar i { display: block; height: 100%; width: 0; background: #6c82c9; transition: width .15s; }

#lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 10; cursor: zoom-out; }
#lightbox[hidden] { display: none; }
#lightbox img, #lightbox canvas { max-width: 96vw; max-height: 90vh; object-fit: contain; }
#lightbox span { margin-top: 8px; color: #bbb; }

@media (max-width: 800px) {
  #view { inset: 0 0 45vh 0; }
  #panel { top: 55vh; width: 100%; border-left: 0; border-top: 1px solid #2c2e33; }
  #loading { right: 0; bottom: calc(45vh + 16px); }
}

#parts { position: fixed; top: 12px; left: 12px; right: 332px; display: flex; flex-direction: column; gap: 6px; pointer-events: none; z-index: 2; }
#parts > div { display: flex; flex-wrap: wrap; gap: 6px; }
#parts button { pointer-events: auto; background: rgba(21,22,24,.85); backdrop-filter: blur(4px); }
#part-tabs button { font-size: 14px; font-weight: 600; padding: 7px 14px; }
#versions button { font-size: 12px; }
#versions button small { color: #9aa0a8; margin-left: 6px; }
#model-title { margin: 0; font-weight: 600; }
.thumbs figcaption b { color: #cfd3d8; font-weight: 600; }
@media (max-width: 800px) { #parts { right: 12px; } }

/* edit mode */
#edit-toggle { position: fixed; top: 12px; right: 332px; z-index: 6; padding: 7px 12px; font-weight: 600; }
#edit-toggle.on { background: #7a5a1e; border-color: #e0a943; }
#edit-panel { position: fixed; left: 12px; bottom: 12px; width: 370px; max-height: calc(100vh - 90px); overflow-y: auto; z-index: 6; background: rgba(21, 22, 24, .95); border: 1px solid #3a3d44; border-radius: 10px; padding: 10px 12px 12px; }
#edit-panel[hidden] { display: none; }
#edit-panel .edit-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
#edit-panel .edit-head button { padding: 2px 8px; }
#edit-panel .grid, #edit-panel .grid3 { margin-top: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
#edit-parts button.on { background: #7a5a1e; border-color: #e0a943; }
#edit-panel button.primary { background: #2f5a35; border-color: #57a562; }
#edit-panel input[type=number] { width: 100%; background: #22242a; color: #e6e6e6; border: 1px solid #34373e; border-radius: 6px; padding: 4px 6px; font: inherit; }
#edit-panel label.range { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 8px; margin-top: 8px; }
#edit-panel .xyz { display: grid; grid-template-columns: auto 1fr 1fr 1fr; gap: 6px; align-items: center; margin-top: 8px; }
#edit-panel .xyz label { display: flex; align-items: center; gap: 4px; }
#edit-fields.off { opacity: .45; pointer-events: none; }
#edit-add { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-top: 8px; }
#edit-add select { min-width: 0; background: #22242a; color: #e6e6e6; border: 1px solid #34373e; border-radius: 6px; padding: 4px 6px; font: inherit; }
#edit-panel button:disabled { opacity: .45; cursor: default; }
#edit-panel label.check { display: flex; gap: 6px; align-items: center; margin-top: 8px; cursor: pointer; }
#pbr-maps label small { color: #8a8f99; margin-left: 4px; }
#pbr-maps label.off { opacity: .45; }
#place { margin-top: 6px; }
#place .prow { display: grid; grid-template-columns: 1fr 22px 92px 22px 54px 18px; gap: 4px; align-items: center; margin-top: 5px; font-size: 12px; }
#place .prow .pl { cursor: pointer; color: #c9ccd2; line-height: 1.15; }
#place .prow .pl small { display: block; color: #7d838c; font-size: 10.5px; }
#place .prow.moved .pl { color: #ffc24d; }
#place .prow button { padding: 1px 0; }
#place .prow input[type=range] { width: 100%; }
#place .prow .pu { color: #8a909a; }
#place .psec { margin-top: 8px; color: #8a909a; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
#edit-parts .item { display: flex; gap: 4px; align-items: stretch; }
#edit-parts .item input { margin: 0 2px; }
#edit-parts .item button { flex: 1; text-align: left; }
#edit-parts .item button.edited::after { content: ' •'; color: #ffc24d; }
#edit-motion { margin-top: 8px; width: 100%; }
#edit-motion.on { background: #5a4a2f; border-color: #c9a35a; }
#anim-box .scrub { display: grid; grid-template-columns: 34px 1fr 92px; gap: 6px; align-items: center; margin-top: 8px; }
#anim-box .scrub span { font: 11px ui-monospace, monospace; color: #9aa0a8; text-align: right; }
#edit-parts { gap: 4px; }
#edit-parts .item button { padding: 3px 7px; font-size: 12px; line-height: 1.25; }
#asm-fit { margin-bottom: 12px; }
#asm-fit label small { color: #8a8f99; }
#asm-fit-raw { color: #e0b060; }
