html, body { margin: 0; height: 100%; overflow: hidden; }
[hidden] { display: none !important; }
body { display: flex; flex-direction: column; font-size: 13px; }
.muted { color: var(--ce-muted); font-size: 12px; }
.hint { color: var(--ce-muted2); font-size: 11px; line-height: 1.5; margin-top: 8px; }
.gap-top { margin-top: 10px; }
.ce-btn.sm { padding: 6px 11px; font-size: 12px; }

#top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 14px;
  background: var(--ce-panel); flex: none; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 15px; letter-spacing: .2px; }
.brand img { width: 22px; height: 22px; }
.brand b { color: var(--ce-accent); }

main { flex: 1; display: flex; min-height: 0; }
#stage { flex: 1; position: relative; background: var(--ce-bg2); display: flex; align-items: center; justify-content: center; min-width: 0; }
#frame { position: relative; outline: 1px solid var(--ce-line); }
#c { display: block; width: 100%; height: 100%; touch-action: none; }
body.picking #c { cursor: crosshair; }
#guides { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; display: none; }
#guides line, #guides rect { fill: none; stroke: rgba(255,255,255,.35); stroke-width: 1; vector-effect: non-scaling-stroke; }
#guides rect.title { stroke-dasharray: 4 4; }
body.guides #guides { display: block; }
#zoomRects { position: absolute; inset: 0; pointer-events: none; }
#zoomRects div { position: absolute; border: 1px dashed rgba(255,90,77,.75); }
#zoomRects span { position: absolute; top: 2px; left: 4px; font-size: 10px; color: #ff8a7d; }
#empty { position: absolute; text-align: center; line-height: 1.8; pointer-events: none; color: var(--ce-muted); }
#empty span { color: var(--ce-muted2); font-size: 11px; }
body.loaded #empty { display: none; }
#busy, #pickHint { position: absolute; top: 12px; left: 12px; }
#pickHint { left: auto; right: 12px; }
#hud { position: absolute; bottom: 10px; left: 12px; font: 11px Menlo, "SF Mono", ui-monospace, monospace; color: var(--ce-muted); }
body.dragover #stage { outline: 2px dashed var(--ce-accent); outline-offset: -8px; }

#side { width: 340px; flex: none; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px;
  background: var(--ce-bg); border-left: 1px solid var(--ce-line-soft); }
#side::-webkit-scrollbar { width: 8px; }
#side::-webkit-scrollbar-thumb { background: #2a2b32; border-radius: 4px; }
#side .ce-panel { padding: 14px; border-radius: 12px; }
#side .ce-panel-title { margin-bottom: 10px; }

