/* UI Essentials Studio */
:root {
  --bg: #0a0912;
  --bg2: #0f0d1a;
  --panel: #13101f;
  --panel2: #1a1629;
  --panel3: #241e38;
  --line: #241f36;
  --line2: #352d50;
  --text: #efebfa;
  --muted: #a49cc2;
  --dim: #6d6690;
  --accent: #8b5cf6;
  --accent2: #c084fc;
  --accent-rgb: 139, 92, 246;
  --grad: linear-gradient(135deg, #d8b4fe 0%, #a855f7 38%, #7c3aed 70%, #5b5bf0 100%);
  --blue: #60a5fa;
  --ok: #34d399;
  --bad: #fb7185;
  --r: 16px;
  --r2: 11px;
  --shadow: 0 14px 50px rgba(5, 3, 14, .6);
  --glow: 0 6px 22px rgba(124, 58, 237, .35);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: dark;}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-size: 13px; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
input, select, textarea {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 9px; padding: 7px 9px; width: 100%; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .18); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); padding: 0; }
input[type=range] { padding: 0; accent-color: var(--accent); background: none; border: 0; box-shadow: none; }
textarea { resize: vertical; font-family: "Cascadia Code", Consolas, monospace; font-size: 12px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }
kbd { font: 11px "Cascadia Code", Consolas, monospace; color: var(--dim); }
.hidden { display: none !important; }

/* ---- layout ---- */
#app { display: grid; height: 100vh; padding: 8px; gap: 8px;
  grid-template-columns: 74px 270px 1fr 330px; grid-template-rows: 52px 1fr 30px;
  grid-template-areas: "top top top top" "rail left center right" "status status status status"; }
#app.code-mode { grid-template-columns: 74px 270px 1fr 0; }
#app.code-mode #right { display: none; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); min-height: 0; }

