:root {
  --bg: #151618; --panel: #1d1f22; --panel2: #24272b; --line: #2e3237; --text: #d8dbdf; --muted: #868c94;
  --accent: #22d3ee; --male: #7fd6a4; --female: #f0a96c; --online: #b7bcc3; --warn: #f0c24b;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px/1.3 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif; }
body { display: flex; flex-direction: column; overflow: hidden; }
button, select, input, textarea { font: inherit; color: inherit; }
button { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
button:hover:not(:disabled) { border-color: #4a5058; }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #062026; font-weight: 600; }
button.primary:hover:not(:disabled) { filter: brightness(1.08); border-color: var(--accent); }
button.on, button.active { border-color: var(--accent); color: var(--accent); }
.grow { flex: 1; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

header { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .04em; margin-right: 10px; }
.brand span { color: var(--muted); font-weight: 400; }
#fileName { margin-left: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }

main { flex: 1; display: flex; min-height: 0; }
#viewport { flex: 1; position: relative; min-width: 0; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#cv.pick { cursor: crosshair; }
#cv.pan { cursor: grabbing; }

#empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
#empty .drop { pointer-events: auto; width: min(420px, 80%); padding: 48px 24px; border: 1.5px dashed #3a3f46; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 16px; }
#empty.over .drop { border-color: var(--accent); }
.dropTitle { font-size: 16px; color: var(--muted); }

.float { position: absolute; display: flex; gap: 6px; align-items: center; background: rgba(29,31,34,.92);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px; backdrop-filter: blur(4px); }
.float.tl { top: 10px; left: 10px; }
.float.bl { bottom: 10px; left: 10px; }
.float.br { bottom: 10px; right: 10px; }
.chip { white-space: nowrap; padding: 4px 10px; border-radius: 5px; font-size: 12px; color: var(--muted); }
.chip.on { color: var(--text); border-color: #4a5058; }
#fitBtn { color: var(--text); }
.chip.accent { border-color: var(--accent); color: var(--accent); }
.modeLabel { color: var(--accent); font-weight: 600; padding: 0 6px 0 4px; }
.icon { width: 30px; height: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.icon svg { width: 14px; height: 14px; fill: currentColor; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
#sim input[type=range] { width: 220px; accent-color: var(--accent); }

aside#editPanel { width: 380px; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.panelHead { display: flex; align-items: center; gap: 6px; padding: 10px 10px 10px 14px; border-bottom: 1px solid var(--line); }
.panelTitle { font-weight: 600; }
.cutHead, .cutRow { display: grid; grid-template-columns: 18px 30px 1fr 58px 50px 34px; align-items: center; gap: 6px; padding: 0 10px; }
.cutHead { color: var(--muted); font-size: 11px; padding-top: 8px; padding-bottom: 6px; text-transform: uppercase; letter-spacing: .05em; }
#cutList { overflow-y: auto; flex: 1; padding-bottom: 12px; }
.cutRow { height: 38px; border-top: 1px solid transparent; border-bottom: 1px solid transparent; cursor: pointer; }
.cutRow:hover { background: #212428; }
.cutRow.sel { background: rgba(34,211,238,.08); border-color: rgba(34,211,238,.35); }
.cutRow.off { opacity: .45; }
.cutRow.dragOver { border-top-color: var(--accent); }
.grip { cursor: grab; width: 10px; height: 16px; background-image: radial-gradient(#5b6169 1.2px, transparent 1.3px); background-size: 5px 5px; }
.num { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.cutRow select { width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 5px; padding: 4px 6px; }
.cutRow button { padding: 4px 0; font-size: 12px; width: 100%; }
.cutRow input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; justify-self: center; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin: 0 4px 0 10px; }
.dot.male { background: var(--male); } .dot.female { background: var(--female); } .dot.online { background: var(--online); }

footer { display: flex; align-items: center; gap: 18px; padding: 7px 14px; background: var(--panel); border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat { display: flex; gap: 6px; }
.stat .k { color: var(--muted); }
.stat.warn, .stat.warn .k { color: var(--warn); }
.coords span:nth-child(2) { min-width: 56px; }
.legend { color: var(--muted); display: flex; align-items: center; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 18px; width: 360px; }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog form { display: flex; flex-direction: column; gap: 10px; }
.dlgTitle { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
dialog label { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); }
dialog label.col { flex-direction: column; align-items: stretch; gap: 4px; }
dialog input, dialog select, dialog textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 5px 8px; color: var(--text); }
dialog textarea { font-family: ui-monospace, Menlo, monospace; font-size: 12px; resize: vertical; }
.unitIn { display: flex; align-items: center; gap: 6px; }
.unitIn input { width: 90px; text-align: right; }
.unitIn i { font-style: normal; color: var(--muted); width: 16px; }
dialog select { width: 112px; }
.dlgBtns { display: flex; gap: 8px; margin-top: 6px; }
.scaleBox, .scaleBox label { display: flex; align-items: center; gap: 6px; }
.scaleBox { gap: 14px; color: var(--muted); margin-left: 10px; }
.scaleBox input { width: 76px; text-align: right; background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 5px 8px; }
.scaleBox i { font-style: normal; }
#leadEdit { border-top: 1px solid var(--line); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.leRow { display: grid; grid-template-columns: 70px 1fr 1fr; align-items: center; gap: 8px; }
.leRow .k { color: var(--muted); }
.leRow.btns { display: flex; justify-content: flex-end; }
#leadEdit .unitIn input { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 5px 8px; text-align: right; }
#leadEdit input.auto { color: var(--muted); }
