:root {
  --bg: #0d0f14; --bg2: #12151c; --panel: #171b24; --panel2: #1d2230; --line: #262c3b; --line2: #323a4d;
  --text: #e9edf5; --muted: #8b93a7; --accent: #3ddc84; --accent2: #2bb56b; --violet: #8b7bff; --warn: #ffb547; --err: #ff5c6c;
  --radius: 14px; --shadow: 0 10px 40px rgba(0, 0, 0, .45);
  --pixel: 'Pixelify Sans', 'Manrope', system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 Manrope, system-ui, -apple-system, Segoe UI, sans-serif; }
body { min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.15; }
h1 { font-weight: 800; font-size: clamp(32px, 4.6vw, 58px); letter-spacing: -1px; }
h2 { font-weight: 800; font-size: clamp(22px, 2.4vw, 30px); letter-spacing: -.4px; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
code { background: var(--panel2); padding: 1px 6px; border-radius: 6px; font-size: 13px; }
canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
[hidden] { display: none !important; }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line2); background: var(--panel2); color: var(--text);
  padding: 9px 16px; border-radius: 10px; font: 600 14px Manrope, sans-serif; cursor: pointer; transition: .15s; text-decoration: none !important; white-space: nowrap; }
.btn:hover { border-color: #46506a; background: #242a3a; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #062312; }
.btn.primary:hover { background: #57ef9a; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.big { padding: 13px 22px; font-size: 16px; border-radius: 12px; }
.btn.wide { width: 100%; }
.btn.on { border-color: var(--accent); color: var(--accent); }
input, select, textarea { background: var(--bg2); border: 1px solid var(--line2); color: var(--text); border-radius: 9px; padding: 8px 10px; font: 14px Manrope, sans-serif; width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
input[type=range] { padding: 0; accent-color: var(--accent); background: none; border: 0; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.wrap { flex-wrap: wrap; }
.chip { border: 1px solid var(--line2); background: var(--panel); color: var(--text); border-radius: 999px; padding: 6px 13px; font: 600 13px Manrope; cursor: pointer; }
.chip:hover { border-color: #46506a; }
.chip.on { background: var(--accent); color: #062312; border-color: var(--accent); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- header / footer ---------- */
header.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 22px; padding: 10px 22px; background: rgba(13, 15, 20, .86); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 9px; color: var(--text); font: 700 22px var(--pixel); text-decoration: none !important; }
.logo b { color: var(--accent); }
.logo-mark { display: inline-flex; }
header nav { display: flex; gap: 4px; }
header nav a { color: var(--muted); padding: 7px 12px; border-radius: 9px; font-weight: 600; text-decoration: none !important; }
header nav a:hover { color: var(--text); background: var(--panel); }
header nav a.active { color: var(--text); background: var(--panel2); }
.top-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.top-right select { width: auto; padding: 6px 8px; font-size: 13px; }
footer.foot { border-top: 1px solid var(--line); padding: 26px 22px 34px; color: var(--muted); font-size: 13px; display: grid; gap: 8px; text-align: center; }
footer .disclaimer { font-size: 11.5px; letter-spacing: .2px; opacity: .8; }
body[data-page=editor] footer.foot { display: none; }

/* ---------- boot ---------- */
.boot { min-height: 70vh; display: grid; place-items: center; padding: 20px; }
.boot-card { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 34px; width: min(460px, 100%); text-align: center; box-shadow: var(--shadow); }
.boot-card .logo-mark svg { width: 56px; height: 56px; }
.progress { position: relative; height: 34px; background: var(--bg2); border-radius: 10px; overflow: hidden; border: 1px solid var(--line2); margin-top: 16px; }
.progress .bar { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, var(--accent2), var(--accent)); transition: width .2s; }
.progress span { position: relative; display: block; line-height: 32px; font-size: 13px; font-weight: 700; text-shadow: 0 1px 2px #000; }

/* ---------- home ---------- */
.hero { display: grid; grid-template-columns: 1.05fr 1fr; gap: 40px; align-items: center; padding: 60px max(22px, 6vw) 40px; position: relative; overflow: hidden; }
.hero::before { content: ''; position: absolute; inset: -40% -10% auto auto; width: 70vw; height: 70vw; background: radial-gradient(circle, rgba(61, 220, 132, .13), transparent 60%); pointer-events: none; }
.badge { display: inline-block; padding: 6px 12px; border-radius: 999px; background: rgba(61, 220, 132, .1); color: var(--accent); border: 1px solid rgba(61, 220, 132, .3); font-weight: 700; font-size: 13px; margin-bottom: 18px; }
.lead { font-size: 18px; color: #c3c9d8; max-width: 560px; }
.ticks { list-style: none; padding: 0; margin: 22px 0 0; display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
.ticks li::before { content: '✔ '; color: var(--accent); }
.hero-art { position: relative; }
.live { position: relative; display: grid; place-items: center; background:
  repeating-conic-gradient(#1a1e28 0% 25%, #151821 0% 50%) 0 0 / 22px 22px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.live canvas { position: absolute; inset: 0; margin: auto; max-width: calc(100% - 12px); max-height: calc(100% - 12px); }
.live.hero { aspect-ratio: 4 / 3; box-shadow: var(--shadow); }
.live.thumb { aspect-ratio: 16 / 10; border-radius: 12px 12px 0 0; border: 0; }
.live-loading { position: absolute; inset: 0; display: grid; place-items: center; }
.live-loading::after { content: ''; width: 26px; height: 26px; border: 3px solid var(--line2); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
.live.ready .live-loading { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.section { padding: 34px max(22px, 6vw); }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.section-head h2 { margin: 0; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 18px; }
.card { position: relative; display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; color: var(--text); text-decoration: none !important; transition: .18s; overflow: hidden; }
.card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 10px 30px rgba(61, 220, 132, .12); }
.card-meta { padding: 11px 14px 13px; display: grid; gap: 2px; }
.card-meta span { color: var(--muted); font-size: 13px; }
.card-cta { position: absolute; top: 10px; right: 10px; background: var(--accent); color: #062312; font-weight: 800; font-size: 12px; padding: 5px 10px; border-radius: 8px; opacity: 0; transition: .15s; }
.card:hover .card-cta { opacity: 1; }
.steps-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.step { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.step p { color: var(--muted); margin: 0; }
.step-n { width: 38px; height: 38px; border-radius: 10px; background: rgba(139, 123, 255, .15); color: var(--violet); display: grid; place-items: center; font: 700 20px var(--pixel); margin-bottom: 12px; }
.fmt-table { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.fmt-row { display: grid; grid-template-columns: 1.2fr 1fr 1.6fr; gap: 16px; background: var(--panel); padding: 14px 18px; align-items: center; }
.faq-item { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 13px 18px; margin-bottom: 10px; }
.faq-item summary { cursor: pointer; font-weight: 700; }
.faq-item p { color: #c3c9d8; margin: 10px 0 0; }

/* ---------- editor ---------- */
.editor { display: grid; grid-template-columns: 230px 1fr 360px; height: calc(100vh - 57px); }
.tpl-list { border-right: 1px solid var(--line); overflow-y: auto; padding: 12px 10px; background: var(--bg2); }
.list-title { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; padding: 4px 8px 10px; }
.tpl { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--text); font-weight: 600; font-size: 14px; text-decoration: none !important; }
.tpl:hover { background: var(--panel); }
.tpl.active { background: var(--panel2); box-shadow: inset 3px 0 0 var(--accent); }
.center { display: flex; flex-direction: column; min-width: 0; padding: 16px 20px; gap: 12px; }
.stage-head { position: relative; padding-right: 40px; }
.stage-head h2 { margin: 0 0 2px; font-size: 24px; }
.stage-head p { margin: 0; font-size: 14px; }
.help { position: absolute; right: 0; top: 0; width: 32px; height: 32px; border-radius: 50%; padding: 0; font-size: 16px; }
.stage { flex: 1; min-height: 240px; display: grid; place-items: center; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.preview-canvas { box-shadow: 0 0 0 1px var(--line2); }
.timeline { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.play { width: 44px; height: 38px; font-size: 14px; background: var(--accent); color: #062312; border-color: var(--accent); }
.play.paused { background: var(--panel2); color: var(--text); border-color: var(--line2); }
.scrub-wrap { position: relative; flex: 1; padding-bottom: 16px; }
.scrub { width: 100%; }
.markers { position: absolute; left: 0; right: 0; bottom: 0; height: 16px; }
.marker { position: absolute; transform: translateX(-50%); background: none; border: 0; color: var(--muted); font: 600 10.5px Manrope; cursor: pointer; white-space: nowrap; padding: 0; }
.marker::before { content: ''; display: block; width: 2px; height: 5px; background: var(--violet); margin: 0 auto 1px; }
.marker:hover { color: var(--text); }
.time { font: 600 13px ui-monospace, Consolas, monospace; color: var(--muted); min-width: 110px; text-align: center; }
.side { border-left: 1px solid var(--line); background: var(--bg2); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab { flex: 1; background: none; border: 0; color: var(--muted); padding: 13px; font: 700 14px Manrope; cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.params, .export { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; }
.side-foot { padding: 12px 16px; border-top: 1px solid var(--line); }
.field { display: grid; gap: 6px; }
.field-label { font-size: 12.5px; font-weight: 700; color: #b9c0d0; }
.field.two { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.field.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: 14px; }
.field.toggle input { display: none; }
.switch { width: 36px; height: 20px; border-radius: 99px; background: var(--line2); position: relative; flex: none; transition: .15s; }
.switch::after { content: ''; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: .15s; }
.field.toggle input:checked + .switch { background: var(--accent); }
.field.toggle input:checked + .switch::after { left: 19px; }
.range-row { display: grid; grid-template-columns: 1fr 74px; gap: 8px; align-items: center; }
.num { padding: 5px 8px; }
.hint { color: var(--muted); font-size: 12px; margin: 0; }
.reset { align-self: flex-start; }
.item-btn { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line2); color: var(--text); border-radius: 10px; padding: 6px 10px; cursor: pointer; font: 600 14px Manrope; text-align: left; }
.item-btn:hover { border-color: var(--accent); }
.empty-slot { width: 32px; height: 32px; border-radius: 6px; background: #8b8b8b; box-shadow: inset 2px 2px #373737, inset -2px -2px #fff; }
.craft-edit { display: flex; align-items: center; gap: 12px; }
.craft-grid { display: grid; grid-template-columns: repeat(3, 44px); gap: 3px; }
.slot { position: relative; width: 44px; height: 44px; background: #8b8b8b; border: 0; border-radius: 3px; box-shadow: inset 2px 2px #373737, inset -2px -2px #fff; display: grid; place-items: center; cursor: pointer; padding: 0; }
.slot.big { width: 56px; height: 56px; }
.slot:hover { background: #a8a8a8; }
.slot .cnt { position: absolute; right: 3px; bottom: 1px; color: #fff; font: 700 12px var(--pixel); text-shadow: 1px 1px #3f3f3f; }
.craft-arrow { font-size: 22px; color: var(--muted); }
.hotbar-edit { display: grid; grid-template-columns: repeat(9, 1fr); gap: 3px; }
.hotbar-edit .slot { width: 100%; height: 36px; }
.skins-def { margin-top: 6px; }
.skin-ctl .row input { flex: 1; width: auto; }
.formats { display: grid; gap: 6px; }
.format { display: flex; gap: 10px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line2); border-radius: 10px; padding: 9px 11px; cursor: pointer; }
.format:has(input:checked) { border-color: var(--accent); background: rgba(61, 220, 132, .07); }
.format.disabled { opacity: .5; cursor: not-allowed; }
.format span { display: grid; }
.format small { color: var(--muted); font-size: 12px; }
.swatches { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.swatch { width: 32px; height: 32px; border-radius: 8px; border: 2px solid var(--line2); cursor: pointer; }
.swatch.transparent { background: repeating-conic-gradient(#888 0% 25%, #ccc 0% 50%) 0 0 / 12px 12px !important; }
.swatch.on { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.swatch-color { width: 40px; height: 32px; padding: 2px; }
.anchors { display: grid; grid-template-columns: repeat(3, 34px); gap: 4px; }
.anchor { height: 24px; border-radius: 5px; border: 1px solid var(--line2); background: var(--panel); cursor: pointer; }
.anchor.on { background: var(--accent); border-color: var(--accent); }
.out-info { font: 600 13px ui-monospace, Consolas, monospace; color: var(--muted); text-align: center; }

/* ---------- pages ---------- */
.page-head { margin-bottom: 20px; }
.pick-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.pick-bar .search { flex: 1; min-width: 200px; }
.skin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-top: 12px; }
.skin-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.skin-view { height: 200px; display: grid; place-items: center; background: repeating-conic-gradient(#1a1e28 0% 25%, #151821 0% 50%) 0 0 / 18px 18px; }
.skin-meta { padding: 10px 12px; display: grid; gap: 8px; }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; margin-top: 14px; }
.asset { display: grid; justify-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 6px 8px; color: var(--text); cursor: pointer; min-height: 104px; }
.asset:hover { border-color: var(--accent); }
.asset span { font-size: 11.5px; color: var(--muted); text-align: center; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sprite-box { height: 48px; display: grid; place-items: center; }
.sprite-box canvas { max-height: 48px; max-width: 96px; min-width: 24px; }
.asset-modal { display: grid; grid-template-columns: 220px 1fr; gap: 22px; align-items: center; }
.asset-big { display: grid; place-items: center; min-height: 220px; background: repeating-conic-gradient(#1a1e28 0% 25%, #151821 0% 50%) 0 0 / 18px 18px; border-radius: 12px; }
.asset-big.pixel canvas { max-width: 200px; max-height: 200px; }

/* ---------- modal, picker, toasts, tour ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(5, 6, 10, .7); z-index: 50; display: grid; place-items: center; padding: 18px; }
.modal { position: relative; background: var(--panel); border: 1px solid var(--line2); border-radius: 18px; padding: 22px; width: min(560px, 100%); max-height: 90vh; overflow: auto; box-shadow: var(--shadow); }
.modal.wide { width: min(880px, 100%); }
.modal-x { position: absolute; top: 10px; right: 12px; background: none; border: 0; color: var(--muted); font-size: 26px; cursor: pointer; line-height: 1; }
.picker { display: flex; flex-direction: column; height: min(70vh, 640px); }
.pick-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; align-content: start; padding-right: 4px; }
.pick { display: grid; justify-items: center; gap: 4px; background: var(--bg2); border: 1px solid var(--line); border-radius: 9px; padding: 9px 4px 6px; color: var(--text); cursor: pointer; min-height: 82px; }
.pick:hover { border-color: var(--accent); background: var(--panel2); }
.pick span { font-size: 11px; color: #c3c9d8; text-align: center; line-height: 1.2; }
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 80; display: grid; gap: 8px; }
.toast { background: var(--panel2); border: 1px solid var(--line2); border-left: 4px solid var(--violet); padding: 11px 15px; border-radius: 10px; box-shadow: var(--shadow); max-width: 380px; font-size: 14px; animation: tin .25s; }
.toast.ok { border-left-color: var(--accent); } .toast.error { border-left-color: var(--err); }
.toast.out { opacity: 0; transform: translateY(8px); transition: .35s; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }
.tour-shade { position: fixed; inset: 0; z-index: 60; }
.tour-hole { position: fixed; z-index: 61; border-radius: 14px; box-shadow: 0 0 0 9999px rgba(5, 6, 10, .72); border: 2px solid var(--accent); pointer-events: none; transition: .25s; }
.tour-card { position: fixed; z-index: 62; background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); transition: .25s; }
.tour-card h4 { font-size: 18px; margin: 4px 0 6px; }
.tour-card p { color: #c3c9d8; margin: 0 0 12px; font-size: 14px; }
.tour-step { color: var(--accent); font-weight: 800; font-size: 12px; }

/* ---------- mobile ---------- */
@media (max-width: 1100px) {
  .editor { grid-template-columns: 1fr; height: auto; }
  .tpl-list { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .list-title { display: none; }
  .tpl { flex: none; }
  .stage { min-height: 46vh; }
  .side { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 860px) {
  header.top { flex-wrap: wrap; gap: 8px; padding: 8px 16px; }
  header nav { order: 3; width: 100%; overflow-x: auto; }
  .top-right .btn { display: none; }
  .hero { grid-template-columns: 1fr; padding: 34px 16px 20px; gap: 24px; }
  .steps-row { grid-template-columns: 1fr; }
  .fmt-row { grid-template-columns: 1fr; gap: 4px; }
  .section { padding: 26px 16px; }
  .asset-modal { grid-template-columns: 1fr; }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}
