/* Vaelo Map Editor (editor.html / src/map-editor.js): menu bar, map settings on the left,
   the 3D view in the middle, the scene + the selected object's properties on the right. */
:root {
  --bg: #0f0f13; --panel: #18181d; --panel2: #1f1f26; --line: #2b2b34; --input: #24242c; --input2: #2c2c35;
  --text: #e9e7ef; --muted: #8e8b99; --red: #ff1e3c; --cyan: #22e6ff; --ok: #3ee68a;
  --display: 'Chakra Petch', system-ui, sans-serif; --heavy: 'Archivo Black', system-ui, sans-serif; --mono: 'Share Tech Mono', ui-monospace, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
/* the three bands are pinned to the window, so nothing else that lands in <body> (browser extensions, injected
   banners) can move them around */
#menubar { position: fixed; left: 0; right: 0; top: 0; height: 40px; }
#workspace { position: fixed; left: 0; right: 0; top: 40px; bottom: 26px; }
#statusbar { position: fixed; left: 0; right: 0; bottom: 0; height: 26px; }
body { background: var(--bg); color: var(--text); font: 500 13px var(--display); overflow: hidden; user-select: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.mono { font-family: var(--mono); }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }

/* ---------- menu bar */
#menubar { display: flex; align-items: center; gap: 6px; padding: 0 10px; background: #0b0b0e; border-bottom: 1px solid var(--line); z-index: 20; }
.brand { font: 400 14px var(--heavy); color: #fff; text-decoration: none; letter-spacing: .04em; margin-right: 10px; white-space: nowrap; }
.brand span { color: var(--red); }
.menus { display: flex; height: 100%; }
.menu { position: relative; height: 100%; }
.menu > button { height: 100%; padding: 0 11px; background: none; border: none; color: #cfccd8; }
.menu > button:hover, .menu.open > button { background: var(--panel2); color: #fff; }
.drop { display: none; position: absolute; left: 0; top: 100%; min-width: 210px; padding: 5px; background: var(--panel2); border: 1px solid var(--line); box-shadow: 0 12px 30px rgba(0,0,0,.5); }
.menu.open .drop { display: block; }
.drop button { display: flex; justify-content: space-between; gap: 20px; width: 100%; padding: 7px 10px; text-align: left; background: none; border: none; color: var(--text); }
.drop button:hover { background: var(--red); color: #fff; }
.drop button:disabled { opacity: .4; pointer-events: none; }
.drop kbd { font: 11px var(--mono); color: var(--muted); }
.drop button:hover kbd { color: #fff; }
.drop hr { border: none; border-top: 1px solid var(--line); margin: 4px 2px; }
.drop .grp { padding: 7px 10px 3px; font: 10px var(--mono); letter-spacing: .16em; color: var(--muted); }
.mb-center { position: absolute; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; }
.mb-center button { display: flex; align-items: center; gap: 7px; height: 28px; padding: 0 16px; font: 400 12px var(--heavy); letter-spacing: .04em; border: none; }
.mb-test { background: #fff; color: #0b0b0e; }
.mb-test svg { width: 13px; height: 13px; fill: currentColor; stroke: none; }
.mb-test:hover { background: var(--ok); }
.mb-publish { background: var(--red); color: #fff; }
.mb-publish:hover { filter: brightness(1.15); }
.mb-right { margin-left: auto; display: flex; gap: 14px; align-items: center; font-size: 11px; letter-spacing: .12em; color: var(--muted); white-space: nowrap; }
#saveState.dirty { color: #ffc35a; }
#saveState.live { color: var(--ok); }

/* ---------- layout */
#workspace { display: grid; grid-template-columns: 270px 1fr 300px; min-height: 0; }
.panel { background: var(--panel); overflow-y: auto; min-height: 0; scrollbar-width: thin; scrollbar-color: #3a3a45 transparent; }
#left { border-right: 1px solid var(--line); }
#right { border-left: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; }
#right .sec.scene { flex: 0 1 45%; min-height: 120px; display: flex; flex-direction: column; }
#right .sec.scene .sec-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#right .sec:last-child { flex: 1; overflow-y: auto; min-height: 0; scrollbar-width: thin; }
.sec { border-bottom: 1px solid var(--line); }
.sec h3 button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 12px; background: var(--panel2); border: none; text-align: left; font: 700 12px var(--display); letter-spacing: .1em; text-transform: uppercase; color: #fff; }
.sec h3 button::before { content: ''; width: 6px; height: 6px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; }
.sec.open h3 button::before { transform: rotate(45deg); }
.sec h3 button:hover { background: #262630; }
.sec h3 .mono { margin-left: auto; font-size: 11px; color: var(--muted); letter-spacing: .06em; }
.sec-body { display: none; padding: 10px 12px 12px; gap: 8px; flex-direction: column; }
.sec.open .sec-body { display: flex; }
label.row { display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 8px; min-height: 26px; }
#props label.row { grid-template-columns: 84px 1fr; gap: 4px; }
label.col { display: flex; flex-direction: column; gap: 5px; }
label > span:first-child, .field-label { color: #bdbac7; font-size: 12px; }
input[type=text], input:not([type]), input[type=number], input[type=search], select, textarea {
  width: 100%; min-width: 0; height: 26px; padding: 0 8px; background: var(--input); border: 1px solid var(--line); outline: none; color: var(--text); user-select: text; }
textarea { height: auto; padding: 6px 8px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #4a4a58; background: var(--input2); }
select option { background: var(--panel2); }
input[type=number] { font-family: var(--mono); font-size: 12px; padding: 0 4px 0 7px; }
input[type=color] { width: 100%; height: 26px; padding: 2px; background: var(--input); border: 1px solid var(--line); cursor: pointer; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: none; }
.range { display: grid; grid-template-columns: 1fr 54px; align-items: center; gap: 8px; }
.range output { font: 12px var(--mono); color: var(--muted); text-align: right; }
input[type=range] { width: 100%; accent-color: var(--red); height: 16px; }
input.toggle { appearance: none; justify-self: start; width: 34px; height: 18px; border-radius: 9px; background: #3a3a45; position: relative; cursor: pointer; transition: background .15s; }
input.toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: left .15s; }
input.toggle:checked { background: var(--red); }
input.toggle:checked::after { left: 18px; }
.hint { font-size: 11px; color: var(--muted); line-height: 1.45; }
.hint b { color: #d9d6e2; font-weight: 700; }
body:not(.parkour) .pk-only, body.parkour .ffa-only { display: none !important; }

/* ---------- scene list */
#sceneSearch { margin-bottom: 6px; flex: none; }
#sceneList { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #3a3a45 transparent; margin: 0 -12px -12px; }
.obj-row { display: flex; align-items: center; gap: 8px; width: 100%; padding: 4px 12px; border: none; background: none; text-align: left; color: var(--text); font-size: 12px; }
.obj-row:hover { background: #24242c; }
.obj-row[aria-selected=true] { background: rgba(34,230,255,.16); box-shadow: inset 2px 0 var(--cyan); }
.obj-row i { width: 12px; height: 12px; flex: none; border: 1px solid rgba(255,255,255,.25); }
.obj-row span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.obj-row em { font: 10px var(--mono); font-style: normal; color: var(--muted); letter-spacing: .08em; }
/* lock toggle and group tag in the scene list */
.obj-row u { text-decoration: none; font-size: 11px; opacity: .25; cursor: pointer; padding: 0 2px; transition: opacity .12s; }
.obj-row:hover u, .obj-row.locked u { opacity: .9; }
.obj-row.locked span { opacity: .55; font-style: italic; }
.obj-row .grp, .obj-folder .grp { font: 700 9px var(--mono); color: #0b0b10; background: var(--g); border-radius: 2px; padding: 0 4px; line-height: 14px; }
/* groups as folders in the scene list */
.obj-folder { display: flex; align-items: center; border-left: 2px solid var(--g); }
.obj-folder .fold { width: 22px; flex: none; border: none; background: none; color: var(--muted); font-size: 10px; cursor: pointer; transition: transform .15s; }
.obj-folder.open .fold { transform: rotate(90deg); }
.obj-folder .folder-name { flex: 1; display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 0; border: none; background: none; color: var(--text); font-size: 12px; text-align: left; cursor: pointer; }
.obj-folder .folder-name span { flex: 1; font-weight: 600; }
.obj-folder .folder-name em { font: 10px var(--mono); font-style: normal; color: var(--muted); }
.obj-folder:hover { background: #24242c; }
.obj-folder .folder-name[aria-selected=true] { color: #fff; }
.obj-folder:has(.folder-name[aria-selected=true]) { background: rgba(34,230,255,.16); }
.obj-row.in-folder { padding-left: 34px; border-left: 2px solid rgba(255,255,255,.08); }
.obj-more { padding: 8px 12px; font: 11px var(--mono); color: var(--muted); }

/* ---------- properties */
#props .none { color: var(--muted); font-size: 12px; padding: 6px 0; line-height: 1.5; }
.prop-head { display: flex; align-items: center; gap: 8px; }
.prop-head .type { font: 10px var(--mono); letter-spacing: .14em; color: var(--muted); padding: 3px 6px; background: var(--input); white-space: nowrap; }
.vec { display: grid; grid-template-columns: 64px 1fr 1fr 1fr; gap: 4px; align-items: center; }
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.vec .ax { position: relative; }
.vec .ax::before { content: attr(data-ax); position: absolute; left: 5px; top: 50%; transform: translateY(-50%); font: 10px var(--mono); pointer-events: none; }
.vec .ax[data-ax=X]::before { color: #ff5a6e; } .vec .ax[data-ax=Y]::before { color: #6eea7a; } .vec .ax[data-ax=Z]::before { color: #5aa7ff; }
.vec .ax input { padding: 0 3px 0 15px; }
.rot { display: grid; grid-template-columns: 64px 1fr 30px 30px; gap: 4px; align-items: center; }
.mini { height: 26px; background: var(--input); border: 1px solid var(--line); color: var(--text); }
.mini:hover { background: var(--input2); }
.tex-pick { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.tex-pick button { aspect-ratio: 1; padding: 0; border: 2px solid transparent; background-size: cover; background-color: #444; }
.tex-pick button.on { border-color: var(--cyan); }
.tex-pick button:hover { border-color: #fff; }
.color-row { display: grid; grid-template-columns: 64px 1fr 74px; gap: 4px; align-items: center; }
.swatches { display: flex; flex-wrap: wrap; gap: 3px; margin-left: 68px; }
.swatches button { width: 16px; height: 16px; border: 1px solid rgba(255,255,255,.2); padding: 0; }
.align-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.align-pick button { height: 26px; background: var(--input); border: 1px solid var(--line); font-size: 11px; }
.align-pick button:hover { background: var(--input2); }
.align-pick button.on { background: var(--red); border-color: var(--red); color: #fff; }
.prop-btns { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px; margin-top: 4px; }
.prop-btns button { height: 28px; padding: 0 4px; background: var(--input); border: 1px solid var(--line); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prop-btns button:hover { background: var(--input2); }
.prop-btns button.danger:hover { background: var(--red); border-color: var(--red); }
.subhead { font: 10px var(--mono); letter-spacing: .18em; color: var(--muted); margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); }

/* ---------- the 3D view and its overlays */
#view { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #000; }
#canvasHost, #canvasHost canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#canvasHost canvas { outline: none; }
.vtools { position: absolute; left: 10px; top: 10px; display: flex; align-items: center; gap: 3px; padding: 3px; background: rgba(15,15,19,.85); border: 1px solid var(--line); }
.vtools button { width: 30px; height: 28px; display: grid; place-items: center; background: none; border: none; color: #c9c6d3; }
.vtools button:hover { background: var(--input2); color: #fff; }
.vtools button.on { background: var(--red); color: #fff; }
.vtools svg { width: 17px; height: 17px; }
.vtools .sep { width: 1px; height: 18px; background: var(--line); margin: 0 3px; }
.vsnap { display: flex; align-items: center; gap: 4px; padding: 0 4px; color: #c9c6d3; }
.vsnap svg { width: 16px; height: 16px; }
.vsnap select { width: 62px; height: 24px; padding: 0 4px; }
.vstats { position: absolute; right: 10px; top: 10px; display: grid; grid-template-columns: auto auto; gap: 2px 16px; padding: 8px 12px; font-size: 11px; letter-spacing: .06em;
  color: #c9c6d3; background: rgba(15,15,19,.85); border: 1px solid var(--line); pointer-events: none; }
.vstats b { font-weight: 400; color: #fff; text-align: right; }
.vstats .bad { color: #ff8a8a; }
.vhint { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); padding: 5px 12px; font-size: 11px; letter-spacing: .1em; color: #c9c6d3;
  background: rgba(15,15,19,.75); pointer-events: none; white-space: nowrap; transition: opacity .3s; }
.vhint b { color: #fff; font-weight: 400; }
.vleft { position: absolute; left: 10px; bottom: 10px; display: flex; gap: 4px; }
.vleft button { height: 28px; padding: 0 12px; background: rgba(15,15,19,.85); border: 1px solid var(--line); color: #e3e0ea; font-size: 12px; }
.vleft button:hover { background: var(--input2); }
.vadd { position: absolute; right: 12px; bottom: 12px; width: 46px; height: 46px; font: 400 28px/1 var(--heavy); color: #fff; background: var(--red); border: none; box-shadow: 0 6px 18px rgba(255,30,60,.4); transition: transform .15s; }
.vadd:hover { transform: scale(1.06); }
.vadd[aria-expanded=true] { background: #2c2c35; box-shadow: none; }
.assets { position: absolute; right: 12px; bottom: 68px; width: min(430px, calc(100% - 24px)); max-height: calc(100% - 110px); overflow-y: auto; padding: 12px; background: rgba(20,20,25,.97);
  border: 1px solid var(--line); box-shadow: 0 16px 40px rgba(0,0,0,.55); }
.assets.hidden { display: none; }
.assets-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.assets-head b { font: 400 13px var(--heavy); }
.assets-head span { font-size: 10px; letter-spacing: .1em; color: var(--muted); }
.asset-grp { font: 10px var(--mono); letter-spacing: .18em; color: var(--muted); margin: 10px 0 6px; }
.asset-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.asset { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 4px 7px; background: var(--input); border: 1px solid var(--line); font-size: 11px; color: var(--text); }
.asset:hover { border-color: var(--red); background: var(--input2); }
.asset img { width: 64px; height: 64px; object-fit: contain; pointer-events: none; }
#marquee { position: absolute; border: 1px solid var(--cyan); background: rgba(34,230,255,.1); pointer-events: none; }
#view.flying { cursor: none; }

/* ---------- status bar */
#statusbar { display: flex; justify-content: space-between; gap: 20px; align-items: center; padding: 0 12px; background: #0b0b0e; border-top: 1px solid var(--line); font-size: 12px; color: #bdbac7; }
#status.err { color: #ff8a8a; } #status.ok { color: var(--ok); }
#camInfo { font-size: 11px; color: var(--muted); letter-spacing: .08em; }

/* ---------- dialogs */
.dlg { margin: auto; width: min(640px, calc(100vw - 32px)); padding: 0; color: var(--text); background: var(--panel); border: 1px solid var(--line); box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.dlg.wide { width: min(860px, calc(100vw - 32px)); }
.dlg.small { width: min(420px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(5,5,8,.6); backdrop-filter: blur(4px); }
.dlg header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; background: var(--panel2); border-bottom: 1px solid var(--line); }
.dlg h2 { font: 400 18px var(--heavy); letter-spacing: .02em; }
.dlg .x { width: 30px; height: 30px; background: none; border: 1px solid var(--line); color: #fff; }
.dlg .x:hover { background: var(--red); border-color: var(--red); }
.dlg > form > p { padding: 16px 18px 0; line-height: 1.5; color: #d4d1dc; }
.dlg footer { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 14px 18px; }
.dlg footer .hint { margin-right: auto; }
.dlg footer button { height: 32px; padding: 0 18px; font: 400 12px var(--heavy); letter-spacing: .04em; border: none; }
.dlg .primary { background: var(--red); color: #fff; }
.dlg .primary:hover { filter: brightness(1.15); }
.dlg .primary:disabled { opacity: .5; pointer-events: none; }
.dlg .ghost { background: var(--input2); color: #fff; }
.pub-body { display: grid; grid-template-columns: 260px 1fr; gap: 16px; padding: 16px 18px 0; }
.pub-thumb img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: #000; border: 1px solid var(--line); }
.pub-thumb-btns { display: grid; grid-template-columns: 1fr auto; gap: 4px; margin-top: 6px; }
.pub-thumb-btns button { height: 28px; padding: 0 10px; background: var(--input); border: 1px solid var(--line); font-size: 11px; }
.pub-thumb-btns button:hover { background: var(--input2); }
.thumb-upload { width: 100%; height: 28px; margin-top: 4px; background: var(--input); border: 1px dashed #55556a; font-size: 11px; }
.thumb-upload:hover { background: var(--input2); border-color: #fff; }
.pub-thumb .hint { margin-top: 4px; }
.pub-fields { display: flex; flex-direction: column; gap: 10px; }
.checks { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.checks li::before { content: '✓'; display: inline-block; width: 18px; color: var(--ok); }
.checks li.bad::before { content: '✕'; color: #ff8a8a; }
.checks li.bad { color: #ffb4b4; }
.msg { min-height: 20px; padding: 10px 18px 0 !important; font-size: 12px; }
.msg.err { color: #ff8a8a; } .msg.ok { color: var(--ok); }
.msg a { color: #fff; }
.open-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; padding: 16px 18px 0; max-height: 60vh; overflow-y: auto; }
.open-card { display: flex; flex-direction: column; padding: 0; text-align: left; background: var(--input); border: 1px solid var(--line); color: var(--text); }
.open-card:hover { border-color: var(--red); }
.open-card .th { aspect-ratio: 16 / 9; background: #111 center / cover; }
.open-card b { padding: 8px 10px 2px; font: 400 13px var(--heavy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.open-card span { padding: 0 10px 9px; font: 11px var(--mono); color: var(--muted); }
.open-empty { grid-column: 1 / -1; color: var(--muted); padding: 20px 0; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 7px 18px; padding: 16px 18px 0; font-size: 13px; }
.keys dt { font: 12px var(--mono); color: #fff; background: var(--input); padding: 2px 8px; justify-self: start; }
.keys dd { color: #c9c6d3; align-self: center; }
@media (max-width: 1100px) { #workspace { grid-template-columns: 230px 1fr 260px; } .vhint { display: none; } }
/* a narrower view: the stats move down beside the "+" so they don't cover the toolbar */
@media (max-width: 1400px) { .vstats { top: auto; bottom: 68px; } }
.vtools { flex-wrap: wrap; max-width: calc(100% - 20px); }
@media (max-width: 820px) { #left { display: none; } #workspace { grid-template-columns: 1fr 250px; } .pub-body { grid-template-columns: 1fr; } }

/* PLAY HERE: first person inside the editor */
.mb-play { background: rgba(255,255,255,.08); color: #fff; }
.mb-play svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; }
.mb-play:hover { background: var(--ok); color: #0b0b0e; }
.play-hud { position: absolute; top: 14px; left: 50%; translate: -50% 0; z-index: 6; display: flex; align-items: center; gap: 12px; padding: 7px 14px; border-radius: 999px; background: rgba(8,8,12,.7); font-size: 11px; letter-spacing: .14em; pointer-events: none; }
.play-hud b { font-size: 15px; color: #fff; letter-spacing: .06em; }
.play-hud span { opacity: .6; }
.play-dot { width: 8px; height: 8px; border-radius: 50%; background: #ff3b4e; box-shadow: 0 0 8px #ff3b4e; animation: playDot 1s steps(2) infinite; }
@keyframes playDot { 50% { opacity: .3; } }
.play-cross { display: none; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.6); pointer-events: none; z-index: 6; }
#view.playing .play-cross { display: block; }
#view.playing .vhint, #view.playing #marquee { display: none !important; }

/* scene list: drag to reorder */
.obj-row.dragging { opacity: .45; }
.obj-row.drop-above { box-shadow: inset 0 2px 0 var(--ok, #4dff88); }

