/* Редактор меха: строгий «инженерный» вид поверх стилей редактора игры. */
:root { --mech-bar: 48px; --mech-bg: #0d1014; --mech-card: #161b22; --mech-line: #2b333e; --mech-acc: #f2a33a; --mech-txt: #dfe5ec; --mech-dim: #8b97a5; }
html, body { background: var(--mech-bg) !important; }
#mainmenu, #hud, #loadwin, #mm-toast, #cv, #uicv, #glcv { display: none !important; }
#mech-bar { position: fixed; z-index: 60; inset: 0 0 auto 0; height: var(--mech-bar); display: flex; align-items: center; gap: 12px;
  padding: 0 12px; background: #0a0d10ee; border-bottom: 1px solid var(--mech-line); color: var(--mech-txt); font: 14px/1.2 system-ui, sans-serif; backdrop-filter: blur(6px); }
#mech-bar .mb-logo { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
#mech-bar .mb-logo img { width: 28px; height: 28px; }
#mech-bar .mb-logo b { letter-spacing: .18em; color: var(--mech-acc); }
#mech-bar .mb-logo span { color: var(--mech-dim); }
#mech-bar .mb-cur { flex: 1; min-width: 0; color: var(--mech-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mech-bar .mb-cur a { color: var(--mech-acc); }
#mech-bar .mb-cur .ok { color: #6fd08c; font-style: normal; }
#mech-bar .mb-cur .warn { font-style: normal; }
#mech-bar .mb-btns { display: flex; gap: 6px; }
#mech-bar button, .mech-modal button { font: inherit; color: var(--mech-txt); background: #1d242d; border: 1px solid #3a4452; border-radius: 6px; padding: 7px 11px; cursor: pointer; min-height: 34px; }
#mech-bar button:hover, .mech-modal button:hover { border-color: var(--mech-acc); }
#mb-acc { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#editor.screen { padding-top: var(--mech-bar) !important; box-sizing: border-box; }
#editor [data-act="ed-cancel"], #ed-done, #ed-gal-row, #ed-code, #ed-budget { display: none !important; }
#editor .ed-save button { flex: 1; }
.mech-modal { position: fixed; z-index: 80; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: #05070acc; color: var(--mech-txt); font: 15px/1.45 system-ui, sans-serif; }
.mech-modal .mm-card { width: min(440px, 100%); max-height: 100%; overflow: auto; box-sizing: border-box; background: var(--mech-card);
  border: 1px solid var(--mech-line); border-radius: 12px; padding: 20px; box-shadow: 0 20px 60px #000a; }
.mech-modal .mm-card.wide { width: min(900px, 100%); }
.mech-modal h2 { margin: 0 0 8px; font-size: 20px; color: #fff; }
.mech-modal h3 { margin: 18px 0 8px; font-size: 15px; color: var(--mech-acc); }
.mech-modal h3 small { color: var(--mech-dim); font-weight: normal; }
.mech-modal p { margin: 0 0 12px; color: #b9c3ce; }
.ma-tabs { display: flex; gap: 6px; margin: 12px 0; }
.ma-tabs button { flex: 1; }
.ma-tabs button.on { border-color: var(--mech-acc); color: var(--mech-acc); }
#ma-form label { display: block; margin: 8px 0; color: var(--mech-dim); font-size: 13px; }
#ma-form input { display: block; width: 100%; box-sizing: border-box; margin-top: 4px; padding: 10px; font: inherit; color: #fff; background: #0e1217; border: 1px solid #3a4452; border-radius: 6px; }
#ma-form input:focus { outline: 2px solid var(--mech-acc); outline-offset: 0; }
.ma-err { min-height: 1.2em; color: #ff8a80; font-size: 14px; }
.mech-modal .ma-main { width: 100%; margin-top: 6px; padding: 11px; background: var(--mech-acc); color: #1a1205; border-color: var(--mech-acc); font-weight: 600; }
.mech-modal .ma-skip { width: 100%; margin-top: 10px; background: transparent; }
.ma-note { margin-top: 12px !important; font-size: 12.5px; color: var(--mech-dim) !important; }
.ml-head { display: flex; justify-content: space-between; align-items: center; }
.ml-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.ml-item { position: relative; }
.ml-item.cur .ml-open { border-color: var(--mech-acc); }
.mech-modal .ml-open { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px; background: #0f1318; }
.ml-open img { width: 110px; height: 110px; object-fit: contain; image-rendering: pixelated; }
.ml-noimg { width: 110px; height: 110px; display: grid; place-items: center; font-size: 40px; color: var(--mech-dim); }
.ml-open b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ml-open small { color: var(--mech-dim); }
.mech-modal .ml-del { position: absolute; top: 4px; right: 4px; padding: 3px 7px; min-height: 0; background: #0f1318cc; }
.ml-hint, .ml-wait { color: var(--mech-dim) !important; }
#mech-toast { position: fixed; z-index: 90; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; transition: .25s;
  background: #1d242d; color: #fff; border: 1px solid var(--mech-acc); border-radius: 8px; padding: 10px 16px; font: 14px system-ui, sans-serif; pointer-events: none; }
#mech-toast.on { opacity: 1; transform: translate(-50%, 0); }
.mech-fail { position: fixed; inset: 40% 10% auto; text-align: center; color: #ff8a80; font: 16px system-ui; }
@media (max-width: 640px) {
  #mech-bar { gap: 6px; padding: 0 6px; }
  #mech-bar .mb-logo span, #mech-bar .mb-cur { display: none; }
  #mech-bar .mb-btns { margin-left: auto; }
  #mech-bar button { padding: 6px 8px; }
  #mb-acc { max-width: 120px; }
}

/* ===== Раскладка как в Spore: режимы сверху, палитра слева, мех — на весь вид =====
   Обычного и «расширенного» вида нет: один экран. Покраска — отдельный режим на той же
   площадке (полноэкранный вид с кистью по модели + цвета меха в палитре). */
:root {
  --mode-h: 56px; --pal-w: 392px;
  --bg: #0d1014; --panel: #12161c; --line: #2b333e; --text: #dfe5ec; --dim: #8b97a5; --gold: #f2a33a; --cyan: #f2a33a;
  --ui-acc: #f2a33a; --ui-sel: #f2a33a; --ui-sub: #9fb8cc; --ui-pane: #12161c; --ui-card: #161b22; --ui-card-h: #1b212a;
  --ui-item: #1a2028; --ui-item-h: #212833; --ui-item-on: #2a2418; --ui-line: #2b333e; --ui-line2: #232a33;
}
body[data-edfac] { --ui-acc: #f2a33a; }
body[data-edfac="0"] { --ui-acc: #e0553f; }
body[data-edfac="1"] { --ui-acc: #9b6ef0; }
body, #editor, #ed-big { font-family: system-ui, -apple-system, "Segoe UI", sans-serif !important; }
#editor h2, #editor .ui-t, #editor .ui-sh, #ed-big .sec, #ed-big .ui-t, #editor .sec { font-family: system-ui, -apple-system, "Segoe UI", sans-serif !important; text-shadow: none !important; letter-spacing: .02em; }
#editor button, #ed-big button, #editor input, #editor select, #ed-big input, #ed-big select { border-radius: 8px !important; border-width: 1px !important; }
#perf, .perf, #fps { display: none !important; }

#editor.screen { position: fixed !important; inset: var(--mech-bar) 0 0 0 !important; padding: 0 !important; margin: 0 !important; overflow: hidden !important; display: block; background: var(--bg); }
#editor.screen.hidden { display: none !important; }
#editor .card.ed { position: absolute; inset: 0; max-width: none !important; width: auto !important; margin: 0 !important; padding: 0 !important; border: 0 !important; border-radius: 0 !important; background: transparent !important; box-shadow: none !important; }
#editor .ed-head { position: fixed; z-index: 6; top: calc(var(--mech-bar) + var(--mode-h) + 10px); right: 14px; margin: 0; padding: 0; background: none; border: 0; }
#editor .ed-head h2 { display: none; }
#editor .ed-head .ed-dirty { margin-right: 6px; }
#editor .ed-grid { position: absolute; inset: 0; display: block !important; }

/* режимы — сверху по центру */
#editor .ed-right { position: absolute; inset: 0 auto 0 0; width: var(--pal-w); display: block; }
#editor #ed-tabs { position: fixed; z-index: 75; top: var(--mech-bar); left: 0; right: 0; height: var(--mode-h); display: flex; justify-content: center; align-items: center; gap: 6px;
  margin: 0; padding: 0 8px; border: 0; border-bottom: 1px solid var(--line); background: #0f1318; flex-wrap: nowrap; overflow-x: auto; }
#editor #ed-tabs button { margin: 0; padding: 7px 14px; min-height: 40px; border: 1px solid transparent !important; border-radius: 20px !important; color: var(--dim); background: transparent; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 7px; white-space: nowrap; }
#editor #ed-tabs button::after { display: none; }
#editor #ed-tabs button .ts { display: none; }
#editor #ed-tabs button .tico { font-style: normal; font-size: 17px; }
#editor #ed-tabs button:hover { color: var(--text); background: #1a2028; }
#editor #ed-tabs button.on { color: #1a1205; background: var(--mech-acc); box-shadow: 0 0 0 1px #000, 0 2px 12px #f2a33a44; }

/* палитра — слева */
#editor #ed-pane { position: fixed; top: calc(var(--mech-bar) + var(--mode-h)); bottom: 0; left: 0; width: var(--pal-w); box-sizing: border-box; overflow-y: auto; overscroll-behavior: contain;
  padding: 10px 12px 24px; border: 0; border-right: 1px solid var(--line); background: var(--panel); }
#editor #ed-pane .ui-sec { border-radius: 10px; overflow: hidden; }

/* вид меха — всё остальное */
#editor .ed-left { position: fixed !important; top: calc(var(--mech-bar) + var(--mode-h)); bottom: 0; left: var(--pal-w); right: 0; display: block !important; width: auto !important; height: calc(100dvh - var(--mech-bar) - var(--mode-h)) !important; max-width: none !important; }
#editor .pvbox { position: absolute !important; inset: 0 !important; width: auto !important; height: auto !important; margin: 0 !important; border: 0 !important; border-radius: 0 !important;
  background: radial-gradient(ellipse at 50% 38%, #2a3440 0%, #161c23 55%, #0d1014 100%) !important; }
#editor #ed-pv { position: absolute; inset: 0; width: 100% !important; height: 100% !important; max-width: none !important; }
#editor #ed-bigbtn { display: none !important; }
#editor .pvanim { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; gap: 4px; padding: 4px; background: #0f1318e6; border: 1px solid var(--line); border-radius: 24px; }
#editor .pvrot { position: absolute; right: 14px; bottom: 16px; display: flex; gap: 4px; padding: 4px; background: #0f1318e6; border: 1px solid var(--line); border-radius: 24px; }
#editor .pvanim button, #editor .pvrot button { border-radius: 18px !important; min-height: 36px; padding: 6px 10px; }
#editor .pvanim button span, #editor .pvrot button span { margin-left: 4px; }
#editor #ed-hint { position: absolute; left: 16px; top: 12px; max-width: min(520px, 60%); margin: 0; color: var(--dim); font-size: 12.5px; pointer-events: none; }
#editor #ed-info, #editor #ed-stats { display: none; }
#editor #ed-err, #editor #ed-saved { position: absolute; left: 16px; bottom: 76px; max-width: 60%; }
#editor .ed-save { position: absolute; z-index: 6; left: 16px; bottom: 16px; display: flex; margin: 0; }
#editor #ed-savebtn { min-height: 44px; padding: 10px 20px; background: var(--mech-acc); color: #1a1205; border-color: var(--mech-acc); font-weight: 700; border-radius: 22px !important; box-shadow: 0 4px 18px #0008; }

/* «Тест»: палитры нет, только мех и движения */
body.mech-test #editor #ed-pane { display: none; }
body.mech-test #editor .ed-left { left: 0; }
body.mech-test #editor .pvanim { transform: translateX(-50%) scale(1.15); }

/* «Покраска»: полноэкранный вид с кистью — на месте вида меха; цвета меха — в палитре */
body.mech-paint #ed-big { inset: calc(var(--mech-bar) + var(--mode-h)) 0 0 var(--pal-w) !important; z-index: 40 !important; background: #12161c; }
body.mech-paint #ed-big .eb-head .eb-close, body.mech-paint #ed-big .eb-head .eb-modes, body.mech-paint #ed-big .eb-tools .tb-mode { display: none !important; }
body.mech-paint #ed-big .eb-head { padding: 6px 10px; background: #0f1318; border-bottom: 1px solid var(--line); }
body.mech-paint #ed-big .eb-view { background: radial-gradient(ellipse at 50% 38%, #2a3440 0%, #161c23 55%, #0d1014 100%); }
body.mech-paint #ed-big .eb-sidew { width: 340px; box-sizing: border-box; overflow-x: hidden; border-left: 1px solid var(--line); background: var(--panel); }
body.mech-paint #editor .ed-left { display: none !important; }
body.mech-paint #editor #ed-pwrap, body.mech-paint #editor .ed-flatpaint { display: none !important; }
body:not(.mech-paint) #ed-big { display: none !important; }

@media (max-width: 760px) {
  :root { --pal-w: 100vw; --mode-h: 50px; }
  #editor #ed-tabs { justify-content: flex-start; }
  #editor #ed-tabs button .tl { display: none; }
  #editor #ed-tabs button .tico { font-size: 20px; }
  #editor #ed-pane { top: calc(var(--mech-bar) + var(--mode-h) + 46vh); width: 100%; border-right: 0; border-top: 1px solid var(--line); }
  #editor .ed-left { left: 0; bottom: auto; height: 46vh; }
  body.mech-test #editor .ed-left { height: calc(100dvh - var(--mech-bar) - var(--mode-h)) !important; }
  #editor .ed-left { height: 46vh !important; }
  #editor .pvrot { display: none; }
  #editor .ed-save { left: auto; right: 10px; bottom: 10px; }
  #editor #ed-hint { display: none; }
  body.mech-paint #ed-big { inset: calc(var(--mech-bar) + var(--mode-h)) 0 0 0 !important; }
}
#editor #ed-pv { background: transparent !important; }
.mech-modal h2 { font-family: system-ui, -apple-system, "Segoe UI", sans-serif !important; text-shadow: none !important; letter-spacing: 0; }