/* ---- top bar ---- */
#top { grid-area: top; display: flex; align-items: center; gap: 6px; padding: 0 10px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14px; margin-right: 6px; white-space: nowrap; }
.logo { width: 30px; height: 30px; border-radius: 9px; background: var(--grad); display: grid; place-items: center; color: #fff; font-weight: 900; box-shadow: var(--glow); }
.brand small { color: var(--muted); font-weight: 500; }
.menu-btn { background: none; border: 0; padding: 7px 11px; border-radius: 8px; color: var(--muted); }
.menu-btn:hover, .menu-btn.open { background: var(--panel2); color: var(--text); }
#tabs { display: flex; gap: 4px; margin-left: 10px; overflow-x: auto; flex: 1; min-width: 0; }
.ptab { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 9px; background: var(--bg2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; cursor: pointer; }
.ptab.active { color: var(--text); border-color: var(--line2); background: var(--panel2); }
.ptab .mode { font-size: 10px; padding: 1px 6px; border-radius: 6px; background: var(--panel3); color: var(--muted); }
.ptab .mode.hud { background: rgba(90, 169, 255, .15); color: var(--blue); }
.ptab .x { color: var(--dim); }
.ptab .x:hover { color: var(--text); }
.ptab .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.spacer { flex: 1; }
.btn { border: 1px solid var(--line2); background: var(--panel2); padding: 7px 13px; border-radius: 10px; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; }
.btn:hover { background: var(--panel3); }
.btn.accent { background: var(--grad); color: #fff; border: 0; font-weight: 700; box-shadow: var(--glow); }
.btn.accent:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--panel2); color: var(--text); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 9px; font-size: 12px; border-radius: 8px; }
.btn.on { border-color: var(--accent); color: var(--accent); }
.icon-btn { background: none; border: 0; width: 30px; height: 30px; border-radius: 8px; color: var(--muted); display: grid; place-items: center; }
.icon-btn:hover { background: var(--panel2); color: var(--text); }
.pill { padding: 5px 10px; border-radius: 20px; font-size: 12px; border: 1px solid var(--line2); color: var(--muted); display: flex; align-items: center; gap: 7px; cursor: pointer; white-space: nowrap; }
.pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.pill.on { color: var(--ok); border-color: rgba(69, 196, 107, .35); }
.pill.on::before { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.pill.err::before { background: var(--bad); }

/* ---- rail ---- */
#rail { grid-area: rail; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0; overflow-y: auto; }
.tool { width: 64px; min-height: 48px; padding: 5px 2px 4px; border-radius: 11px; border: 0; background: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 17px; position: relative; flex: none; }
.tool .ico { line-height: 1; height: 19px; display: grid; place-items: center; }
.tool .lbl { font-size: 9.5px; line-height: 1.1; letter-spacing: .01em; max-width: 62px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .85; }
.tool.active .lbl { opacity: 1; }
#rail-tip { position: fixed; transform: translateY(-50%); background: #000; color: #fff; padding: 6px 10px; border-radius: 8px; font-size: 12px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .12s; z-index: 1000; box-shadow: 0 6px 20px rgba(0,0,0,.45); border: 1px solid rgba(var(--accent-rgb), .35); }
#rail-tip.on { opacity: 1; }
#rail-tip b { font-weight: 600; }
#rail-tip .kbd { margin-left: 8px; padding: 1px 6px; border-radius: 5px; background: rgba(var(--accent-rgb), .25); border: 1px solid rgba(var(--accent-rgb), .45); font-size: 11px; }
.lang-sel { width: auto; flex: none; max-width: 130px; background: var(--panel2); color: var(--text); border: 1px solid var(--line2); border-radius: 9px; padding: 5px 8px; font: inherit; font-size: 12px; cursor: pointer; }
.lang-sel:hover { border-color: rgba(var(--accent-rgb), .6); }
.tool:hover { background: var(--panel2); color: var(--text); }
.tool.active { background: var(--grad); color: #fff; box-shadow: var(--glow); }
.tool .tip { position: absolute; left: 68px; top: 50%; transform: translateY(-50%); background: #000; color: #fff; padding: 5px 9px; border-radius: 7px; font-size: 12px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .12s; z-index: 20; }
.tool:hover .tip { opacity: 1; }
.rail-sep { width: 26px; height: 1px; background: var(--line); margin: 6px 0; flex: none; }

/* ---- side panels ---- */
#left, #right { display: flex; flex-direction: column; overflow: hidden; }
#left { grid-area: left; }
#right { grid-area: right; }
.ptabs { display: flex; gap: 2px; padding: 8px 8px 0; border-bottom: 1px solid var(--line); flex: none; }
.ptabs .t { padding: 8px 10px; border-radius: 9px 9px 0 0; color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.ptabs .t.active { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.pbody { flex: 1; overflow-y: auto; padding: 10px 12px 30px; }
.section { margin-bottom: 14px; }
.section > h4 { margin: 4px 0 8px; font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; display: flex; align-items: center; justify-content: space-between; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.field { display: flex; flex-direction: column; gap: 4px; grid-column: span 2; min-width: 0; }
.field.half { grid-column: span 1; }
.field > span { color: var(--muted); font-size: 11.5px; }
.field.check { flex-direction: row; align-items: center; gap: 8px; }
.field.check > span { order: 2; color: var(--text); font-size: 12.5px; }
.hint { color: var(--dim); font-size: 11.5px; line-height: 1.4; }
.color-row { display: flex; gap: 6px; }
.color-row input[type=color] { width: 38px; height: 32px; padding: 2px; flex: none; cursor: pointer; }
.color-row .none { flex: none; padding: 0 8px; }
.empty { color: var(--dim); text-align: center; padding: 30px 10px; line-height: 1.6; }

/* layers */
.layer { display: flex; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 8px; cursor: pointer; color: var(--muted); user-select: none; }
.layer:hover { background: var(--panel2); color: var(--text); }
.layer.sel { background: rgba(var(--accent-rgb), .16); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.layer .ic { width: 18px; text-align: center; color: var(--dim); flex: none; }
.layer .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer .act { opacity: 0; display: flex; gap: 2px; }
.layer:hover .act, .layer.sel .act { opacity: 1; }
.layer .act button { background: none; border: 0; color: var(--dim); padding: 0 3px; }
.layer .act button:hover { color: var(--text); }
.layer.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.layer.drop-into { background: rgba(var(--accent-rgb), .12); }
.layer .tw { width: 12px; color: var(--dim); flex: none; text-align: center; }

/* resources */
.img-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.img-cell { background: var(--bg2); border: 1px solid var(--line); border-radius: 9px; padding: 6px; cursor: pointer; text-align: center; overflow: hidden; }
.img-cell:hover { border-color: var(--accent); }
.img-cell .th { height: 56px; display: grid; place-items: center; background: repeating-conic-gradient(#1c1830 0 25%, #141122 0 50%) 0 0/12px 12px; border-radius: 6px; }
.img-cell img { max-width: 100%; max-height: 56px; image-rendering: pixelated; }
.img-cell .n { font-size: 10.5px; color: var(--muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.img-cell .src { font-size: 9.5px; color: var(--dim); }
.drop-zone { border: 1.5px dashed var(--line2); border-radius: 12px; padding: 16px; text-align: center; color: var(--muted); margin-bottom: 10px; cursor: pointer; }
.drop-zone:hover, .drop-zone.over { border-color: var(--accent); color: var(--text); }

/* actions */
.action { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin-bottom: 6px; display: grid; gap: 6px; }
.action .row { display: flex; gap: 6px; align-items: center; }
.action select { width: 46%; flex: none; }
.action .del { color: var(--dim); }

/* ---- center / canvas ---- */
#center { grid-area: center; position: relative; overflow: hidden; display: flex; flex-direction: column; }
#viewport { flex: 1; position: relative; overflow: hidden; cursor: default; background:
  radial-gradient(circle at 50% 35%, #1c1733 0%, #0b0a14 72%), #0b0a14; }
#viewport.panning { cursor: grabbing; }
#viewport.tool-create { cursor: crosshair; }
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#screen { position: relative; overflow: hidden; border-radius: 4px; box-shadow: 0 0 0 1px #000, 0 20px 80px rgba(0, 0, 0, .6); }
#screen.bg-game { background: linear-gradient(#7fb3ff 0%, #a9cdfb 52%, #6aa84f 52%, #4e8a3a 100%); }
#screen.bg-dark { background: #1b1b1b; }
#screen.bg-checker { background: repeating-conic-gradient(#221d33 0 25%, #1a1628 0 50%) 0 0/40px 40px; }
#screen .safe { position: absolute; top: 0; bottom: 0; border-left: 2px dashed rgba(255, 255, 255, .25); border-right: 2px dashed rgba(255, 255, 255, .25); pointer-events: none; z-index: 99998; }
#stage { position: absolute; inset: 0; }
#grid { position: absolute; inset: 0; pointer-events: none; z-index: 99997; background-image:
  linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px);
  background-size: 40px 40px; }
#overlay { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
.sel-box { position: absolute; border: 1.5px solid var(--accent); box-shadow: 0 0 0 1px rgba(0, 0, 0, .5); pointer-events: none; }
.sel-box.hover { border: 1px dashed rgba(192, 132, 252, .85); box-shadow: none; }
.sel-box.parent { border: 1px dashed rgba(90, 169, 255, .6); box-shadow: none; }
.handle { position: absolute; width: 10px; height: 10px; background: #fff; border: 1.5px solid var(--accent); border-radius: 3px; pointer-events: auto; }
.sel-label { position: absolute; transform: translateY(-100%); margin-top: -4px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 5px; white-space: nowrap; }
.guide { position: absolute; background: #ff3d8b; pointer-events: none; }
.guide.v { width: 1px; top: 0; bottom: 0; }
.guide.h { height: 1px; left: 0; right: 0; }
.marquee { position: absolute; border: 1px solid var(--accent); background: rgba(var(--accent-rgb), .1); }

/* elements on the canvas */
.el { position: absolute; display: flex; align-items: center; justify-content: center; }
.el.clips { overflow: hidden; }
.el-face { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.el.is-hidden { opacity: .25 !important; outline: 1px dashed #888; }
.el.is-conditional::after { content: '?'; position: absolute; right: 2px; top: 1px; font: 700 12px sans-serif; color: #ffd166; text-shadow: 0 0 3px #000; pointer-events: none; }
.el .txt { font-family: "Minecraft", "Minecraftia", "Monocraft", "Press Start 2P", ui-monospace, monospace; letter-spacing: .02em; pointer-events: none; }
.el .txt.shadow span { text-shadow: .12em .12em 0 rgba(0, 0, 0, .75); }
.el img { width: 100%; height: 100%; object-fit: fill; image-rendering: pixelated; pointer-events: none; }
.el .ph { width: 100%; height: 100%; display: grid; place-items: center; color: rgba(255, 255, 255, .55); font-size: 13px; border: 1px dashed rgba(255, 255, 255, .25); text-align: center; overflow: hidden; }
.el .ph.small { border: 0; font-size: 11px; }
.el .fill { position: absolute; }
.el .ph-text { color: #7a7a7a; width: 100%; }
.item-icon { width: 100%; height: 100%; display: grid; place-items: center; }
.item-icon img { width: 100%; height: 100%; image-rendering: pixelated; filter: drop-shadow(3px 3px 0 rgba(0, 0, 0, .35)); }
.item-ph { width: 92%; height: 92%; border: 2px solid; border-radius: 8px; display: grid; place-items: center; text-align: center; font-size: 10px; color: #ddd; background: rgba(0, 0, 0, .35); text-transform: uppercase; overflow: hidden; line-height: 1.1; padding: 2px; }
.head-icon { width: 100%; height: 100%; position: relative; }
.head-icon .face { position: absolute; inset: 6%; background-size: 800% 800%; background-position: 14.2857% 14.2857%; image-rendering: pixelated; }
.head-icon .face.hat { inset: 0; background-position: 71.4286% 14.2857%; }

/* zoom widget */
#zoombar { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 4px; align-items: center; background: rgba(19, 16, 31, .88); border: 1px solid var(--line); border-radius: 11px; padding: 4px; z-index: 5; }
#zoombar span { min-width: 46px; text-align: center; color: var(--muted); font-size: 12px; }
#aspectbar { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 4px; background: rgba(19, 16, 31, .88); border: 1px solid var(--line); border-radius: 11px; padding: 4px; z-index: 5; }

/* code view */
#codeview { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(380px, 44%) 1fr; background: var(--panel); z-index: 6; }
#codeview .cv-left { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-height: 0; }
.cv-bar { display: flex; align-items: center; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line); flex: none; }
.cv-tab { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg2); color: var(--muted); font-weight: 700; font-size: 11px; letter-spacing: .05em; }
.cv-tab.active { color: #fff; background: var(--grad); border-color: transparent; }
.cv-err { padding: 5px 10px; min-height: 26px; color: var(--bad); font: 12px "Cascadia Code", Consolas, monospace; border-top: 1px solid var(--line); flex: none; white-space: pre-wrap; }
.cv-right { position: relative; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.cv-preview { flex: 1; position: relative; overflow: hidden; background: linear-gradient(#7fb3ff 0%, #a9cdfb 52%, #6aa84f 52%, #4e8a3a 100%); }
.cv-preview iframe { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; border: 0; transform-origin: 0 0; background: transparent; }

.ce { flex: 1; display: flex; min-height: 0; background: #0c0a16; font: 13px/1.55 "Cascadia Code", "JetBrains Mono", Consolas, monospace; }
.ce-gutter { width: 46px; flex: none; text-align: right; padding: 12px 8px 12px 0; color: #4b4468; overflow: hidden; user-select: none; background: #0f0d1b; border-right: 1px solid #1d1830; }
.ce-scroll { flex: 1; position: relative; overflow: hidden; }
.ce-hl, .ce-input { position: absolute; inset: 0; margin: 0; padding: 12px 14px; font: inherit; white-space: pre; tab-size: 2; border: 0; border-radius: 0; }
.ce-hl { pointer-events: none; color: #e9e4f7; overflow: visible; }
.ce-input { color: transparent; caret-color: #d8b4fe; background: transparent; resize: none; overflow: auto; box-shadow: none !important; }
.ce-input::selection { background: rgba(var(--accent-rgb), .35); color: transparent; }
.tk-com { color: #6d7e72; font-style: italic; }
.tk-str { color: #a5d6a7; }
.tk-kw { color: #f472b6; }
.tk-num { color: #fcd34d; }
.tk-fn { color: #82b1ff; }
.tk-glob { color: #f48fb1; }
.tk-tag { color: #c084fc; }
.tk-punc { color: #8d7f7a; }
.tk-attr { color: #ffd180; }
.tk-attr2 { color: #b39ddb; }
.tk-prop { color: #80cbc4; }
.tk-sel { color: #a78bfa; }
.tk-ph { color: #4fc3f7; }

/* ---- status bar ---- */
#status { grid-area: status; display: flex; align-items: center; gap: 16px; padding: 0 12px; color: var(--dim); font-size: 11.5px; }
#status b { color: var(--muted); font-weight: 600; }

/* ---- menus, modals, toasts ---- */
.ctx-menu { position: fixed; z-index: 1000; min-width: 220px; background: #18142a; border: 1px solid var(--line2); border-radius: 12px; padding: 5px; box-shadow: var(--shadow); }
.ctx-menu .item { display: flex; justify-content: space-between; gap: 20px; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.ctx-menu .item:hover { background: var(--panel3); }
.ctx-menu .item.disabled { opacity: .4; pointer-events: none; }
.ctx-menu .sep { height: 1px; background: var(--line); margin: 4px 6px; }
.modal-wrap { position: fixed; inset: 0; z-index: 900; background: rgba(6, 4, 16, .66); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 30px; }
.modal { background: var(--panel); border: 1px solid var(--line2); border-radius: 18px; box-shadow: var(--shadow); width: min(560px, 96vw); max-height: 92vh; display: flex; flex-direction: column; }
.modal.wide { width: min(1180px, 96vw); }
.modal.mid { width: min(860px, 96vw); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 10px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 4px 20px 16px; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line); }
#toasts { position: fixed; right: 18px; bottom: 46px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { background: #1b1630; border: 1px solid var(--line2); border-radius: 11px; padding: 9px 14px; box-shadow: var(--shadow); max-width: 440px; transition: opacity .4s, transform .4s; }
.toast.ok { border-color: rgba(69, 196, 107, .5); }
.toast.err { border-color: rgba(255, 90, 95, .6); color: #ffd1d2; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* start / templates */
.start-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.start-card { background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; cursor: pointer; display: flex; gap: 12px; }
.start-card:hover { border-color: var(--accent); }
.start-card .ic { font-size: 20px; color: var(--accent); }
.start-card b { display: block; margin-bottom: 3px; }
.start-card span { color: var(--muted); font-size: 12px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.tpl { background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; cursor: pointer; transition: transform .12s, border-color .12s; }
.tpl:hover { border-color: var(--accent); transform: translateY(-2px); }
.tpl .thumb { position: relative; height: 118px; overflow: hidden; background: linear-gradient(#7fb3ff 0%, #a9cdfb 52%, #6aa84f 52%, #4e8a3a 100%); }
.tpl .thumb iframe { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; border: 0; transform-origin: 0 0; pointer-events: none; }
.tpl .meta { padding: 10px 12px 12px; }
.tpl .meta b { display: flex; justify-content: space-between; gap: 6px; margin-bottom: 4px; }
.tpl .meta span { color: var(--muted); font-size: 12px; line-height: 1.4; }
.tag { font-size: 10px; padding: 1px 7px; border-radius: 6px; background: var(--panel3); color: var(--muted); font-weight: 600; }
.tag.hud { color: var(--blue); background: rgba(90, 169, 255, .14); }

/* export / settings */
.export-text { width: 100%; min-height: 360px; font-size: 12px; white-space: pre; }
.steps { margin: 6px 0 14px; padding-left: 20px; color: var(--muted); line-height: 1.7; }
.steps code, .hint code, .help code { background: var(--bg2); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; color: #d8b4fe; font-size: 12px; }
.cfg-group { background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; }
.cfg-group h3 { margin: 0 0 10px; font-size: 13px; color: var(--accent); }
.cfg-item { display: grid; grid-template-columns: 230px 1fr; gap: 12px; align-items: start; padding: 8px 0; border-top: 1px solid var(--line); }
.cfg-item:first-of-type { border-top: 0; }
.cfg-item .k { font: 12px "Cascadia Code", Consolas, monospace; color: var(--text); }
.cfg-item .d { color: var(--dim); font-size: 11.5px; margin-top: 3px; line-height: 1.4; }
.help table { width: 100%; border-collapse: collapse; }
.help td { border-top: 1px solid var(--line); padding: 6px; vertical-align: top; }
.help h3 { color: var(--accent); }
.kf { display: grid; grid-template-columns: repeat(4, 1fr) 26px; gap: 6px; align-items: end; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin-bottom: 6px; }
.kf .field > span { font-size: 10.5px; }
.el.cond-off { display: none; }
.el.cond-sel { opacity: .45 !important; outline: 1px dashed #ffd166; }

/* ---- UI Essentials look: purple, glass and soft glows ---- */
body { background: radial-gradient(1200px 600px at 10% -10%, rgba(124, 58, 237, .16), transparent 60%), radial-gradient(900px 500px at 110% 110%, rgba(91, 91, 240, .12), transparent 60%), var(--bg); }
.panel { background: linear-gradient(180deg, rgba(26, 22, 41, .92), rgba(19, 16, 31, .92)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035), 0 8px 30px rgba(0, 0, 0, .25); }
#top { backdrop-filter: blur(12px); border-color: #2c2546; }
.logo { border-radius: 11px; font-size: 13px; letter-spacing: -.02em; }
.brand > div:last-child { font-size: 14.5px; }
.brand small { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 800; }
.ptab.active { border-color: rgba(var(--accent-rgb), .55); box-shadow: inset 0 -2px 0 var(--accent); }
.ptabs .t.active { box-shadow: inset 0 -2px 0 var(--accent2); color: #fff; }
.tool { border-radius: 12px; }
.tool:hover { color: var(--accent2); }
.btn { border-radius: 11px; }
.btn.accent { background: var(--grad); }
.btn.on { color: var(--accent2); border-color: var(--accent); background: rgba(var(--accent-rgb), .12); }
.layer.sel { box-shadow: inset 2px 0 0 var(--accent2); }
.start-card:hover, .tpl:hover { border-color: var(--accent); box-shadow: var(--glow); }
.start-card .ic { color: var(--accent2); }
.modal { background: linear-gradient(180deg, #1a1629, #13101f); border-color: #3a3158; }
.modal-head h2 { background: linear-gradient(90deg, #fff, #d8b4fe); -webkit-background-clip: text; background-clip: text; color: transparent; }
.cfg-group h3, .help h3 { color: var(--accent2); }
#status { font-size: 11px; letter-spacing: .01em; }
#zoombar, #aspectbar { backdrop-filter: blur(8px); border-color: #2c2546; }
.sel-label { background: var(--grad); color: #fff; }
.handle { border-color: var(--accent); }
.marquee { border-color: var(--accent2); }
.cv-preview, .tpl .thumb, #screen.bg-game { background: linear-gradient(#8fb8ff 0%, #b9d4fb 52%, #6aa84f 52%, #4e8a3a 100%); }

/* ---- segmented buttons, item field, 3D model preview ---- */
.seg { display: flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; }
.seg-btn { flex: 1 1 auto; min-width: 0; border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px; padding: 6px 8px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.seg-btn:hover { color: var(--text); background: var(--panel2); }
.seg-btn.on { background: var(--grad); color: #fff; box-shadow: var(--glow); }
.item-ico { width: 30px; height: 30px; flex: none; border-radius: 7px; background: var(--bg2) center / 22px no-repeat; border: 1px solid var(--line); display: grid; place-items: center; color: var(--dim); image-rendering: pixelated; font-size: 13px; }
.model-host { perspective: 600px; display: grid; place-items: center; }
.model-3d { width: 100%; height: 100%; display: grid; place-items: center; transform-style: preserve-3d; }
.model-3d > * { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(3px 4px 0 rgba(0, 0, 0, .35)); }
.model-3d.spinning > * { animation: uie-spin var(--spin, 4s) linear infinite; }
@keyframes uie-spin { to { transform: rotateY(360deg); } }
.note-box { background: rgba(var(--accent-rgb), .08); border: 1px solid rgba(var(--accent-rgb), .3); border-radius: 10px; padding: 10px 12px; margin: 6px 0 10px; font-size: 12.5px; line-height: 1.55; color: var(--text); display: grid; gap: 4px; }

/* ---- timeline (clips) ---- */
#center { display: flex; flex-direction: column; }
#center > #viewport { flex: 1; min-height: 0; }
#timeline { flex: none; height: 330px; border-top: 1px solid var(--line); background: var(--bg2); display: flex; flex-direction: column; border-radius: 0 0 var(--r) var(--r); }
.tl-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tl-head select, .tl-num { width: auto; padding: 4px 8px; font-size: 12px; }
.tl-num { width: 82px; }
.tl-check { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.tl-clock { font: 600 12px "Cascadia Code", Consolas, monospace; color: var(--accent2); min-width: 56px; text-align: right; }
.tl-zoom { width: 90px; }
.tl-empty { padding: 26px; text-align: center; color: var(--dim); }
.tl-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 112px 1fr 250px; }
.tl-lanes { padding-top: 24px; border-right: 1px solid var(--line); }
.tl-label { height: 28px; display: flex; align-items: center; gap: 7px; padding: 0 10px; font-size: 12px; color: var(--muted); border-bottom: 1px solid rgba(255, 255, 255, .03); }
.tl-label i { width: 8px; height: 8px; border-radius: 2px; transform: rotate(45deg); }
.tl-scroll { overflow-x: auto; overflow-y: hidden; position: relative; }
.tl-inner { position: relative; min-height: 100%; }
.tl-ruler { height: 24px; position: relative; border-bottom: 1px solid var(--line); cursor: ew-resize; background: var(--panel); }
.tl-tick { position: absolute; top: 14px; width: 1px; height: 10px; background: var(--line2); font-size: 10px; color: var(--dim); }
.tl-tick.major { top: 4px; height: 20px; background: var(--dim); }
.tl-tick.major { padding-left: 4px; }
.tl-lane { height: 28px; position: relative; border-bottom: 1px solid rgba(255, 255, 255, .03); cursor: copy; }
.tl-lane:hover { background: rgba(var(--accent-rgb), .05); }
.tl-key { position: absolute; top: 8px; width: 12px; height: 12px; margin-left: -6px; transform: rotate(45deg); border-radius: 2px; cursor: grab; box-shadow: 0 0 0 2px var(--bg2); }
.tl-key.on { box-shadow: 0 0 0 2px #fff, 0 0 12px rgba(255, 255, 255, .5); }
.tl-playhead { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--accent2); pointer-events: none; box-shadow: 0 0 10px rgba(var(--accent-rgb), .8); }
.tl-playhead::before { content: ''; position: absolute; top: 0; left: -5px; border: 6px solid transparent; border-top-color: var(--accent2); }
.tl-end { position: absolute; top: 24px; bottom: 0; width: 1px; border-left: 1px dashed var(--dim); pointer-events: none; }
.tl-inspector { border-left: 1px solid var(--line); padding: 10px 12px; overflow-y: auto; display: grid; gap: 8px; align-content: start; }
.tl-inspector h4 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent2); }
.clip-list { display: grid; gap: 6px; }
.clip-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 9px; background: var(--bg2); border: 1px solid var(--line); font-size: 12.5px; }
.clip-row small { color: var(--dim); }


/* ---------- bottom drawer: logic / animations / game ---------- */
#timeline.collapsed { height: auto; }
#timeline.collapsed .dr-tabs { border-bottom: 0; padding-bottom: 6px; }
.dr-fold { font-size: 16px; }
.dr-tabs { display: flex; align-items: center; gap: 4px; padding: 6px 10px 0; border-bottom: 1px solid var(--line); }
.dr-tab { border: 0; background: none; color: var(--muted); padding: 8px 12px; font: 600 13px inherit; border-bottom: 2px solid transparent; cursor: pointer; }
.dr-tab:hover { color: var(--text); }
.dr-tab.on { color: var(--text); border-bottom-color: var(--accent); }
.dr-tabs .hint { font-size: 12px; margin-right: 8px; }
.dr-body { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }

/* ---------- logic (blocks) ---------- */
.lg-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
.lg-target { font: 12px "Cascadia Code", Consolas, monospace; color: var(--accent2); background: var(--panel2); padding: 2px 8px; border-radius: 6px; }
.lg-zoom { font: 12px "Cascadia Code", Consolas, monospace; color: var(--muted); min-width: 42px; text-align: center; }
.lg-canvas { flex: 1; min-height: 0; position: relative; overflow: hidden; cursor: grab;
  background-color: var(--bg); background-image: radial-gradient(circle, rgba(255, 255, 255, .07) 1px, transparent 1.2px); background-size: 22px 22px; }
.lg-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.lg-links { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; }
.lg-link { fill: none; stroke: #8f8aa8; stroke-width: 2.5; cursor: pointer; pointer-events: stroke; }
.lg-link:hover { stroke: var(--bad); stroke-width: 4; }
.lg-link.ok { stroke: #4ade80; }
.lg-link.no { stroke: #f87171; }
.lg-link.temp { stroke: var(--accent2); stroke-dasharray: 6 5; pointer-events: none; }
.lg-node { position: absolute; width: 250px; background: #16131f; border: 1.5px solid var(--line2); border-radius: 12px; box-shadow: 0 8px 22px rgba(0, 0, 0, .45); font-size: 12px; cursor: default; }
.lg-node.root { width: 210px; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .18), 0 8px 22px rgba(0, 0, 0, .45); }
.lg-nhead { position: relative; display: flex; align-items: center; gap: 7px; padding: 9px 10px; cursor: move; user-select: none; }
.lg-nhead b { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lg-icon { width: 24px; height: 24px; flex: none; display: grid; place-items: center; border-radius: 7px; background: var(--panel3); font-size: 13px; }
.lg-fold, .lg-del { border: 0; background: none; color: var(--dim); cursor: pointer; padding: 0 2px; font-size: 12px; }
.lg-del:hover { color: var(--bad); }
.lg-in { position: absolute; left: -7px; top: 13px; width: 12px; height: 12px; border-radius: 50%; background: var(--bg); border: 2px solid #8f8aa8; }
.lg-out { flex: none; width: 18px; height: 18px; display: grid; place-items: center; color: #e5e1f5; cursor: crosshair; font-size: 13px; margin-right: -16px; }
.lg-out:hover { color: var(--accent2); transform: scale(1.25); }
.lg-nbody { padding: 0 12px 10px; display: flex; flex-wrap: wrap; gap: 6px; border-top: 1px solid var(--line); padding-top: 8px; }
.lg-field { display: flex; flex-direction: column; gap: 3px; width: 100%; color: var(--muted); font-size: 11px; }
.lg-field.half { width: calc(50% - 3px); }
.lg-field.check { flex-direction: row; align-items: center; gap: 6px; }
.lg-field input, .lg-field select, .lg-field textarea { width: 100%; padding: 5px 7px; font-size: 12px; border-radius: 7px; background: var(--bg2); border: 1px solid var(--line2); color: var(--text); }
.lg-field input[type=checkbox] { width: auto; }
.lg-field textarea { resize: vertical; font-family: inherit; }
.lg-branches { border-top: 1px solid var(--line); padding: 6px 0 6px 12px; display: grid; gap: 4px; }
.lg-branch { display: flex; justify-content: flex-end; align-items: center; gap: 6px; font-weight: 600; font-size: 12px; }
.lg-branch.ok { color: #4ade80; }
.lg-branch.no { color: #f87171; }
.lg-node.collapsed .lg-nbody { display: none; }
.lg-picker { position: absolute; z-index: 30; width: 290px; max-height: 360px; display: flex; flex-direction: column; background: #17141f; border: 1px solid var(--line2); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.lg-pfrom { padding: 9px 12px 6px; font-size: 11px; color: var(--dim); }
.lg-psearch { margin: 0 10px 6px; display: flex; align-items: center; gap: 6px; padding: 0 8px; border: 1px solid var(--line2); border-radius: 8px; background: var(--bg2); color: var(--dim); }
.lg-psearch input { border: 0; background: none; padding: 7px 0; width: 100%; color: var(--text); outline: none; }
.lg-plist { overflow-y: auto; padding: 0 6px 8px; }
.lg-pcat { padding: 10px 8px 4px; font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--dim); }
.lg-pitem { width: 100%; display: flex; align-items: center; gap: 9px; padding: 6px 8px; border: 0; border-radius: 8px; background: none; color: var(--text); font-size: 13px; text-align: left; cursor: pointer; }
.lg-pitem:hover { background: var(--panel3); }
.lg-pbadge { margin-left: auto; font-size: 10px; padding: 1px 7px; border-radius: 99px; border: 1px solid #b7862c; color: #f2c46d; }

/* ---------- timeline in ticks ---------- */
.tl-tick .tk { position: absolute; left: 4px; top: -2px; white-space: nowrap; }
.tl-key-all { color: #f2c46d; }
.tl-label .tl-add { margin-left: auto; border: 0; background: none; color: #b7862c; cursor: pointer; font-size: 11px; }
.tl-label .tl-add:hover { color: #f2c46d; }
.tl-label { text-transform: uppercase; letter-spacing: .06em; font-weight: 700; font-size: 11px; }
.tl-lane { margin: 2px 0; border-radius: 8px; background: rgba(255, 255, 255, .025); border-bottom: 0; height: 26px; }
.tl-playhead { background: #ff7a3d; box-shadow: 0 0 8px rgba(255, 122, 61, .7); }
.tl-playhead::before { display: none; }
.tl-phead { position: absolute; top: 2px; left: 50%; transform: translateX(-50%); padding: 1px 7px; border-radius: 99px; background: #ff7a3d; color: #1b0f08; font: 700 11px "Cascadia Code", Consolas, monospace; }

/* ---------- variables ---------- */
.vr-wrap { flex: 1; min-height: 0; overflow-y: auto; }
.vr-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.vr-bar .hint { font-size: 12px; }
.vr-table { padding: 6px 12px 12px; display: grid; gap: 6px; }
.vr-row { display: grid; grid-template-columns: 190px 1fr 1fr 1fr 34px; gap: 8px; align-items: center; }
.vr-row select, .vr-row input { padding: 5px 8px; font-size: 13px; }
.vr-row code { color: #f2c46d; font-size: 12px; }
.vr-headrow { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--dim); }

/* ---------- game script ---------- */
.sc-wrap { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 380px; }
.sc-code { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.sc-bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.sc-bar .hint { font-size: 12px; }
.sc-editor { flex: 1; min-height: 0; position: relative; }
.sc-editor .ce { height: 100%; }
.sc-help { overflow-y: auto; padding: 8px 12px; font-size: 12px; }
.sc-help h4 { margin: 10px 0 4px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent2); }
.sc-api { display: grid; gap: 2px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.sc-api code { color: #f2c46d; font-size: 11.5px; white-space: normal; }
.sc-api span { color: var(--muted); }
.sc-play { position: fixed; inset: 0; z-index: 9000; display: flex; flex-direction: column; background: rgba(5, 4, 10, .96); }
.sc-top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.sc-status { font-size: 13px; color: var(--muted); max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-status.err { color: var(--bad); }
.sc-frame { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.sc-stage { position: absolute; transform-origin: 0 0; overflow: hidden; background: #111; cursor: pointer; }
