:root {
  --bg: #17130f; --panel: #211b16; --panel2: #2a221c; --line: #3d3128; --ink: #ebe4d7;
  --dim: #9a8e82; --rust: #b8402c; --rust2: #dc3e2a; --amber: #f0aa32; --grey: #aaaaaa;
  --ok: #5abe5a; --bad: #f09628; --none: #6e6862; --sel: #4cc8ff;
  --font: Bahnschrift, "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* #tabs/#actions are display:flex, which beats the attribute */
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.35 var(--font); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button, .btn {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 11px;
  cursor: pointer; text-decoration: none; display: inline-block; white-space: nowrap;
}
button:hover, .btn:hover { border-color: #6b5446; }
button:disabled { opacity: .4; cursor: default; }
button.primary, .btn.primary { background: var(--rust); border-color: var(--rust2); color: #fff; }
button.primary:hover { background: var(--rust2); }
button.danger { color: #ff9a85; }
button.on { background: #4a2a22; border-color: var(--rust2); }
button.small { padding: 2px 7px; font-size: 12px; }
input, select, textarea {
  background: #120f0c; border: 1px solid var(--line); border-radius: 5px; padding: 4px 7px; min-width: 0;
}
input[type=checkbox] { width: auto !important; display: inline-block !important; margin: 0; }
input:focus, select:focus, textarea:focus { outline: 1px solid var(--rust2); border-color: var(--rust2); }
textarea { resize: vertical; width: 100%; }
label { display: block; color: var(--dim); font-size: 12px; margin: 8px 0 3px; }
label > input, label > select, label > textarea { display: block; width: 100%; margin-top: 3px; color: var(--ink); font-size: 14px; }
code { background: #0e0b09; padding: 1px 4px; border-radius: 3px; }
.muted { color: var(--dim); }
h2 { font-size: 18px; margin: 0 0 8px; font-weight: 600; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--dim); margin: 16px 0 6px; font-weight: 600; }

/* header */
#top {
  height: 52px; display: flex; align-items: center; gap: 14px; padding: 0 12px;
  background: linear-gradient(#2a1d16, #1c1510); border-bottom: 2px solid #4a2a20;
}
.brand { font-weight: 700; letter-spacing: .08em; color: #e8d6c4; white-space: nowrap; }
.brand span { font-weight: 400; color: var(--dim); letter-spacing: 0; margin-left: 6px; }
#tabs { display: flex; gap: 4px; }
#tabs button.on { background: var(--rust); border-color: var(--rust2); color: #fff; }
#state { flex: 1; min-width: 0; font-size: 12px; color: var(--dim); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#state b { color: var(--amber); font-weight: 600; }
#state a { color: var(--dim); }
#actions { display: flex; gap: 4px; }
#user { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--dim); white-space: nowrap; }
#user img { width: 24px; height: 24px; border-radius: 50%; }
#user a { color: var(--dim); }

#main { height: calc(100% - 52px); }
.pane { height: 100%; }
#login { max-width: 620px; margin: 80px auto; }
#login h1 { font-size: 26px; }

/* three-column layout used by both editors */
.cols { display: grid; grid-template-columns: 250px 1fr 330px; height: 100%; }
.side { background: var(--panel); border-right: 1px solid var(--line); overflow: auto; padding: 10px; }
.side.right { border-right: 0; border-left: 1px solid var(--line); }
.center { overflow: auto; position: relative; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row > label { flex: 1; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.grid4 label { margin-top: 4px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  padding: 5px 8px; border-radius: 5px; cursor: pointer; display: flex; gap: 6px; align-items: center;
  border: 1px solid transparent;
}
.list li:hover { background: var(--panel2); }
.list li.on { background: #3a231b; border-color: var(--rust); }
.list li .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list li .id { color: var(--dim); font-size: 11px; }
.list li.mod::after { content: "●"; color: var(--amber); font-size: 10px; }

/* ---- UI block map ---- */
.stage-wrap { padding: 14px; }
.toolbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.stage { position: relative; background: #000; overflow: hidden; box-shadow: 0 0 0 1px var(--line); user-select: none; }
.frame { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.frame > img.bg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.frame > .shade, .frame > svg.grid { position: absolute; inset: 0; pointer-events: none; }
.zone {
  position: absolute; border: 3px solid; cursor: move; overflow: visible;
}
.zone .zid { position: absolute; left: 8px; top: 4px; font-size: 26px; font-weight: 600; color: #fff;
  text-shadow: 0 0 3px #000, 0 0 3px #000, 0 0 2px #000; white-space: nowrap; pointer-events: none; }
.zone .zname { position: absolute; left: 8px; top: 38px; font-size: 19px; color: #ffebc8; right: 6px;
  text-shadow: 0 0 3px #000, 0 0 3px #000; pointer-events: none; }
.zone.short .zname { top: calc(100% + 4px); left: 0; right: auto; white-space: nowrap; }
.frame > .zones { position: absolute; inset: 0; }
.zone.sel { box-shadow: 0 0 0 var(--sw, 3px) var(--sel); z-index: 5; }
/* handles keep the same on-screen size at any zoom: --hs = 13px / scale */
.zone .hd { position: absolute; width: var(--hs, 18px); height: var(--hs, 18px); background: var(--sel); border: 1px solid #000; display: none;
  --o: calc(var(--hs, 18px) / -2 - 1.5px); }
.zone.sel .hd { display: block; }
.hd.nw { left: var(--o); top: var(--o); cursor: nwse-resize; } .hd.ne { right: var(--o); top: var(--o); cursor: nesw-resize; }
.hd.sw { left: var(--o); bottom: var(--o); cursor: nesw-resize; } .hd.se { right: var(--o); bottom: var(--o); cursor: nwse-resize; }
.hd.n { left: calc(50% + var(--o)); top: var(--o); cursor: ns-resize; } .hd.s { left: calc(50% + var(--o)); bottom: var(--o); cursor: ns-resize; }
.hd.w { top: calc(50% + var(--o)); left: var(--o); cursor: ew-resize; } .hd.e { top: calc(50% + var(--o)); right: var(--o); cursor: ew-resize; }
.guide { position: absolute; background: #ff3cd2; pointer-events: none; z-index: 9; }
.marquee { position: absolute; border: 2px dashed var(--sel); background: rgba(76,200,255,.08); pointer-events: none; z-index: 9; }
.title-bar { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; font-size: 34px; color: #fff;
  text-shadow: 0 0 4px #000, 0 0 4px #000; pointer-events: none; }
.hint { font-size: 12px; color: var(--dim); margin-top: 10px; }
.pri1 { --c: 230,60,40; } .pri2 { --c: 240,170,50; } .pri3 { --c: 170,170,170; }
.zone { border-color: rgb(var(--c)); background: rgba(var(--c), .24); }
.pridot { width: 10px; height: 10px; border-radius: 2px; background: rgb(var(--c)); flex: none; }

/* ---- sound map ---- */
.summary { display: flex; gap: 18px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.summary b { font-size: 20px; color: var(--ink); display: block; }
.summary span { color: var(--dim); font-size: 12px; }
.form { padding: 14px 18px 60px; max-width: 980px; }
.badge { display: inline-block; min-width: 20px; text-align: center; padding: 0 5px; border-radius: 4px; font-size: 11px; font-weight: 700;
  border: 1px solid var(--grey); color: var(--dim); }
.badge.A { background: var(--rust2); border-color: var(--rust2); color: #fff; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.none { border: 2px solid var(--none); }
.prio { font-size: 11px; font-weight: 700; }
.prio.p1 { color: rgb(230,60,40); } .prio.p2 { color: rgb(240,170,50); } .prio.p3 { color: #aaa; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--line); padding: 4px 10px; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--rust); color: #fff; }
.grp-head { font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; margin: 10px 0 2px; padding: 0 8px;
  display: flex; align-items: center; gap: 6px; cursor: pointer; }
.grp-head.on { color: var(--amber); }
.param { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 8px 0; background: var(--panel2); }
.param.A { border-color: var(--rust2); background: #33201a; }
.param .row { gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; align-items: center; }
.chip { border: 1px solid var(--line); border-radius: 12px; padding: 2px 9px; font-size: 13px; background: #18130f; cursor: pointer; }
.chip.hot { border-color: var(--rust2); color: #ff8f7a; }
.chip.all { border-color: var(--rust2); }
.chip .x { margin-left: 5px; color: var(--dim); }
.chip .x:hover { color: #fff; }
.chips input { width: 140px; padding: 2px 7px; border-radius: 12px; font-size: 13px; }
.budget { font-size: 13px; color: var(--dim); margin-top: 6px; }
.budget b { color: var(--ink); }
table.dims { border-collapse: collapse; width: 100%; }
table.dims td { border-top: 1px solid var(--line); padding: 8px 6px; vertical-align: top; }
.used { font-size: 11px; color: var(--dim); }

/* dialogs, toasts */
dialog { background: var(--panel); color: var(--ink); border: 1px solid var(--rust); border-radius: 10px; width: min(560px, 92vw); padding: 18px; }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog menu { display: flex; gap: 8px; justify-content: flex-end; padding: 0; margin: 16px 0 0; }
#save-list { font-size: 12px; color: var(--dim); max-height: 160px; overflow: auto; padding-left: 18px; }
#msg-body { white-space: pre-wrap; }
#msg-body ul { white-space: normal; }
#toasts { position: fixed; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: #2d211a; border: 1px solid var(--rust); border-radius: 8px; padding: 9px 13px; max-width: 420px; box-shadow: 0 4px 18px #000a; }
.toast a { color: var(--amber); }
.toast.err { border-color: #ff6a4a; }
.banner { background: #3a2a14; border: 1px solid var(--amber); border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; }
.busy { cursor: progress !important; }
.busy * { pointer-events: none; }

@media (max-width: 1100px) {
  .cols { grid-template-columns: 200px 1fr 280px; }
  .brand span { display: none; }
}
