/* Unity-style dark editor skin */
:root {
  --bg: #383838;
  --bg-dark: #282828;
  --bg-darker: #1e1e1e;
  --bg-tab: #3c3c3c;
  --bg-header: #3e3e3e;
  --bg-hover: #454545;
  --bg-input: #2a2a2a;
  --border: #191919;
  --border-soft: #232323;
  --text: #c4c4c4;
  --text-bright: #e4e4e4;
  --text-dim: #8a8a8a;
  --sel: #2c5d87;
  --sel-unfocus: #4d4d4d;
  --accent: #3a79bb;
  --btn: #585858;
  --btn-hover: #676767;
  --btn-border: #303030;
  --prefab: #7bb0f5;
  --x: #e1563e;
  --y: #8bc34a;
  --z: #3d8ef5;
  --warn: #f4bc02;
  --err: #ff534a;
  --rune: #5fd6e0;
  --left-w: 260px;
  --right-w: 360px;
  --bottom-h: 270px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg-darker); color: var(--text);
  font: 12px/1.35 Inter, "Segoe UI", system-ui, -apple-system, sans-serif; user-select: none; }
input, select, button, textarea { font: inherit; color: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #2b2b2b; }
::-webkit-scrollbar-thumb { background: #5e5e5e; border: 2px solid #2b2b2b; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #727272; }
svg.i { width: 14px; height: 14px; flex: none; vertical-align: middle; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

#app { display: grid; grid-template-rows: 22px 36px 1fr 22px; height: 100vh; }

/* ---------- menubar ---------- */
#menubar { display: flex; align-items: stretch; background: var(--bg-dark); border-bottom: 1px solid var(--border); padding-left: 4px; }
#menubar .mi { padding: 0 9px; display: flex; align-items: center; cursor: default; color: var(--text); }
#menubar .mi:hover, #menubar .mi.open { background: var(--bg-hover); }
#menubar .brand { margin-left: auto; padding: 0 10px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
#menubar .brand b { color: var(--rune); font-weight: 600; }
.mcp-dot { width: 7px; height: 7px; border-radius: 50%; background: #666; display: inline-block; }
.mcp-dot.on { background: #4caf50; box-shadow: 0 0 6px #4caf50; }
.mcp-dot.busy { background: var(--rune); box-shadow: 0 0 8px var(--rune); }

.menu { position: fixed; z-index: 1000; min-width: 210px; background: #2d2d2d; border: 1px solid #111; box-shadow: 0 6px 18px rgba(0,0,0,.55); padding: 3px 0; }
.menu .it { padding: 3px 22px 3px 24px; display: flex; gap: 20px; justify-content: space-between; align-items: center; white-space: nowrap; position: relative; }
.menu .it:hover:not(.dis) { background: var(--sel); color: #fff; }
.menu .it.dis { color: #6a6a6a; }
.menu .it .k { color: var(--text-dim); font-size: 11px; }
.menu .it:hover .k { color: #dde; }
.menu .it.sub::after { content: "▸"; position: absolute; right: 8px; }
.menu .it .chk { position: absolute; left: 8px; }
.menu .sep { height: 1px; background: #444; margin: 3px 0; }
.menu .hdr { padding: 3px 12px; color: var(--text-dim); font-size: 11px; }

/* ---------- toolbar ---------- */
#toolbar { display: flex; align-items: center; background: var(--bg-dark); border-bottom: 1px solid var(--border); padding: 0 8px; gap: 8px; }
.tgroup { display: flex; border: 1px solid var(--btn-border); border-radius: 3px; overflow: hidden; }
.tbtn { background: #3b3b3b; border: 0; border-right: 1px solid var(--btn-border); height: 24px; min-width: 28px; padding: 0 7px; display: flex; align-items: center; justify-content: center; gap: 5px; color: var(--text); cursor: default; }
.tbtn:last-child { border-right: 0; }
.tbtn:hover { background: #4a4a4a; }
.tbtn.on { background: #46607c; color: #fff; }
.tbtn.play.on { background: #3a6ea5; }
.tbtn .i { width: 15px; height: 15px; }
.tcenter { position: absolute; left: 50%; transform: translateX(-50%); }
#toolbar .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.btn { background: var(--btn); border: 1px solid var(--btn-border); border-radius: 3px; padding: 2px 10px; height: 22px; color: #eee; cursor: default; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.btn:hover { background: var(--btn-hover); }
.btn:active { background: #4a4a4a; }
.btn.primary { background: #2f6aa6; border-color: #1c4670; }
.btn.primary:hover { background: #3a7cc0; }
.btn.small { height: 18px; padding: 0 6px; font-size: 11px; }
.btn.full { width: 100%; justify-content: center; }
.btn.danger:hover { background: #8a3a36; }

/* ---------- dock ---------- */
#dock { display: grid; min-height: 0;
  grid-template-columns: var(--left-w) 3px 1fr 3px var(--right-w);
  grid-template-rows: 1fr 3px var(--bottom-h);
  grid-template-areas: "hier sl view sr insp" "sb sb sb sr insp" "bot bot bot sr insp"; background: var(--border); }
#p-hierarchy { grid-area: hier; } #p-view { grid-area: view; } #p-inspector { grid-area: insp; } #p-bottom { grid-area: bot; }
.split[data-split="left"] { grid-area: sl; cursor: col-resize; }
.split[data-split="right"] { grid-area: sr; cursor: col-resize; }
.split[data-split="bottom"] { grid-area: sb; cursor: row-resize; }
.split { background: var(--border); }
.split:hover, .split.drag { background: var(--accent); }
.panel { background: var(--bg); display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.tabs { display: flex; background: var(--bg-dark); height: 22px; flex: none; align-items: flex-end; padding-left: 2px; }
.tab { padding: 0 12px; height: 21px; display: flex; align-items: center; gap: 5px; color: var(--text-dim); border: 1px solid transparent; border-bottom: 0; border-radius: 3px 3px 0 0; cursor: default; }
.tab.on { background: var(--bg-tab); color: var(--text-bright); border-color: var(--border); position: relative; top: 1px; }
.tab:not(.on):hover { color: var(--text); background: #303030; }
.tabs .spacer { flex: 1; }
.tabs .kebab { color: var(--text-dim); padding: 0 6px; height: 21px; display: flex; align-items: center; }
.ptool { display: flex; align-items: center; gap: 4px; height: 24px; padding: 0 4px; background: var(--bg-tab); border-bottom: 1px solid var(--border); flex: none; }
.ptool .grow { flex: 1; }
.search { background: var(--bg-input); border: 1px solid var(--border); border-radius: 10px; height: 18px; padding: 0 8px 0 22px; width: 100%; max-width: 220px; outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5'%3E%3Ccircle cx='10' cy='10' r='6'/%3E%3Cpath d='M15 15l6 6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 6px 3px; }
.search:focus { border-color: var(--accent); }
.dd { background: #4b4b4b; border: 1px solid var(--btn-border); border-radius: 3px; height: 18px; padding: 0 6px; display: inline-flex; align-items: center; gap: 4px; cursor: default; white-space: nowrap; font-size: 11px; }
.dd:hover { background: #575757; }
.dd.on { background: #46607c; }
.dd .car { font-size: 9px; opacity: .8; }
.body { flex: 1; overflow: auto; min-height: 0; position: relative; }

/* ---------- hierarchy ---------- */
.tree { padding: 2px 0; }
.row { display: flex; align-items: center; height: 20px; padding-right: 8px; gap: 4px; white-space: nowrap; cursor: default; }
.row:hover { background: #404040; }
.row.sel { background: var(--sel); color: #fff; }
.row .arrow { width: 12px; text-align: center; color: var(--text-dim); font-size: 9px; flex: none; }
.row .name { overflow: hidden; text-overflow: ellipsis; }
.row.prefab .name { color: var(--prefab); }
.row.sel.prefab .name { color: #d8e8ff; }
.row.inactive .name { opacity: .45; }
.row.scene { background: #3e3e3e; font-weight: 600; border-bottom: 1px solid var(--border-soft); }
.row.drop-into { outline: 1px solid var(--accent); outline-offset: -1px; }
.row .pf-arrow { margin-left: auto; color: var(--text-dim); font-size: 10px; }
.row input.rename { background: var(--bg-input); border: 1px solid var(--accent); color: #fff; height: 17px; padding: 0 3px; outline: none; width: 160px; }

/* ---------- viewport ---------- */
#viewwrap { position: relative; flex: 1; min-height: 0; background: #202020; }
#viewwrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#overlay { pointer-events: none; }
#viewwrap.drop { outline: 2px solid var(--accent); outline-offset: -2px; }
.vlabel { position: absolute; left: 8px; bottom: 6px; color: #ddd; font-size: 11px; text-shadow: 0 1px 2px #000; pointer-events: none; }
.stats { position: absolute; right: 8px; top: 8px; background: rgba(30,30,30,.82); border: 1px solid #111; border-radius: 3px; padding: 6px 10px; font: 11px/1.5 ui-monospace, Consolas, monospace; color: #ddd; pointer-events: none; white-space: pre; }
.play-tint #viewwrap::after { content: ""; position: absolute; inset: 0; border: 2px solid #3a6ea5; pointer-events: none; }
.hint { position: absolute; left: 50%; top: 40%; transform: translate(-50%,-50%); color: #aaa; text-align: center; pointer-events: none; }

/* ---------- inspector ---------- */
.insp { padding-bottom: 30px; }
.ihead { display: flex; gap: 8px; padding: 8px 8px 6px; align-items: center; border-bottom: 1px solid var(--border); background: var(--bg-header); }
.ihead .big { width: 36px; height: 36px; border-radius: 2px; flex: none; display: flex; align-items: center; justify-content: center; background: #2b2b2b; overflow: hidden; }
.ihead .big img { width: 100%; height: 100%; object-fit: cover; }
.ihead .big .i { width: 26px; height: 26px; }
.ihead .col { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ihead .line { display: flex; gap: 6px; align-items: center; }
.ihead .sub { color: var(--text-dim); font-size: 11px; display: flex; gap: 10px; align-items: center; }
.prefab-bar { display: flex; gap: 4px; padding: 4px 8px; background: #3a4656; border-bottom: 1px solid var(--border); align-items: center; font-size: 11px; color: #cfe0f5; }
.prefab-bar .grow { flex: 1; }
.comp { border-bottom: 1px solid var(--border); }
.comp-h { display: flex; align-items: center; gap: 6px; height: 24px; padding: 0 6px; background: var(--bg-header); border-top: 1px solid #4a4a4a; cursor: default; }
.comp-h:hover { background: #474747; }
.comp-h .fold { width: 10px; font-size: 9px; color: var(--text-dim); }
.comp-h .title { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comp-h .runeic { color: var(--rune); font-size: 15px; width: 16px; text-align: center; }
.comp-h .tag { color: var(--text-dim); font-weight: 400; font-size: 11px; }
.comp-h .icn { color: var(--text-dim); padding: 0 3px; }
.comp-h .icn:hover { color: #fff; }
.comp-b { padding: 4px 8px 8px 18px; }
.comp.closed .comp-b { display: none; }
.comp.disabled .comp-b { opacity: .5; }
.f { display: flex; align-items: center; min-height: 20px; gap: 6px; margin: 1px 0; }
.f > label { flex: 0 0 42%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.f > label.drag { cursor: ew-resize; }
.f > .c { flex: 1; display: flex; gap: 4px; align-items: center; min-width: 0; }
.f.note { color: var(--text-dim); font-size: 11px; }
.inp { background: var(--bg-input); border: 1px solid var(--border); border-radius: 2px; height: 18px; padding: 0 4px; outline: none; min-width: 0; width: 100%; }
.inp:focus { border-color: var(--accent); }
select.inp { padding: 0 2px; }
.num { width: 56px; flex: none; text-align: left; }
.vec { display: flex; gap: 4px; flex: 1; min-width: 0; }
.vec .ax { display: flex; align-items: center; flex: 1; min-width: 0; }
.vec .ax b { width: 12px; font-weight: 400; text-align: center; cursor: ew-resize; color: var(--text); }
.vec .ax .inp { flex: 1; }
input[type=range] { -webkit-appearance: none; appearance: none; flex: 1; min-width: 30px; height: 18px; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { height: 2px; background: #5e5e5e; border-radius: 1px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 10px; height: 10px; margin-top: -4px; background: #999; border-radius: 50%; border: 0; }
input[type=range]:hover::-webkit-slider-thumb { background: #ccc; }
input[type=range]::-moz-range-track { height: 2px; background: #5e5e5e; }
input[type=range]::-moz-range-thumb { width: 10px; height: 10px; background: #999; border-radius: 50%; border: 0; }
input[type=checkbox] { accent-color: #6b8db5; margin: 0; width: 13px; height: 13px; }
input[type=color] { width: 100%; height: 18px; border: 1px solid var(--border); padding: 0; background: var(--bg-input); cursor: pointer; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 1px; }
input[type=color]::-webkit-color-swatch { border: 0; }
.objfield { display: flex; align-items: center; gap: 5px; background: var(--bg-input); border: 1px solid var(--border); height: 18px; padding: 0 0 0 3px; flex: 1; min-width: 0; cursor: default; }
.objfield:hover { border-color: #555; }
.objfield img, .objfield .sw { width: 14px; height: 14px; border-radius: 2px; flex: none; }
.objfield .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.objfield .pick { width: 18px; height: 16px; display: flex; align-items: center; justify-content: center; border-left: 1px solid var(--border); color: var(--text-dim); }
.objfield .pick:hover { color: #fff; background: #3a3a3a; }
.addcomp { display: flex; justify-content: center; padding: 12px; }
.addcomp .btn { width: 70%; justify-content: center; }
.preview { border-top: 1px solid var(--border); background: #2b2b2b; }
.preview .ph { display: flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; background: var(--bg-header); font-weight: 600; }
.preview .ph .grow { flex: 1; }
.preview .pv { display: flex; justify-content: center; padding: 8px; }
.preview .pv img, .preview .pv canvas { max-width: 100%; width: 256px; height: 256px; image-rendering: auto; background: repeating-conic-gradient(#3a3a3a 0 25%, #2e2e2e 0 50%) 0 0/16px 16px; }
.maptabs { display: flex; gap: 2px; }
.maptabs span { padding: 1px 6px; border-radius: 2px; color: var(--text-dim); font-weight: 400; font-size: 11px; }
.maptabs span.on { background: #555; color: #fff; }
.empty-insp { color: var(--text-dim); padding: 20px; text-align: center; }
.kindgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 4px 0; }
.kindgrid .btn { justify-content: center; }
.kindgrid .btn.on { background: #46607c; }

/* ---------- project ---------- */
.proj { display: grid; grid-template-columns: 180px 1fr; flex: 1; min-height: 0; }
.ptree { border-right: 1px solid var(--border); overflow: auto; padding: 4px 0; background: #353535; }
.pgrid-wrap { display: flex; flex-direction: column; min-height: 0; }
.crumbs { height: 22px; display: flex; align-items: center; padding: 0 8px; gap: 4px; color: var(--text); border-bottom: 1px solid var(--border-soft); flex: none; }
.crumbs span.sep { color: var(--text-dim); }
.pgrid { flex: 1; overflow: auto; padding: 8px; display: grid; gap: 6px 4px; grid-template-columns: repeat(auto-fill, minmax(var(--tile, 78px), 1fr)); align-content: start; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 2px; border-radius: 3px; cursor: default; }
.tile .th { width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-radius: 2px; position: relative; }
.tile .th img { width: 100%; height: 100%; object-fit: contain; }
.tile .th .i { width: 50%; height: 50%; color: #777; }
.tile .th .badge { position: absolute; right: 2px; bottom: 2px; font-size: 9px; background: rgba(0,0,0,.6); color: #bbb; padding: 0 3px; border-radius: 2px; }
.tile .lb { font-size: 11px; text-align: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; border-radius: 2px; }
.tile:hover .th { background: #404040; }
.tile.sel .lb { background: var(--sel); color: #fff; }
.tile.sel .th { background: #3b4a5a; }
.pfoot { height: 20px; display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 0 8px; border-top: 1px solid var(--border-soft); color: var(--text-dim); flex: none; }
.pfoot input[type=range] { flex: 0 0 90px; }

/* ---------- console ---------- */
.clog { font-size: 12px; }
.cl { display: flex; gap: 8px; padding: 3px 8px; border-bottom: 1px solid #333; align-items: flex-start; }
.cl:nth-child(even) { background: #3b3b3b; }
.cl .ic { width: 16px; flex: none; text-align: center; }
.cl .ic.info { color: #bbb; } .cl .ic.warn { color: var(--warn); } .cl .ic.error { color: var(--err); } .cl .ic.mcp { color: var(--rune); }
.cl .tx { flex: 1; white-space: pre-wrap; word-break: break-word; }
.cl .tm { color: var(--text-dim); font-size: 10px; flex: none; }
.cl .cnt { background: #555; border-radius: 8px; padding: 0 6px; font-size: 10px; }
.ccount { display: inline-flex; align-items: center; gap: 3px; padding: 0 5px; }

/* ---------- MCP panel ---------- */
.mcp { padding: 10px 12px; display: grid; grid-template-columns: minmax(280px, 1fr) minmax(280px, 1.3fr); gap: 14px; }
.mcp h3 { margin: 0 0 6px; font-size: 12px; color: var(--text-bright); display: flex; gap: 6px; align-items: center; }
.mcp .card { background: #303030; border: 1px solid var(--border); border-radius: 4px; padding: 8px 10px; margin-bottom: 10px; }
.mcp code, .mcp pre { font: 11px/1.45 ui-monospace, Consolas, monospace; color: #d8e6f3; }
.mcp pre { background: #232323; border: 1px solid #1a1a1a; padding: 6px 8px; border-radius: 3px; white-space: pre-wrap; margin: 6px 0; user-select: text; }
.mcp .tool { padding: 3px 0; border-bottom: 1px solid #3a3a3a; }
.mcp .tool b { color: var(--rune); font-weight: 600; font-family: ui-monospace, Consolas, monospace; font-size: 11px; }
.mcp .tool div { color: var(--text-dim); font-size: 11px; }
.mcp .act { font: 11px/1.4 ui-monospace, Consolas, monospace; padding: 2px 0; border-bottom: 1px solid #363636; }
.mcp .act .ok { color: #7bd88f; } .mcp .act .bad { color: var(--err); }
.mcp p { margin: 4px 0; color: var(--text); }
.mcp .muted { color: var(--text-dim); }

/* ---------- statusbar ---------- */
#statusbar { display: flex; align-items: center; justify-content: space-between; padding: 0 8px; background: var(--bg-dark); border-top: 1px solid var(--border); color: var(--text-dim); font-size: 11px; }
#statusbar .spin { display: inline-block; width: 9px; height: 9px; border: 2px solid #777; border-top-color: var(--rune); border-radius: 50%; animation: sp 0.8s linear infinite; margin-right: 6px; vertical-align: -1px; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ---------- modals ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 900; display: flex; align-items: center; justify-content: center; }
.win { background: var(--bg); border: 1px solid #111; box-shadow: 0 12px 40px rgba(0,0,0,.6); min-width: 420px; max-width: 92vw; max-height: 88vh; display: flex; flex-direction: column; }
.win .wt { background: var(--bg-dark); height: 26px; display: flex; align-items: center; padding: 0 10px; font-weight: 600; border-bottom: 1px solid var(--border); }
.win .wt .x { margin-left: auto; color: var(--text-dim); padding: 0 4px; }
.win .wt .x:hover { color: #fff; }
.win .wb { padding: 12px 14px; overflow: auto; }
.win .wf { display: flex; justify-content: flex-end; gap: 6px; padding: 8px 14px; border-top: 1px solid var(--border); background: #333; }
.win h4 { margin: 10px 0 4px; font-size: 12px; color: var(--text-bright); border-bottom: 1px solid #444; padding-bottom: 3px; }
.win h4:first-child { margin-top: 0; }
.radios { display: flex; flex-direction: column; gap: 3px; }
.radios label { display: flex; align-items: center; gap: 6px; }
.picklist { max-height: 300px; overflow: auto; border: 1px solid var(--border); background: #2f2f2f; }
.picklist .pi { display: flex; align-items: center; gap: 8px; padding: 3px 6px; }
.picklist .pi:hover { background: #404040; }
.picklist .pi.sel { background: var(--sel); }
.picklist .pi img { width: 28px; height: 28px; border-radius: 2px; }
.kbd { display: inline-block; background: #2a2a2a; border: 1px solid #555; border-bottom-width: 2px; border-radius: 3px; padding: 0 5px; font-size: 11px; font-family: ui-monospace, Consolas, monospace; }
.help-grid { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; }

/* ---------- boot ---------- */
#boot { position: fixed; inset: 0; background: #1b1b1b; display: flex; align-items: center; justify-content: center; z-index: 2000; transition: opacity .3s; }
#boot.gone { opacity: 0; pointer-events: none; }
.boot-card { text-align: center; }
.boot-logo { font-size: 56px; color: var(--rune); text-shadow: 0 0 24px rgba(95,214,224,.5); }
.boot-title { font-size: 20px; color: #eee; letter-spacing: .5px; margin-top: 4px; }
.boot-sub { color: #888; margin-top: 6px; }

@media (max-width: 900px) {
  :root { --left-w: 180px; --right-w: 280px; --bottom-h: 200px; }
  .proj { grid-template-columns: 1fr; } .ptree { display: none; }
  .mcp { grid-template-columns: 1fr; }
}
