:root {
  --bg: #15120e;
  --panel: #1f1a14;
  --panel-2: #29221a;
  --line: #3d3326;
  --text: #eee3cf;
  --muted: #a8998a;
  --gold: #e0b056;
  --gold-2: #f3cf7c;
  --accent: #5fa8d3;
  --ok: #7cc47f;
  --bad: #e06a5a;
  --store: #c98df0;
  --npc: #7cc47f;
  --market: #5fa8d3;
  --radius: 8px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
a { color: var(--gold-2); }
.muted { color: var(--muted); }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--gold); }

/* ---------- buttons ---------- */
.btn, .tool {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 10px; cursor: pointer; text-decoration: none; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px;
}
.btn:hover, .tool:hover { border-color: var(--gold); }
.btn:focus-visible, .tool:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.btn.primary { background: linear-gradient(#b8862f, #8a6120); border-color: #d9a54a; color: #fff8e6; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.icon { width: 32px; justify-content: center; padding: 0; font-size: 16px; }
.btn.big { font-size: 16px; padding: 10px 18px; }
.btn:disabled { opacity: .4; cursor: default; }
.tool span { font-size: 12px; }
.tool.active { background: #4a3a20; border-color: var(--gold); color: var(--gold-2); }

/* ---------- app layout ---------- */
body.app { display: grid; grid-template-rows: auto 1fr auto; grid-template-columns: minmax(0, 1fr); height: 100dvh; overflow: hidden; }
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; flex-wrap: wrap;
  background: linear-gradient(#2a2219, #1d1812); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--gold-2); text-decoration: none; font-weight: 700; font-size: 16px; }
.brand small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.group { display: flex; gap: 4px; align-items: center; }
.group.right { margin-left: auto; }
.floor-btn { min-width: 32px; justify-content: center; }
.floor-btn.active { background: #4a3a20; border-color: var(--gold); color: var(--gold-2); }

.layout { display: grid; grid-template-columns: 300px 1fr 280px; min-height: 0; position: relative; }
#btnSide { display: none; }
.palette, .side { background: var(--panel); min-height: 0; }
.palette { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.side { border-left: 1px solid var(--line); overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.pal-head { padding: 10px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
input[type=search], input[type=number], select {
  font: inherit; color: var(--text); background: #120f0b; border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 8px; width: 100%;
}
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font: inherit; font-size: 12px; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; padding: 2px 9px; cursor: pointer; }
.chip.active { background: #4a3a20; border-color: var(--gold); color: var(--gold-2); }
.chips.small .chip { font-size: 11px; }
.pal-grid { flex: 1; overflow: auto; position: relative; min-height: 0; }
.pal-inner { position: absolute; top: 8px; left: 8px; right: 8px; display: grid; gap: 6px; grid-auto-rows: 64px; }
.pal-item {
  position: relative; width: 64px; height: 64px; background: #120f0b; border: 1px solid var(--line); border-radius: 6px;
  cursor: pointer; padding: 0; display: grid; place-items: center;
}
.pal-item canvas { width: 100%; height: 100%; image-rendering: pixelated; }
.pal-item:hover { border-color: var(--gold); }
.pal-item.active { border-color: var(--gold-2); box-shadow: 0 0 0 2px var(--gold) inset; }
.pal-item .dot { position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; border-radius: 50%; }
.pal-item .rot { position: absolute; bottom: 2px; right: 4px; font-size: 10px; color: var(--muted); }
.pal-foot { padding: 6px 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.src-store { background: var(--store); } .src-npc { background: var(--npc); } .src-market { background: var(--market); } .src-other { background: #8b7d6b; }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 99px; color: #120f0b; font-weight: 600; }

.stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #0b0907; }
#view { display: block; width: 100%; height: 100%; touch-action: none; image-rendering: pixelated; }
.hud { position: absolute; left: 10px; bottom: 10px; font-size: 12px; color: var(--muted); background: rgba(0,0,0,.55); padding: 4px 8px; border-radius: 6px; pointer-events: none; }
.hud:empty { display: none; }
.empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 20px; gap: 10px; max-width: 520px; margin: auto; }
.empty h1 { font-size: 30px; color: var(--gold-2); }
.empty[hidden] { display: none; }
.toast { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); background: #2d2418; border: 1px solid var(--gold); padding: 8px 14px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90%; }
.toast.show { opacity: 1; }

.card { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.card label { display: flex; align-items: center; gap: 6px; padding: 2px 0; cursor: pointer; }
.card p { margin: .3em 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.sel-preview { display: flex; gap: 10px; align-items: center; }
.sel-preview canvas { width: 64px; height: 64px; image-rendering: pixelated; background: #120f0b; border-radius: 6px; border: 1px solid var(--line); flex: none; }
.stack-ctl { margin-top: 8px; }
.stack-ctl label { font-size: 13px; }
.stack-ctl input[type=number] { width: 70px; }
.stack-ctl input[type=range] { width: 100%; margin: 4px 0; accent-color: var(--gold); }
.stack-views { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.stack-view { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 3px 0 2px; background: #120f0b;
  border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font-size: 10px; cursor: pointer; }
.stack-view canvas { width: 40px; height: 40px; image-rendering: pixelated; }
.stack-view:hover { border-color: var(--gold); }
.stack-view.active { border-color: var(--gold); color: var(--gold-2); background: #2a2114; }
.card .row.doors { flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.row.doors .btn { font-size: 12px; }
.shop-row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.shop-row:last-child { border-bottom: 0; }
.shop-total { margin-top: 6px; font-weight: 600; color: var(--gold-2); }
.design-row { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.design-row a { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.design-row button { font-size: 12px; padding: 0 6px; min-height: 24px; }

/* ---------- dialogs ---------- */
.dialog { background: var(--panel); color: var(--text); border: 1px solid var(--gold); border-radius: 10px; padding: 0; width: min(760px, 94vw); max-height: 86vh; }
.dialog.small { width: min(420px, 94vw); padding: 16px; }
.dialog::backdrop { background: rgba(0,0,0,.6); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.dialog.small .dlg-head { padding: 0 0 8px; border: 0; }
.dlg-filters { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; padding: 12px 16px; }
.hlist { overflow: auto; max-height: 60vh; padding: 0 16px 16px; }
.hrow { display: grid; grid-template-columns: 1fr auto auto auto; gap: 12px; align-items: center; width: 100%; text-align: left; font: inherit; color: var(--text); background: none; border: 0; border-bottom: 1px solid var(--line); padding: 8px 4px; cursor: pointer; }
.hrow:hover { background: var(--panel-2); }
.hrow .t { color: var(--muted); font-size: 12px; }
.row { display: flex; gap: 10px; margin: 10px 0; }
.row label { flex: 1; font-size: 12px; color: var(--muted); }
.row.end { justify-content: flex-end; }

.legal { font-size: 11px; color: var(--muted); padding: 6px 12px; border-top: 1px solid var(--line); background: #120f0b; text-align: center; }

/* ---------- content pages ---------- */
body.page { max-width: 820px; margin: 0 auto; padding: 24px 16px; }
body.page h1 { color: var(--gold-2); font-size: 28px; }
body.page h2 { margin-top: 1.6em; font-size: 15px; }
body.page .legal { margin-top: 40px; border-radius: 8px; }
body.page li { margin: .3em 0; }

/* ---------- small screens ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 250px 1fr; }
  .side { display: none; }
  .side.open { display: flex; position: absolute; right: 0; top: 0; bottom: 0; width: min(300px, 90vw); z-index: 5; box-shadow: -8px 0 24px rgba(0,0,0,.5); }
  .tool span { display: none; }
  #btnSide { display: inline-flex; }
}
@media (max-width: 720px) {
  .brand small, .brand span { display: none; }
  .topbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 6px; padding: 6px 8px; }
  .topbar > * { flex: none; }
  .group.right { margin-left: 0; }
  #houseLabel { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 38vh; }
  .palette { order: 2; border-right: 0; border-top: 1px solid var(--line); }
  .pal-head { padding: 8px; gap: 6px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .chip { flex: none; }
  .side.open { top: 0; bottom: 38vh; }
  .legal { font-size: 10px; padding: 4px 8px; }
  .group.right .btn { padding: 6px 8px; }
  .dlg-filters { grid-template-columns: 1fr; }
  .hrow { grid-template-columns: 1fr auto; }
  .hrow .hide-sm { display: none; }
}
kbd { font: 12px/1 ui-monospace, monospace; background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 2px 5px; }

/* ---------- icons ---------- */
.ic { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.icon .ic { width: 17px; height: 17px; }
.btn.big .ic { width: 20px; height: 20px; }
.btn.icon-sm { width: 26px; min-height: 24px; padding: 0; justify-content: center; }
.btn.icon-sm .ic { width: 14px; height: 14px; }
.pal-item .rot .ic { width: 11px; height: 11px; }
.hud .warn { color: #f0a090; display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; }
.hud .warn .ic { width: 13px; height: 13px; }
.walk-btn { background: linear-gradient(#2f5e46, #234635); border-color: #4f9a74; color: #e8fff2; font-weight: 600; }
.walk-btn:hover { border-color: #8fe0b4; }

/* ---------- walk mode ---------- */
.walkbar, .walkhelp, .chatbox { display: none; }
body.walking .palette, body.walking .side, body.walking .edit-only, body.walking .hud, body.walking #btnSave,
body.walking #btnShare, body.walking #btnPng, body.walking #btnSide { display: none !important; }
body.walking .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
body.walking .walk-btn span::after { content: ""; }
body.walking .stage { background: #000; }
body.walking #view { cursor: pointer; outline: none; }
body.walking .walkbar { display: flex; position: absolute; top: 10px; left: 50%; transform: translateX(-50%); gap: 6px; flex-wrap: wrap; justify-content: center; z-index: 2; }
body.walking .walkbar .btn { background: rgba(31, 26, 20, .88); backdrop-filter: blur(3px); }
body.walking .walkhelp { display: block; position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); font-size: 12px; color: var(--muted); background: rgba(0,0,0,.6); padding: 4px 10px; border-radius: 6px; pointer-events: none; white-space: nowrap; max-width: 96%; overflow: hidden; text-overflow: ellipsis; }
body.walking .chatbox.open { display: block; position: absolute; bottom: 40px; left: 50%; transform: translateX(-50%); width: min(520px, 92%); z-index: 3; }
.chatbox input { width: 100%; font: inherit; color: #ffff66; background: rgba(0,0,0,.8); border: 1px solid var(--gold); border-radius: 6px; padding: 8px 10px; }

/* ---------- dialogs: outfit + HUD ---------- */
.dialog.wide { width: min(980px, 96vw); max-height: 92vh; display: none; flex-direction: column; }
.dialog.wide[open] { display: flex; }
.outfit-body { display: grid; grid-template-columns: 220px 1fr; gap: 16px; padding: 12px 16px; min-height: 0; overflow: auto; }
.of-preview { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.of-preview canvas { width: 192px; height: 192px; align-self: center; image-rendering: pixelated; background: radial-gradient(#3a3025, #16120d); border: 1px solid var(--line); border-radius: 8px; }
.row.center { justify-content: center; margin: 0; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; align-self: flex-start; }
.seg-btn { font: inherit; font-size: 13px; color: var(--text); background: var(--panel-2); border: 0; border-right: 1px solid var(--line); padding: 5px 12px; cursor: pointer; }
.seg-btn:last-child { border-right: 0; }
.seg-btn.active { background: #4a3a20; color: var(--gold-2); }
.of-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tab { font: inherit; color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent; padding: 6px 10px; cursor: pointer; }
.tab.active { color: var(--gold-2); border-bottom-color: var(--gold); }
.tab-pane { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.tab-pane[hidden] { display: none; }
.of-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; max-height: 46vh; overflow: auto; padding-right: 4px; }
.of-item { font: inherit; font-size: 11px; color: var(--text); background: #120f0b; border: 1px solid var(--line); border-radius: 6px; padding: 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.of-item canvas { width: 64px; height: 64px; image-rendering: pixelated; }
.of-item span { width: 100%; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.of-item:hover { border-color: var(--gold); }
.of-item.active { border-color: var(--gold-2); box-shadow: 0 0 0 2px var(--gold) inset; }
.palette133 { display: grid; grid-template-columns: repeat(19, 1fr); gap: 3px; max-width: 560px; }
.palette133 button { aspect-ratio: 1; border: 1px solid #000; border-radius: 3px; cursor: pointer; padding: 0; min-width: 14px; }
.palette133 button.active { outline: 2px solid #fff; outline-offset: 1px; }
textarea { font: 12px/1.4 ui-monospace, monospace; color: var(--text); background: #120f0b; border: 1px solid var(--line); border-radius: 6px; padding: 8px; width: 100%; resize: vertical; }
.dlg-foot { padding: 10px 16px; border-top: 1px solid var(--line); margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 10px 0; padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; }
legend { color: var(--gold); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding: 0 4px; }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); }
.field input:not([type=range]), .field select { font: inherit; color: var(--text); background: #120f0b; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.field output { color: var(--text); font-size: 12px; }
input[type=range] { accent-color: var(--gold); }
@media (max-width: 720px) {
  .outfit-body { grid-template-columns: 1fr; }
  body.walking .walkbar .btn span, body.walking .walkhelp { display: none; }
}
.back { display: inline-flex; align-items: center; gap: 6px; }
.dialog.small { max-height: 90vh; overflow: auto; }

/* ---------- Creator: custom items development mode ---------- */
.creator-btn { background: linear-gradient(#5a3f78, #3f2b57); border-color: #9a78c9; color: #f5ecff; font-weight: 600; }
.creator-btn:hover { border-color: #d3b8f5; }
.src-custom { background: #e8a0c8; }
.pal-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.linkbtn { font: inherit; font-size: 12px; color: var(--gold-2); background: none; border: 0; padding: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.linkbtn:hover { text-decoration: underline; }
.linkbtn .ic { width: 13px; height: 13px; }
.pal-cta { grid-column: 1 / -1; padding: 16px 6px; text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.btn.small { font-size: 12px; padding: 3px 8px; min-height: 26px; gap: 4px; }
.btn.small .ic { width: 14px; height: 14px; }
.btn.icon-sm.active { background: #4a3a20; border-color: var(--gold); color: var(--gold-2); }
.sel-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

body.creating { overflow: hidden; }
.creator { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: grid; grid-template-rows: auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); }
.creator[hidden] { display: none; }
.cr-top { display: flex; align-items: center; gap: 10px; padding: 8px 12px; flex-wrap: wrap; background: linear-gradient(#2e2338, #1d1812); border-bottom: 1px solid var(--line); }
.cr-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: #e6d2ff; }
.cr-brand .ic { width: 20px; height: 20px; color: #c9a4ff; }
.cr-brand small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.cr-edit-only { display: none !important; }
.creator.editing .cr-edit-only { display: flex !important; }
.creator.editing .cr-brand small { display: none; }
.cr-name { font: inherit; font-weight: 600; color: var(--text); background: #120f0b; border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; width: 200px; }
.cr-kind { background: #c9a4ff; }
.look-only { display: none !important; }
.creator.is-look .look-only { display: flex !important; }

/* home */
.cr-home { overflow: auto; padding: 20px max(16px, calc(50% - 560px)) 40px; }
.cr-home[hidden], .cr-editor[hidden] { display: none; }
.cr-hero h1 { font-size: 30px; color: var(--gold-2); margin: 0 0 6px; }
.cr-hero p { color: var(--muted); max-width: 720px; margin: 0 0 18px; }
.cr-home > h2 { margin: 22px 0 10px; }
.cr-starts { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.cr-start { font: inherit; text-align: left; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: start; }
.cr-start:hover { border-color: #b48ee8; background: #2c2330; }
.cr-start-ic { grid-row: span 2; width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; background: #3a2d4a; color: #d9bfff; }
.cr-start-ic .ic { width: 20px; height: 20px; }
.cr-start > span:last-child { font-size: 12px; color: var(--muted); }
.cr-draft { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: #2d2418; border: 1px solid var(--gold); border-radius: 8px; padding: 8px 12px; margin-bottom: 8px; }
.cr-draft[hidden] { display: none; }
.cr-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.cr-empty { grid-column: 1 / -1; }
.cr-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px; display: grid; grid-template-columns: 96px 1fr; gap: 4px 10px; }
.cr-thumb { grid-row: span 2; width: 96px; height: 96px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: radial-gradient(#3a3025, #16120d); cursor: pointer; }
.cr-thumb:hover { border-color: var(--gold); }
.cr-thumb canvas { width: 100%; height: 100%; image-rendering: pixelated; }
.cr-card-body { min-width: 0; display: flex; flex-direction: column; font-size: 13px; }
.cr-card-body b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-card-body .muted { font-size: 11px; }
.cr-card-acts { display: flex; gap: 3px; flex-wrap: wrap; align-self: end; }
.cr-tips { margin-top: 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.cr-tips summary { cursor: pointer; color: var(--gold-2); font-weight: 600; }
.cr-tips li { margin: 6px 0; color: var(--muted); }
.cr-tips b { color: var(--text); }

/* editor */
.cr-editor { display: grid; grid-template-columns: 52px minmax(0, 1fr) 300px; min-height: 0; }
.cr-tools { display: flex; flex-direction: column; gap: 4px; padding: 8px 6px; background: var(--panel); border-right: 1px solid var(--line); overflow: auto; align-items: center; }
.cr-tools .tool { width: 38px; min-height: 36px; padding: 0; justify-content: center; flex: none; }
.cr-tools .tool .ic { width: 18px; height: 18px; }
.cr-tools .zone-tool.active { background: #3a2d4a; border-color: #c9a4ff; color: #e6d2ff; }
.cr-sep { width: 28px; height: 1px; background: var(--line); margin: 4px 0; flex: none; }
.cr-opt { display: flex; flex-direction: column; gap: 2px; }
.cr-mini { font: inherit; font-size: 11px; width: 38px; height: 22px; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; cursor: pointer; padding: 0; }
.cr-mini.active { background: #4a3a20; border-color: var(--gold); color: var(--gold-2); }
.cr-center { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-width: 0; min-height: 0; }
.cr-stage { position: relative; min-height: 0; overflow: hidden; background: #0b0907; }
#crCanvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; outline: none; }
#crCanvas[data-tool="pan"] { cursor: grab; }
#crCanvas[data-tool="picker"] { cursor: copy; }
#crCanvas[data-tool="move"], #crCanvas[data-tool="select"] { cursor: move; }
.cr-hud { position: absolute; left: 10px; bottom: 10px; font-size: 12px; color: var(--muted); background: rgba(0,0,0,.6); padding: 3px 8px; border-radius: 6px; pointer-events: none; display: flex; align-items: center; gap: 5px; }
.cr-hud:empty { display: none; }
.cr-hud-sw { display: inline-block; width: 11px; height: 11px; border: 1px solid #000; border-radius: 2px; }
.cr-stagebar { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 12px; pointer-events: none; }
.cr-stagebar > * { pointer-events: auto; background: rgba(20,16,12,.85); border-radius: 6px; padding: 3px 8px; }
.cr-stagebar select { width: auto; padding: 3px 6px; font-size: 12px; border: 1px solid var(--line); }
.cr-strip { background: var(--panel); border-top: 1px solid var(--line); padding: 6px 10px; display: flex; flex-direction: column; gap: 6px; }
.cr-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cr-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--gold); min-width: 70px; }
.cr-chip { font: inherit; font-size: 12px; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 3px 10px; cursor: pointer; min-width: 30px; }
.cr-chip.active { background: #4a3a20; border-color: var(--gold); color: var(--gold-2); }
.cr-thumbs { display: flex; gap: 4px; overflow-x: auto; max-width: 100%; min-width: 0; padding-bottom: 2px; }
.cr-strip, .cr-row { min-width: 0; }
.cr-frame { font: inherit; font-size: 10px; color: var(--muted); background: #120f0b; border: 1px solid var(--line); border-radius: 6px; padding: 2px; cursor: pointer; display: flex; flex-direction: column; align-items: center; flex: none; }
.cr-frame canvas { width: 44px; height: 44px; image-rendering: pixelated; }
.cr-frame.active { border-color: var(--gold-2); color: var(--gold-2); box-shadow: 0 0 0 1px var(--gold) inset; }
.cr-frame-acts { display: flex; gap: 3px; align-items: center; flex-wrap: wrap; }
.cr-dur { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; margin-left: 4px; }
.cr-dur input { width: 64px; padding: 3px 6px; font-size: 12px; }
.cr-hint { font-size: 12px; }
.cr-panel { background: var(--panel); border-left: 1px solid var(--line); overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.cr-panel .card { padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.cr-panel .card h2 { margin: 0; }
.cr-panel .row { margin: 2px 0; gap: 6px; flex-wrap: wrap; }
.cr-pv canvas { width: 256px; height: 256px; max-width: 100%; align-self: center; image-rendering: pixelated; background: #0b0907; border: 1px solid var(--line); border-radius: 8px; }
.cr-pv-opts .check { font-size: 12px; flex: none; }
.cr-pv-opts [hidden] { display: none !important; }
.cr-pv-mount { flex: 1 1 100%; flex-direction: row !important; align-items: center !important; gap: 8px; }
.cr-pv-mount select { flex: 1; width: auto; }
.cr-pose { margin-right: 6px; }
.cr-pose .seg-btn { font-size: 12px; padding: 3px 10px; display: inline-flex; align-items: center; gap: 4px; }
.cr-pose .ic { width: 12px; height: 12px; }
.cr-color-row { display: flex; gap: 6px; align-items: center; }
.cr-cur { width: 34px; height: 34px; border-radius: 6px; border: 1px solid #000; box-shadow: 0 0 0 1px var(--line); flex: none;
  background-image: linear-gradient(45deg, #666 25%, transparent 25%, transparent 75%, #666 75%), linear-gradient(45deg, #666 25%, #999 25%, #999 75%, #666 75%); background-size: 8px 8px; background-position: 0 0, 4px 4px; background-blend-mode: normal; }
#crColor { width: 40px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }
.cr-hex { font: 13px ui-monospace, monospace; color: var(--text); background: #120f0b; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; width: 100%; min-width: 0; }
.field-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(20px, 1fr)); gap: 3px; }
.swatches:empty { display: none; }
.swatches button { aspect-ratio: 1; border: 1px solid #000; border-radius: 3px; cursor: pointer; padding: 0; min-width: 0; }
.swatches button:hover { outline: 1px solid #fff; }
.swatches button.active { outline: 2px solid var(--gold-2); outline-offset: 1px; }
.swatches.s133 { grid-template-columns: repeat(19, 1fr); gap: 2px; }
.cr-panel details summary { cursor: pointer; }
.cr-zonebox { border-top: 1px dashed var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.cr-zonebox[hidden] { display: none; }
.cr-zones, .cr-pcols { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.cr-zone, .cr-pcol { font: inherit; font-size: 12px; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.cr-zone span, .cr-pcol span { width: 14px; height: 14px; border-radius: 3px; border: 1px solid #000; flex: none; }
.cr-zone.active { border-color: #c9a4ff; background: #3a2d4a; }
.cr-pop { background: #120f0b; border: 1px solid var(--line); border-radius: 6px; padding: 4px; }
.cr-pop[hidden] { display: none; }
.cr-layers { display: flex; flex-direction: column; gap: 3px; }
.cr-layer { display: flex; align-items: center; gap: 6px; padding: 3px 4px; border: 1px solid var(--line); border-radius: 6px; background: #120f0b; cursor: pointer; }
.cr-layer.active { border-color: var(--gold); background: #2a2114; }
.cr-layer.zones.active { border-color: #c9a4ff; background: #2c2330; }
.cr-layer-name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; user-select: none; }
.cr-layer input[type=range] { width: 64px; }
.cr-scope { align-self: stretch; }
.cr-scope .seg-btn { flex: 1; font-size: 12px; padding: 4px 6px; }
.cr-ops { display: flex; flex-wrap: wrap; gap: 4px; }
.cr-nudge { display: inline-flex; gap: 2px; }
.cr-check ul { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.cr-check li { display: flex; gap: 6px; align-items: flex-start; }
.cr-check li .ic { width: 14px; height: 14px; margin-top: 2px; }
.cr-check li.ok .ic { color: var(--ok); }
.cr-check li.warn .ic { color: #f0a090; }
.cr-panel .field, .cr-dialog .field { align-items: stretch; cursor: default; }
.cr-panel .field output { align-self: flex-start; }
#crProps { display: flex; flex-direction: column; gap: 6px; }
#crProps .check { font-size: 13px; }
.cr-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cr-light { display: flex; flex-direction: column; gap: 6px; }
.cr-light[hidden] { display: none; }
.cr-lightcols { display: grid; grid-template-columns: repeat(18, 1fr); gap: 1px; }
.cr-lightcols button { aspect-ratio: 1; border: 0; padding: 0; cursor: pointer; min-width: 0; }
.cr-lightcols button.active { outline: 2px solid #fff; z-index: 1; }
.cr-size-row { align-items: center; }
.cr-size-row select { width: auto; }

/* creator dialogs */
.cr-dialog .field { margin: 8px 0; }
.cr-sizes { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; margin: 6px 0 10px; }
.cr-size { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.cr-size small { font-size: 10px; color: var(--muted); text-align: center; }
.cr-size.active { border-color: var(--gold); background: #2a2114; }
.cr-size-box { width: calc(var(--w) * 12px); height: calc(var(--h) * 12px); background-image: linear-gradient(var(--gold) 1px, transparent 1px), linear-gradient(90deg, var(--gold) 1px, transparent 1px); background-size: 12px 12px; border: 1px solid var(--gold); opacity: .7; }
.cr-pick-body { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.cr-pick-opts { margin: 0; flex-wrap: wrap; font-size: 13px; }
.cr-pick-grid { max-height: 60vh; }
.cr-more { grid-column: 1 / -1; }
.cr-imp-preview { display: flex; gap: 12px; align-items: center; margin-top: 10px; }
.cr-imp-preview canvas { width: 96px; height: 96px; image-rendering: pixelated; background: radial-gradient(#3a3025, #16120d); border: 1px solid var(--line); border-radius: 8px; }
.cr-share-acts { flex-wrap: wrap; }
.cr-share-size { font-size: 11px; margin: 2px 0 0; }

@media (max-width: 1100px) {
  .cr-editor { grid-template-columns: 52px minmax(0, 1fr) 260px; }
  .cr-top .btn span { display: none; }
  .cr-name { width: 150px; }
}
@media (max-width: 820px) {
  .creator { overflow: auto; }
  .cr-top { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 6px; padding: 6px 8px; }
  .cr-top > * { flex: none; }
  .cr-brand span { display: none; }
  .cr-editor { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 62vh auto; overflow: auto; }
  .cr-center { grid-template-rows: minmax(0, 1fr) auto; min-height: 0; }
  .cr-tools { flex-direction: row; overflow-x: auto; overflow-y: hidden; min-height: 50px; flex-wrap: nowrap; border-right: 0; border-bottom: 1px solid var(--line); padding: 6px; }
  .cr-opt { flex-direction: row; }
  .cr-mini { width: 26px; height: 36px; }
  .cr-sep { width: 1px; height: 28px; margin: 0 4px; }
  .cr-panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .cr-lbl { min-width: 0; }
  .hide-sm { display: none; }
}
