/* ROBLIX Creativity: the 3D accessory editor (js/platform/ugc3d.js). Always dark, Studio-like. Phones: the panels
   become a bottom sheet with Parts / Properties tabs. */
.u3d {
  --u-bg: #111216; --u-p1: #1c1d22; --u-p2: #24262c; --u-line: #2d2f36; --u-text: #f7f7f8; --u-muted: #a6a9b2; --u-acc: #335fff; --u-green: #00b06f; --u-red: #ff5c5c; --u-r: 8px;
  position: fixed; inset: 0; z-index: 800; display: flex; flex-direction: column; background: var(--u-bg); color: var(--u-text);
  font: 14px/1.4 "Figtree", system-ui, sans-serif; color-scheme: dark; overscroll-behavior: contain; outline: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.u3d *, .u3d *::before, .u3d *::after { box-sizing: border-box; }
.u3d button { font: inherit; color: inherit; }
.u3d input, .u3d select { font: inherit; color: var(--u-text); user-select: text; -webkit-user-select: text; }
.u3d svg { display: block; flex: none; }
.u3d :focus-visible { outline: 2px solid #7d9bff; outline-offset: 1px; }
.u3d kbd { font: 600 11px/1 "JetBrains Mono", ui-monospace, Consolas, monospace; background: var(--u-p2); border: 1px solid #3a3d46; border-bottom-width: 2px; border-radius: 4px; padding: 3px 5px; color: var(--u-text); }

/* top bar */
.u3d-top { display: flex; align-items: center; gap: 12px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top, 0px)); background: var(--u-p1); border-bottom: 1px solid var(--u-line); min-height: 58px; flex: none; }
.u3d-title { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1 1 200px; max-width: 340px; }
.u3d-name { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.u3d-nm { width: 100%; background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 2px 8px; font-weight: 700 !important; font-size: 16px !important; line-height: 1.5; text-overflow: ellipsis; }
.u3d-nm::placeholder { color: #6d717c; }
.u3d-nm:hover { border-color: var(--u-line); }
.u3d-nm:focus { border-color: var(--u-acc); background: var(--u-bg); outline: none; }
.u3d-state { font-size: 12px; color: var(--u-muted); padding-left: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.u3d-state.dirty::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #ffb020; flex: none; }
.u3d-tools { display: flex; align-items: center; gap: 8px; flex: 0 1 auto; min-width: 0; }
.u3d-grp { display: flex; gap: 2px; padding: 3px; background: var(--u-bg); border-radius: 10px; flex: none; }
.u3d-tb { height: 34px; min-width: 34px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; color: #c3c6ce; font-weight: 600; font-size: 13px; white-space: nowrap; }
.u3d-tb svg { width: 18px; height: 18px; }
.u3d-tb:hover { background: var(--u-p2); color: var(--u-text); }
.u3d-tb.on { background: var(--u-acc); color: #fff; }
.u3d-opts .u3d-tb.on { background: rgba(51, 95, 255, .2); color: #a9bdff; box-shadow: inset 0 0 0 1px rgba(91, 140, 255, .5); }
.u3d-tb:disabled { opacity: .32; cursor: default; background: transparent; color: #c3c6ce; }
.u3d-grp:first-child .u3d-tb { padding: 0 8px; }
.u3d-grp:first-child .u3d-tb span { display: none; }
.u3d-end { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex: 1 1 160px; }
.u3d-count { font-variant-numeric: tabular-nums; color: var(--u-muted); font-size: 13px; font-weight: 600; white-space: nowrap; }
.u3d-count.full { color: #ffb020; }
.u3d-save { height: 38px; min-width: 92px; padding: 0 18px; border: 0; border-radius: var(--u-r); background: var(--u-acc); color: #fff !important; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; box-shadow: 0 2px 10px rgba(51, 95, 255, .35); transition: background .15s, box-shadow .15s; }
.u3d-save svg { width: 18px; height: 18px; }
.u3d-save:hover { background: #4a71ff; }
.u3d-save.saved { background: rgba(0, 176, 111, .14); color: #29d391 !important; box-shadow: inset 0 0 0 1px rgba(0, 176, 111, .45); }
.u3d-save:disabled { opacity: .7; cursor: progress; }
.u3d-ib { width: 36px; height: 36px; border: 0; border-radius: var(--u-r); background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--u-muted); flex: none; }
.u3d-ib svg { width: 20px; height: 20px; }
.u3d-ib:hover { background: var(--u-p2); color: var(--u-text); }
.u3d-ib.sm { width: 32px; height: 32px; }
.u3d-ib.sm svg { width: 16px; height: 16px; }

/* panels + view */
.u3d-main { flex: 1; min-height: 0; display: flex; }
.u3d-panel { background: var(--u-p1); display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; flex: none; }
.u3d-left { order: 1; width: 252px; border-right: 1px solid var(--u-line); overflow: hidden; }
.u3d-view { order: 2; flex: 1; min-width: 0; position: relative; overflow: hidden; background: radial-gradient(120% 90% at 50% 35%, #30343f 0%, #1d1f26 55%, #131418 100%); }
.u3d-right { order: 3; width: 292px; border-left: 1px solid var(--u-line); }
.u3d-tabs { display: none; }
.u3d canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
.u3d-hint { position: absolute; left: 14px; bottom: 12px; right: 14px; font-size: 12px; color: rgba(247, 247, 248, .5); pointer-events: none; transition: opacity .8s; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
.u3d-used .u3d-hint { opacity: 0; }
.u3d-note { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 24px); background: rgba(28, 29, 34, .94); border: 1px solid var(--u-line); padding: 8px 12px; border-radius: var(--u-r); font-size: 13px; color: #ffcf70; }
.u3d-sec { padding: 14px; border-bottom: 1px solid var(--u-line); }
.u3d-sec h4 { margin: 0 0 9px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--u-muted); display: flex; align-items: center; gap: 6px; }
.u3d-sec h4.u3d-h2 { margin-top: 14px; }
.u3d-grow { flex: 1; min-height: 0; display: flex; flex-direction: column; border-bottom: 0; padding-bottom: 8px; }
.u3d-pc { font-weight: 700; color: var(--u-text); background: var(--u-p2); border-radius: 999px; padding: 1px 7px; letter-spacing: 0; font-size: 11px; }
.u3d-pc:empty { display: none; }

/* add part */
.u3d-shapes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.u3d-shape { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; height: 64px; border: 1px solid transparent; border-radius: var(--u-r); background: var(--u-p2); color: #c9ccd4; font-size: 12px; font-weight: 600; cursor: pointer; transition: border-color .12s, background .12s; }
.u3d-shape svg { width: 26px; height: 26px; color: #7f9bff; }
.u3d-shape:hover { border-color: var(--u-acc); background: #2a2d36; color: #fff; }
.u3d-shape:active { transform: scale(.96); }
.u3d-shape:disabled { opacity: .35; cursor: not-allowed; border-color: transparent; transform: none; }

/* parts list */
.u3d-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -6px; padding: 0 6px; }
.u3d-row { display: flex; align-items: center; border-radius: var(--u-r); flex: none; }
.u3d-row:hover { background: var(--u-p2); }
.u3d-row.on { background: rgba(51, 95, 255, .2); box-shadow: inset 0 0 0 1px rgba(91, 140, 255, .8); }
.u3d-rowmain { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 6px 0 10px; background: none; border: 0; cursor: pointer; text-align: left; font-weight: 600; }
.u3d-rowmain span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u3d-rowmain small { margin-left: auto; color: var(--u-muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.u3d-sw { width: 18px; height: 18px; border-radius: 5px; flex: none; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22); }
.u3d-row .u3d-ib { opacity: 0; }
.u3d-row:hover .u3d-ib, .u3d-row.on .u3d-ib, .u3d-row .u3d-ib:focus-visible { opacity: 1; }
.u3d-row .u3d-ib:hover { color: var(--u-red); background: rgba(255, 92, 92, .12); }
.u3d-none { color: var(--u-muted); font-size: 13px; margin: 4px 4px; }

/* properties */
.u3d-slot, .u3d-right select, .u3d-hex { height: 36px; width: 100%; border-radius: var(--u-r); border: 1px solid var(--u-line); background: var(--u-bg); padding: 0 10px; cursor: pointer; }
.u3d-hex { cursor: text; font-family: "JetBrains Mono", ui-monospace, Consolas, monospace !important; font-size: 13px !important; text-transform: lowercase; }
.u3d-right select:focus, .u3d-hex:focus { outline: none; border-color: var(--u-acc); }
.u3d-tip { margin: 8px 0 0; font-size: 12px; color: var(--u-muted); }
.u3d-ph { display: flex; align-items: center; gap: 10px; padding-top: 12px; padding-bottom: 12px; }
.u3d-ph b { font-size: 15px; }
.u3d-ph small { margin-left: auto; color: var(--u-muted); font-size: 12px; }
.u3d-shp { width: 30px; height: 30px; border-radius: 7px; background: var(--u-p2); display: grid; place-items: center; color: #7f9bff; }
.u3d-shp svg { width: 20px; height: 20px; }
.u3d-colrow { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.u3d-colbtn { position: relative; width: 46px; height: 36px; border-radius: var(--u-r); overflow: hidden; flex: none; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22); }
.u3d-colbtn input { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; padding: 0; opacity: 0; cursor: pointer; }
.u3d-colbtn span { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22); border-radius: inherit; }
.u3d-pal { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.u3d-pal button { aspect-ratio: 1; min-height: 24px; border-radius: 6px; border: 0; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16); transition: transform .1s; }
.u3d-pal button:hover { transform: scale(1.1); }
.u3d-pal button.on { box-shadow: 0 0 0 2px var(--u-p1), 0 0 0 4px #fff; }
.u3d-out { margin-left: auto; color: var(--u-text); font-variant-numeric: tabular-nums; letter-spacing: 0; text-transform: none; font-size: 12px; }
.u3d input[type="range"] { width: 100%; accent-color: var(--u-acc); height: 24px; margin: 0; cursor: pointer; }
.u3d-xyz { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 14px; }
.u3d-xyz:last-child { margin-bottom: 0; }
.u3d-ax { display: flex; align-items: stretch; height: 36px; border-radius: var(--u-r); background: var(--u-bg); border: 1px solid var(--u-line); overflow: hidden; min-width: 0; }
.u3d-ax:focus-within { border-color: var(--u-acc); }
.u3d-ax span { width: 20px; flex: none; display: grid; place-items: center; font-size: 11px; font-weight: 800; cursor: ew-resize; touch-action: none; }
.u3d-x span { color: #ff6b6b; background: rgba(255, 107, 107, .12); }
.u3d-y span { color: #5fd47e; background: rgba(95, 212, 126, .12); }
.u3d-z span { color: #6d9cff; background: rgba(109, 156, 255, .14); }
.u3d-ax input { flex: 1; min-width: 0; width: 100%; border: 0; background: transparent; padding: 0 6px; font-variant-numeric: tabular-nums; font-size: 13px !important; outline: none; -moz-appearance: textfield; appearance: textfield; }
.u3d-ax input::-webkit-inner-spin-button, .u3d-ax input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.u3d-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; border-bottom: 0; }
.u3d-btn { height: 38px; border-radius: var(--u-r); border: 1px solid var(--u-line); background: var(--u-p2); font-weight: 600; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 8px; white-space: nowrap; }
.u3d-btn svg { width: 16px; height: 16px; }
.u3d-btn:hover { background: #2c2f37; border-color: #3a3d46; }
.u3d-btn:disabled { opacity: .4; cursor: default; }
.u3d-btn.danger { grid-column: span 2; color: #ff7a7a; background: transparent; border-color: rgba(255, 92, 92, .35); }
.u3d-btn.danger:hover { background: rgba(255, 92, 92, .1); }
.u3d-empty { padding: 30px 20px; text-align: center; color: var(--u-muted); font-size: 13px; }
.u3d-empty > svg { width: 38px; height: 38px; margin: 0 auto 12px; color: #555a68; }
.u3d-empty b { color: var(--u-text); display: block; font-size: 15px; margin-bottom: 4px; }
.u3d-empty p { margin: 0; }
.u3d-keys { list-style: none; padding: 14px 0 0; margin: 20px 0 0; display: grid; gap: 9px; text-align: left; font-size: 12.5px; border-top: 1px solid var(--u-line); }
.u3d-keys li { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* in-between widths: fewer labels in the top bar */
@media (max-width: 1220px) { .u3d-opts .u3d-tb span { display: none; } .u3d-opts .u3d-tb { padding: 0 8px; } }
@media (max-width: 1000px) { .u3d-modes .u3d-tb span { display: none; } .u3d-modes .u3d-tb { padding: 0 8px; } .u3d-left { width: 220px; } .u3d-right { width: 264px; } }
/* touch: bigger targets */
@media (pointer: coarse) {
  .u3d-tb { height: 40px; min-width: 40px; }
  .u3d-ib, .u3d-ib.sm { width: 40px; height: 40px; }
  .u3d-save { height: 40px; }
  .u3d-row .u3d-ib { opacity: 1; }
  .u3d-rowmain, .u3d-ax, .u3d-btn, .u3d-slot, .u3d-right select, .u3d-hex, .u3d-colbtn { min-height: 40px; height: 40px; }
  .u3d-pal button { min-height: 30px; }
  .u3d input[type="range"] { height: 32px; }
  .u3d-keys { display: none; }
}
/* phones: the panels are a bottom sheet with tabs; tap the open tab to fold it away */
@media (max-width: 760px) {
  .u3d-top { flex-wrap: wrap; gap: 6px 8px; padding: 6px 8px; padding-top: max(6px, env(safe-area-inset-top, 0px)); min-height: 0; }
  .u3d-title { order: 1; flex: 1 1 0; max-width: none; gap: 2px; }
  .u3d-nm { font-size: 15px !important; padding: 1px 6px; }
  .u3d-state { padding-left: 7px; font-size: 11px; }
  .u3d-end { order: 2; flex: none; gap: 8px; }
  .u3d-save { min-width: 0; padding: 0 14px; height: 40px; }
  .u3d-tools { order: 3; width: 100%; justify-content: space-between; gap: 4px; overflow-x: auto; scrollbar-width: none; }
  .u3d-tools::-webkit-scrollbar { display: none; }
  .u3d-grp { padding: 2px; }
  .u3d-tb, .u3d-grp:first-child .u3d-tb, .u3d-modes .u3d-tb, .u3d-opts .u3d-tb { height: 40px; min-width: 40px; padding: 0 9px; }
  .u3d-tb span { display: none; }
  .u3d-ib, .u3d-ib.sm { width: 40px; height: 40px; }
  .u3d-main { flex-direction: column; }
  .u3d-view { order: 1; flex: 1; min-height: 160px; }
  .u3d-hint { bottom: 8px; left: 10px; }
  .u3d-tabs { order: 2; display: flex; flex: none; background: var(--u-p1); border-top: 1px solid var(--u-line); padding: 0 6px; }
  .u3d-tabs button { flex: 1; height: 44px; border: 0; background: none; color: var(--u-muted); font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; box-shadow: inset 0 -2px 0 transparent; }
  .u3d-tabs button.on { color: var(--u-text); box-shadow: inset 0 -2px 0 var(--u-acc); }
  .u3d-collapsed .u3d-tabs button.on { box-shadow: none; color: var(--u-muted); }
  .u3d-left, .u3d-right { order: 3; width: auto; height: min(44vh, 380px); border: 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .u3d[data-tab="parts"] .u3d-right, .u3d[data-tab="props"] .u3d-left, .u3d-collapsed .u3d-left, .u3d-collapsed .u3d-right { display: none; }
  .u3d-collapsed .u3d-tabs { padding-bottom: env(safe-area-inset-bottom, 0px); }
  .u3d-left .u3d-sec { padding: 10px 12px; }
  .u3d-left .u3d-sec h4 { margin-bottom: 7px; }
  .u3d-shapes { grid-template-columns: repeat(6, 1fr); gap: 5px; }
  .u3d-shape { height: 56px; font-size: 10.5px; gap: 3px; }
  .u3d-shape svg { width: 22px; height: 22px; }
  .u3d-right .u3d-sec { padding: 12px; }
  .u3d-rowmain, .u3d-ax, .u3d-btn, .u3d-slot, .u3d-right select, .u3d-hex, .u3d-colbtn { min-height: 40px; height: 40px; }
  .u3d-row .u3d-ib { opacity: 1; }
  .u3d-pal { grid-template-columns: repeat(8, 1fr); }
  .u3d-pal button { min-height: 30px; }
  .u3d-keys { display: none; }
  .u3d-empty { padding: 20px 16px; }
}
