:root {
  --bg: #f4f4f2; --panel: #fff; --ink: #1d1d1f; --mute: #6b6b70; --line: #deded9;
  --accent: #2b59c3;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); }
header { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 10px; }
.controls { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; }
.controls label { display: flex; align-items: center; gap: 6px; color: var(--mute); }
.controls output { min-width: 2.5em; color: var(--ink); font-variant-numeric: tabular-nums; }
main { display: grid; grid-template-columns: 300px 1fr; gap: 16px; padding: 16px; }
@media (max-width: 760px) { main { grid-template-columns: 1fr; padding: 12px; } }
aside, section { min-width: 0; }
.drop { display: flex; align-items: center; justify-content: center; border: 2px dashed var(--line);
  border-radius: 10px; padding: 14px; cursor: pointer; color: var(--mute); background: var(--panel); margin-bottom: 12px; text-align: center; }
.drop.big { padding: 26px; }
.drop:hover, .drop.over { border-color: var(--accent); color: var(--accent); }

.ref { display: grid; grid-template-columns: 84px 1fr; gap: 10px; background: var(--panel); border-radius: 10px;
  padding: 8px; margin-bottom: 8px; border-left: 6px solid var(--c); }
.ref .thumb { position: relative; width: 84px; height: 84px; background: #eee; border-radius: 6px; overflow: hidden; cursor: pointer; }
.ref .thumb img { width: 100%; height: 100%; object-fit: contain; }
.ref .thumb svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.ref .info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ref .row { display: flex; gap: 6px; align-items: center; }
.ref input[type=text] { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; font: inherit; }
.ref input[type=color] { width: 32px; height: 28px; border: none; padding: 0; background: none; cursor: pointer; }
.ref .count { color: var(--mute); font-size: 12px; }
.ref .count b { color: var(--ink); }
button { font: inherit; border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 4px 9px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.small { padding: 2px 7px; font-size: 12px; }
button.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.sechead { display: flex; justify-content: space-between; align-items: baseline; }
#queueInfo { color: var(--mute); font-size: 12px; }
#scenes { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
@media (max-width: 400px) { #scenes { grid-template-columns: 1fr; } }
.scene { background: var(--panel); border-radius: 10px; overflow: hidden; }
.scene .pic { position: relative; cursor: zoom-in; background: #222; }
.scene .pic img { display: block; width: 100%; height: auto; }
.scene .pic svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.scene .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px; }
.scene .meta .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--mute); font-size: 12px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px; color: #fff; font-size: 12px; font-weight: 600; }
.status { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.65); color: #fff; padding: 6px 10px; font-size: 12px; }
.status .bar { height: 4px; background: rgba(255,255,255,.25); border-radius: 2px; margin-top: 4px; }
.status .bar i { display: block; height: 100%; background: #6cf; border-radius: 2px; transition: width .4s; }
.empty { color: var(--mute); padding: 20px 0; }

.modal { position: fixed; inset: 0; background: #111; z-index: 20; display: flex; flex-direction: column; }
.modal[hidden] { display: none; }
.vbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 12px; background: #1c1c1e; color: #eee; }
.vbar button { background: #2c2c2e; color: #eee; border-color: #3a3a3c; }
.vbar button.on { background: var(--accent); border-color: var(--accent); }
.vbar .spacer { flex: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 4px; }
.vhint { color: #ccc; background: #2b3a55; padding: 4px 12px; font-size: 12px; }
.vhint:empty { display: none; }
.vstage { flex: 1; overflow: auto; position: relative; touch-action: none; cursor: grab; }
.vstage.panning { cursor: grabbing; }
.vstage.panning svg rect.box { cursor: grabbing; }
.vwrap { position: relative; margin: auto; }
.vwrap img { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; }
.vwrap svg { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.vwrap.drawing svg { cursor: crosshair; }
svg rect.box { fill: transparent; cursor: pointer; }
svg rect.box:hover { fill: rgba(255,255,255,.12); }

.menu { position: fixed; z-index: 30; background: var(--panel); border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.35);
  padding: 6px; min-width: 200px; max-width: 90vw; }
.menu .t { color: var(--mute); font-size: 12px; padding: 4px 8px; }
.menu button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: none; padding: 6px 8px; }
.menu button:hover { background: #eef2fb; }
.menu .sw { width: 14px; height: 14px; border-radius: 3px; flex: none; }
.menu .sim { margin-left: auto; color: var(--mute); font-size: 12px; font-variant-numeric: tabular-nums; }
.scene .none { color: var(--mute); font-size: 12px; }

.tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.tab { font-weight: 600; padding: 6px 12px; }
.tab.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.controls input[type=number] { width: 4em; font: inherit; padding: 2px 4px; border: 1px solid var(--line); border-radius: 6px; }
.ref .thumb.crop img { object-fit: cover; }
.ref .count .best { display: block; }

.rblock { background: var(--panel); border-radius: 10px; border-left: 6px solid var(--c); padding: 10px; margin-bottom: 12px; }
.rhead { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.rhead img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; background: #eee; flex: none; }
.rhead .n { font-weight: 700; font-size: 15px; }
.rhead .sub { color: var(--mute); font-size: 12px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
@media (max-width: 400px) { .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.match { position: relative; border: 2px solid var(--line); border-radius: 8px; overflow: hidden; cursor: zoom-in; background: var(--panel); min-width: 0; }
.match:hover { border-color: var(--c); }
.match.pin { border-color: var(--c); }
.match .ph { position: relative; aspect-ratio: 4/3; background: #f1f1ee; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.match .ph .phc { max-width: 100%; max-height: 100%; width: 100%; background-repeat: no-repeat; }
.match .ph .phc[style*="aspect-ratio"] { height: auto; }
.match .ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; background: #f1f1ee; }
.match .rk { position: absolute; top: 4px; left: 4px; background: var(--c); color: #fff; font-weight: 800; font-size: 18px;
  padding: 0 7px; border-radius: 6px; line-height: 1.4; }
.match .acts { position: absolute; top: 4px; right: 4px; display: flex; gap: 3px; }
.match .acts button { padding: 0 6px; font-size: 13px; background: rgba(255,255,255,.9); }
.match .acts button.on { background: var(--c); color: #fff; border-color: var(--c); }
.match .bd { padding: 5px 7px; font-size: 12px; }
.match .sc { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.match .sn { color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.parts { display: grid; grid-template-columns: auto 1fr 2.2em; gap: 1px 5px; align-items: center; color: var(--mute); font-size: 11px; margin: 2px 0; }
.parts i { display: block; height: 5px; background: #e6e6e1; border-radius: 3px; overflow: hidden; }
.parts i b { display: block; height: 100%; background: var(--c); }
.parts span:nth-child(3n) { text-align: right; font-variant-numeric: tabular-nums; }
.menu button.rich { flex-wrap: wrap; }
.menu .sub { flex-basis: 100%; padding-left: 22px; color: var(--mute); font-size: 11px; }

@keyframes pulse { 0%, 100% { stroke-opacity: 1; } 50% { stroke-opacity: .1; } }
svg .pulse { animation: pulse .5s ease-in-out 5; }

.shopbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
#shops { display: flex; flex-wrap: wrap; gap: 6px; }
.shop { border-radius: 99px; padding: 5px 12px; }
.shop small { color: var(--mute); margin-left: 2px; }
.shop.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.shop.on small { color: #ccc; }
.shop.add { border-style: dashed; color: var(--mute); }
#shopActs { display: flex; gap: 6px; }
#shopActs[hidden] { display: none; }
.drop.off { opacity: .55; }
.scene .mv { font: inherit; font-size: 12px; max-width: 130px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.scene .mv[hidden] { display: none; }
