* { box-sizing: border-box; }
html, body { margin:0; height:100%; overflow:hidden; background:#111; color:#eee; }
.wrap { display:grid; grid-template-columns: 240px 1fr; height:100vh; }
#sidebar { background:#1e1e1e; padding:12px; font-family:system-ui,sans-serif; border-right:1px solid #333; }
#sidebar h2 { font-size:16px; margin:0 0 12px; color:#bbb; }
.btn { width:100%; padding:10px 12px; margin-bottom:8px; border:1px solid #444; background:#2a2a2a; color:#eee; border-radius:8px; cursor:pointer; text-align:left; }
.btn.active { background:#3a3a3a; border-color:#69a4ff; outline: 1px solid #69a4ff55; }
.panel { margin-top:12px; font-size:12px; color:#bbb; }
.panel a { color:#9cf; }
#toolbar { position:fixed; top:10px; right:10px; background:#222; padding:.5rem .75rem; border-radius:8px; font-family:system-ui,sans-serif; border:1px solid #333; }
#stage { position:relative; }
canvas { display:block; width:100%; height:100vh; cursor: grab; }
canvas.mode-add, canvas.mode-connect { cursor: crosshair; }

/* Popover */
.popover { position:absolute; background:#1c1c1c; border:1px solid #333; border-radius:10px; padding:10px; min-width:340px; box-shadow: 0 8px 24px rgba(0,0,0,.4); z-index:5; }
.hidden { display:none; }
.pop-title { font-weight:700; margin-bottom:8px; }
#checkboxes { max-height:360px; overflow:auto; margin-bottom:10px; }
.pop-actions { display:flex; gap:8px; justify-content:flex-end; }

/* Custom Name row */
.custom-name-row { display:flex; align-items:center; gap:.5rem; margin:6px 0 10px; }
.cn-label { display:flex; align-items:center; gap:.5rem; min-width:120px; }
.custom-name-row input[type="text"] { flex:1 1 auto; background:#111; color:#eee; border:1px solid #333; border-radius:6px; padding:4px 8px; }

/* Entity header row */
.entity-row.header { display:grid; grid-template-columns: 48px 1fr 1fr 90px; gap:8px; padding:4px 6px; border-bottom:1px solid #2a2a2a; color:#9aa; font-size:12px; }
.entity-row.header .hdr-a { grid-column: 1; }
.entity-row.header .hdr-b { grid-column: 2; }
.entity-row.header .hdr-c { grid-column: 3; }
.entity-row.header .hdr-d { grid-column: 4; text-align:center; }

/* Entities list (grid) */
.entity-row { display:grid; grid-template-columns: 48px 1fr 1fr 90px; gap:8px; align-items:center; margin:6px 0; }
.entity-empty { color:#aaa; padding:8px 4px; font-size:12px; }

/* Cells */
.cell.a { display:flex; justify-content:center; }
.cell.b .name { font-weight:500; }
.cell.c.option-wrap { display:flex; gap:8px; align-items:center; }
.cell.c.dim { color:#777; }
.cell.c select, .cell.c .opt-custom { background:#111; color:#eee; border:1px solid #333; border-radius:6px; padding:2px 6px; }

/* Qty cell */
.cell.d.qty { display:flex; align-items:center; justify-content:center; gap:.35rem; }
.cell.d.qty.disabled { opacity:.5; }
.cell.d.qty .count { min-width:26px; text-align:center; font-variant-numeric: tabular-nums; }
.qty-btn { width:26px; height:24px; border:1px solid #444; background:#2a2a2a; color:#eee; border-radius:6px; cursor:pointer; font-weight:700; line-height:1; }

/* Settings panels (draw/connect) */
.draw-menu { margin-top:10px; padding:10px; border:1px solid #333; border-radius:8px; background:#191919; }
.draw-menu.hidden { display:none; }

.row { display:flex; align-items:center; gap:10px; margin:6px 0; flex-wrap:nowrap; }
.row-label { min-width:60px; color:#bbb; }

/* Color swatches */
.swatches { display:flex; gap:10px; }
.swatch { width:22px; height:22px; border-radius:6px; border:2px solid #444; cursor:pointer; }
.swatch[data-color="red"]   { background:#ff3333; }
.swatch[data-color="green"] { background:#18c35b; }
.swatch[data-color="blue"]  { background:#3399ff; }
.swatch.selected { outline:2px solid #69a4ff; outline-offset:1px; }

/* Weight buttons */
.weightBtns { display:flex; gap:12px; align-items:center; }
.weight-btn { width:28px; height:24px; display:flex; align-items:center; justify-content:center;
              border:1px solid #444; border-radius:6px; background:#2a2a2a; cursor:pointer; color:#fff; }
.weight-btn .bar { height:16px; border-left: solid #fff 1px; }
.weight-btn[data-weight="thin"]   .bar { border-left-width: 2px; }
.weight-btn[data-weight="medium"] .bar { border-left-width: 4px; }
.weight-btn[data-weight="thick"]  .bar { border-left-width: 7px; }
.weight-btn.selected { outline:2px solid #69a4ff; outline-offset:1px; }
