* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", system-ui, -apple-system, sans-serif; color: #1f2430; background: #eef1f5; }
#app { display: flex; flex-direction: column; height: 100vh; }

.dw-top { display: flex; align-items: center; gap: 10px; background: #ea6b22; color: #fff; padding: 8px 14px; }
.dw-top .brand { font-weight: 700; font-size: 15px; }
.dw-top .title { background: rgba(255,255,255,.16); border: none; color: #fff; font-size: 14px; padding: 5px 10px; border-radius: 6px; width: 240px; }
.dw-top .title::placeholder { color: #ffe6d5; }
.dw-top .spacer { flex: 1; }
.dw-top button { background: rgba(255,255,255,.16); color: #fff; border: none; border-radius: 6px; padding: 6px 11px; font-weight: 600; cursor: pointer; font-size: 13px; }
.dw-top button:hover { background: rgba(255,255,255,.28); }
.dw-top .saved { font-size: 12px; opacity: .85; min-width: 54px; }

.dw-body { flex: 1; display: flex; min-height: 0; }
.dw-side { width: 214px; background: #fff; border-right: 1px solid #e2e6ee; display: flex; flex-direction: column; }
.dw-side h4 { margin: 12px 12px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #94a3b8; }
.dw-newbtn { margin: 10px 12px; padding: 8px; background: #ea6b22; color: #fff; border: none; border-radius: 6px; font-weight: 600; cursor: pointer; }
.dw-list { overflow: auto; max-height: 30%; border-bottom: 1px solid #eef1f5; }
.dw-list .item { padding: 8px 12px; cursor: pointer; font-size: 13px; border-left: 3px solid transparent; }
.dw-list .item:hover { background: #f6f8fb; }
.dw-list .item.active { background: #fdf0e8; border-left-color: #ea6b22; font-weight: 600; }
.dw-list .item small { display: block; color: #94a3b8; font-size: 11px; }

.dw-stencils { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 6px 12px; overflow: auto; }
.dw-stencil { aspect-ratio: 1.4; border: 1px solid #e2e6ee; border-radius: 8px; background: #fbfcfe; cursor: grab; display: flex; align-items: center; justify-content: center; }
.dw-stencil:hover { border-color: #ea6b22; background: #fff7f1; }
.dw-stencil svg { width: 70%; height: 60%; }

.dw-canvas-wrap { flex: 1; overflow: auto; background: #eef1f5; position: relative; }
#dw-svg { background: #fff; display: block; box-shadow: inset 0 0 0 1px #e2e6ee; }
#dw-svg text { user-select: none; }
.dw-node { cursor: move; }
.dw-handle { fill: #fff; stroke: #ea6b22; stroke-width: 1.5; cursor: nwse-resize; }
.dw-selected { outline: none; }
.dw-selbox { fill: none; stroke: #ea6b22; stroke-width: 1.5; stroke-dasharray: 4 3; }
.dw-port { fill: #ea6b22; stroke: #fff; stroke-width: 1.5; opacity: .3; cursor: crosshair; transition: opacity .1s; }
.dw-node:hover .dw-port { opacity: 1; }
.dw-port:hover { opacity: 1; }
.dw-rot { fill: #fff; stroke: #ea6b22; stroke-width: 1.5; cursor: grab; }

.dw-props { width: 224px; background: #fff; border-left: 1px solid #e2e6ee; padding: 12px; overflow: auto; }
.dw-props h4 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #94a3b8; }
.dw-props label { display: block; font-size: 12px; color: #64748b; margin: 10px 0 3px; }
.dw-props input[type=text], .dw-props textarea { width: 100%; padding: 6px; border: 1px solid #e2e6ee; border-radius: 6px; font-size: 13px; }
.dw-swatches { display: flex; flex-wrap: wrap; gap: 5px; }
.dw-sw { width: 22px; height: 22px; border-radius: 5px; cursor: pointer; border: 2px solid transparent; }
.dw-sw.on { border-color: #1f2430; }
.dw-props .danger { margin-top: 14px; width: 100%; background: #fdecec; color: #c0362c; border: none; border-radius: 6px; padding: 8px; font-weight: 600; cursor: pointer; }
.dw-empty { color: #94a3b8; text-align: center; margin-top: 20px; font-size: 13px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1f2430; color: #fff; padding: 8px 16px; border-radius: 8px; font-size: 13px; opacity: 0; transition: opacity .2s; pointer-events: none; }
#toast.show { opacity: .95; }

/* --- upgraded editor --- */
.dw-top button { background: rgba(255,255,255,.16); color:#fff; border:none; border-radius:6px; padding:5px 9px; font-weight:600; cursor:pointer; font-size:13px; margin-left:2px; }
.dw-top button:hover { background: rgba(255,255,255,.3); }
.dw-top .snap { color:#fff; font-size:12px; display:flex; align-items:center; gap:3px; margin:0 4px; white-space:nowrap; }
#dw-svg { width:100%; height:100%; }
.dw-side { overflow:auto; }
#dw-stencils h4 { margin:10px 12px 4px; font-size:11px; text-transform:uppercase; letter-spacing:.5px; color:#94a3b8; }
.dw-stencils-grid { display:grid; grid-template-columns:1fr 1fr; gap:6px; padding:2px 12px 6px; }
.dw-modal { position:fixed; inset:0; background:rgba(15,23,42,.4); display:flex; align-items:center; justify-content:center; z-index:100; }
.dw-modal-card { background:#fff; border-radius:12px; padding:20px; width:420px; max-height:74vh; overflow:auto; box-shadow:0 20px 50px rgba(0,0,0,.3); }
.dw-modal-card h3 { margin:0 0 12px; }
.dw-modal-btn { width:100%; background:#ea6b22; color:#fff; border:none; border-radius:8px; padding:10px; font-weight:600; cursor:pointer; }
.dw-modal-sub { margin:16px 0 6px; color:#64748b; font-size:13px; }
.dw-modal-list { border:1px solid #e2e6ee; border-radius:8px; max-height:220px; overflow:auto; }
.dv-file { padding:9px 12px; cursor:pointer; border-bottom:1px solid #f1f5f9; font-size:13px; }
.dv-file:hover { background:#fdf0e8; }
.dw-modal-x { margin-top:14px; background:#eee; color:#444; border:none; border-radius:6px; padding:8px 14px; cursor:pointer; }
.dw-props label input[type=checkbox] { margin-right:6px; }
.dw-props select { width:100%; padding:6px; border:1px solid #e2e6ee; border-radius:6px; }
.dw-props button:not(.danger) { margin:2px 4px 6px 0; padding:6px 10px; border:1px solid #e2e6ee; background:#fff; border-radius:6px; cursor:pointer; font-size:12px; }