.field { display: grid; grid-template-columns: 78px 1fr; align-items: center; gap: 8px; margin-top: 8px; }
.field > span { color: var(--ce-muted); font-size: 12px; }
.field .ce-seg { justify-self: start; }
.field:has(#bgColor) { grid-template-columns: 78px auto 1fr; }
#bgColor { width: 30px; height: 26px; border: 1px solid var(--ce-line); border-radius: 6px; background: none; padding: 0; justify-self: start; }
.ce-inp { padding: 6px 9px; font-size: 12.5px; }
select.ce-inp { cursor: pointer; }
.ce-slider { gap: 8px; min-width: 0; }
.ce-slider input[type=range] { min-width: 0; }
.unit { color: var(--ce-muted2); font-size: 11px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.grid3 label { display: flex; flex-direction: column; gap: 4px; color: var(--ce-muted); font-size: 12px; min-width: 0; }

/* Number field = input + unit + ▲▼ steppers in one box (built by enhanceNumbers in app.js).
   Wheel / two-finger scroll over it (and over any slider) changes the value; Shift = finer. */
.num-wrap { display: inline-flex; align-items: stretch; width: 92px; flex: none; box-sizing: border-box;
  background: var(--ce-input); border: 1px solid var(--ce-line); border-radius: var(--ce-r); overflow: hidden; transition: border-color .16s; }
.num-wrap:hover, .num-wrap:focus-within { border-color: var(--ce-accent); }
.num-wrap input.ce-inp.num { flex: 1; min-width: 0; width: auto; border: 0; background: transparent; border-radius: 0;
  padding: 5px 2px 5px 6px; text-align: right; -moz-appearance: textfield; }
.num-wrap input::-webkit-inner-spin-button, .num-wrap input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.num-wrap .unit { align-self: center; padding: 0 4px 0 2px; }
.num-wrap .steps { display: flex; flex-direction: column; width: 18px; border-left: 1px solid var(--ce-line); flex: none; }
.num-wrap .steps button { flex: 1; border: 0; padding: 0; background: transparent; color: var(--ce-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; }
.num-wrap .steps button + button { border-top: 1px solid var(--ce-line); }
.num-wrap .steps button:hover { color: var(--ce-accent); background: var(--ce-card-hi); }
.num-wrap .steps svg { width: 9px; height: 9px; }
.grid3 .num-wrap { width: 100%; }

.role { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; margin-top: 8px;
  padding: 7px 9px; background: var(--ce-card); border: 1px solid var(--ce-line); border-radius: 8px; }
.role .tag { font-weight: 650; font-size: 12px; padding: 2px 7px; border-radius: 6px; color: #0e0f12; }
.role .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ce-muted); font-size: 12px; }
.role .ops { display: flex; gap: 4px; }
.role .ops button { font: inherit; font-size: 11px; background: transparent; border: 1px solid var(--ce-line); color: var(--ce-muted);
  border-radius: 6px; padding: 3px 6px; cursor: pointer; }
.role .ops button:hover, .role .ops button.ce-on { border-color: var(--ce-accent); color: var(--ce-text); }

.zoom { display: grid; grid-template-columns: 1fr 72px auto; gap: 6px; margin-bottom: 6px; align-items: center; }
.zoom button { background: transparent; border: 0; color: var(--ce-muted2); cursor: pointer; font-size: 15px; }
.zoom button:hover { color: var(--ce-accent); }

@media (max-width: 820px) {
  main { flex-direction: column; }
  #stage { min-height: 45vh; }
  #side { width: auto; border-left: 0; border-top: 1px solid var(--ce-line-soft); }
}

.objname { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 10px 0 8px; }
.objname span { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#hiddenList .role .tag { background: var(--ce-card-hi); color: var(--ce-muted); }
#btnPickObject.ce-on, #btnObjMove.ce-on, #btnObjRotate.ce-on { border-color: var(--ce-accent); color: var(--ce-accent); background: var(--ce-accent-wash); }

#restoreBar, #shotBar { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); gap: 10px; padding: 6px 8px 6px 14px;
  font-size: 12px; background: var(--ce-panel); box-shadow: 0 8px 24px rgba(0,0,0,.45); max-width: calc(100% - 24px); z-index: 2; }
#restoreBar .ce-btn, #shotBar .ce-btn { padding: 4px 10px; }
body.shotpreview #zoomRects { display: none; }
body.shotpreview #frame { outline: 2px solid var(--ce-accent); }
.zoom { grid-template-columns: 1fr 84px auto auto; }
.zoom .num-wrap { width: 100%; }
.zoom button.view { font-size: 12px; border: 1px solid var(--ce-line); border-radius: 6px; padding: 3px 7px; color: var(--ce-muted); }
.zoom button.view:hover, .zoom button.view.ce-on { border-color: var(--ce-accent); color: var(--ce-accent); }
.proj { display: grid; grid-template-columns: 64px 1fr auto; gap: 8px; align-items: center; margin-top: 8px; padding: 6px;
  background: var(--ce-card); border: 1px solid var(--ce-line); border-radius: 8px; cursor: pointer; }
.proj:hover { border-color: var(--ce-accent); }
.proj.current { border-color: var(--ce-accent); background: var(--ce-accent-wash); }
.proj img, .proj .noimg { width: 64px; height: 36px; object-fit: cover; border-radius: 4px; background: var(--ce-bg2); }
.proj .nm { font-weight: 600; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj .dt { color: var(--ce-muted2); font-size: 11px; }
.proj button { background: transparent; border: 0; color: var(--ce-muted2); cursor: pointer; font-size: 14px; }
.proj button:hover { color: var(--ce-accent); }

.sub-title { margin-top: 14px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ce-muted2); }
#keyColor { width: 30px; height: 26px; border: 1px solid var(--ce-line); border-radius: 6px; background: none; padding: 0; }
#frontList .role .tag { background: #d9a441; color: #14060a; }
#btnObjFront.ce-on, #btnOutput.ce-on, #btnKeyPick.ce-on { border-color: var(--ce-accent); color: var(--ce-accent); background: var(--ce-accent-wash); }

details.adv { margin-top: 10px; }
details.adv > summary { cursor: pointer; list-style: none; font-size: 11px; color: var(--ce-muted2); display: inline-flex; align-items: center; gap: 6px; user-select: none; }
details.adv > summary::-webkit-details-marker { display: none; }
details.adv > summary::before { content: '▸'; transition: transform .16s; }
details.adv[open] > summary::before { transform: rotate(90deg); color: var(--ce-accent); }
details.adv > summary:hover { color: var(--ce-text); }
/* rotate / mirror buttons of the screens only with Advanced open */
body:not(.uvfix) .role .ops button[data-op="rot"], body:not(.uvfix) .role .ops button[data-op="flipU"], body:not(.uvfix) .role .ops button[data-op="flipV"] { display: none; }
