:root {
  --bg: #0f1020; --panel: #181a2e; --panel2: #20233b; --line: #2e3252; --text: #eef0ff; --muted: #9096bf;
  --accent: #ff3d8b; --accent2: #25f4ee; --ok: #3ddc84; --err: #ff5470; --warn: #ffc547;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 system-ui, 'Segoe UI', sans-serif; }
.muted { color: var(--muted); }
code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; }
header { height: 56px; display: flex; align-items: center; gap: 14px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { font-weight: 800; font-size: 17px; }
.spacer { flex: 1; }
.status { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); max-width: 420px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status i { width: 10px; height: 10px; border-radius: 50%; background: #555; flex: none; }
.status.connected i { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.status.connecting i { background: var(--warn); }
.status.error i { background: var(--err); }
main { display: flex; height: calc(100% - 56px); }
aside { width: 470px; flex: none; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--panel); }
nav#tabs { display: flex; border-bottom: 1px solid var(--line); }
nav#tabs button { flex: 1; background: none; border: 0; color: var(--muted); padding: 12px 4px; font: inherit; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; }
nav#tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
#side { flex: 1; overflow: auto; padding: 14px; }
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--accent2); }
.btn.primary { background: var(--accent); border-color: var(--accent); }
.btn.small { padding: 3px 7px; font-size: 12px; border-radius: 6px; }
.btn.danger:hover { border-color: var(--err); color: var(--err); }
input, select { background: #0e0f1d; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font: inherit; min-width: 0; }
input[type=color] { padding: 0; width: 34px; height: 30px; border-radius: 6px; cursor: pointer; }
input[type=number] { width: 78px; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.box { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 14px; }
.box.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.box h3 { margin: 0 0 10px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.field > input, .field > select { color: var(--text); }
.cardrow { display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.cardrow:first-of-type { border-top: 0; }
.thumb { width: 64px; height: 64px; border-radius: 10px; border: 1px dashed var(--line); background: #0e0f1d center/contain no-repeat; cursor: pointer; display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.thumb:hover { border-color: var(--accent2); }
.cardrow .lblprev { font-weight: 800; font-size: 15px; }
.cardrow .f { display: grid; grid-template-columns: 1.4fr .7fr; gap: 6px; }
.cardrow .f3 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.tools { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.hint { font-size: 12px; color: var(--muted); margin: 4px 0 10px; }
#previewWrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.pv-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
#preview { flex: 1; position: relative; overflow: hidden; }
#preview .stage { position: absolute; top: 0; left: 0; box-shadow: 0 0 0 2px var(--line), 0 20px 60px rgba(0,0,0,.5); }
#preview.bg-checker .stage { background: repeating-conic-gradient(#2a2c40 0 25%, #1f2133 0 50%) 0 0 / 48px 48px; }
#preview.bg-dark .stage { background: #111; }
#preview.bg-game .stage { background: linear-gradient(180deg, #7fb8e6 0%, #9dc7a0 45%, #6c7a5a 60%, #444 100%); }
#preview.bg-green .stage { background: #00b140; }
#preview [data-drag] { cursor: move; outline: 2px dashed transparent; outline-offset: 6px; border-radius: 8px; }
#preview [data-drag]:hover { outline-color: rgba(37,244,238,.6); }
#preview [data-drag].sel { outline-color: var(--accent); }
#preview .card { cursor: pointer; }
#preview .hidden-ed { opacity: .3; }
.log { font-size: 12.5px; max-height: 260px; overflow: auto; }
.log div { padding: 4px 0; border-bottom: 1px solid var(--line); }
.log time { color: var(--muted); margin-right: 6px; }
.big { font-size: 26px; font-weight: 800; }
dialog#gallery { width: min(1100px, 94vw); height: 86vh; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 0; display: none; flex-direction: column; }
dialog#gallery[open] { display: flex; }
dialog::backdrop { background: rgba(0,0,0,.65); }
.gal-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.gal-head input[type=search] { flex: 1; min-width: 160px; }
.gal-note { margin: 8px 14px 0; font-size: 12.5px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: none; border: 0; color: var(--muted); padding: 6px 10px; font: inherit; cursor: pointer; }
.seg button.on { background: var(--accent); color: #fff; }
#galGrid { flex: 1; overflow: auto; padding: 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; align-content: start; }
#galGrid.drop { outline: 3px dashed var(--accent2); outline-offset: -8px; }
.tile { position: relative; background: #0e0f1d; border: 1px solid var(--line); border-radius: 10px; padding: 6px; cursor: pointer; text-align: center; }
.tile:hover { border-color: var(--accent2); }
.tile.cur { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tile img { width: 88px; height: 88px; object-fit: contain; display: block; margin: 0 auto; }
.tile .nm { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: 15px; }
.tile .nm.has { color: var(--text); }
.tile .ed { position: absolute; top: 4px; right: 4px; background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 6px; font-size: 11px; padding: 1px 5px; cursor: pointer; opacity: 0; }
.tile:hover .ed { opacity: 1; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--accent2); padding: 9px 16px; border-radius: 10px; z-index: 99; }
.swatches { display: inline-flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.sw { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #0e0f1d; outline: 1px solid var(--line); cursor: pointer; padding: 0; }
.sw:hover { outline-color: var(--accent2); }
.cardrow .row { margin-bottom: 6px; }
.tile .val { font-size: 11px; color: var(--warn); font-weight: 700; }
