/* Visual builder ("Design" view) */

body.design-mode .layout { grid-template-columns: 170px minmax(560px, 1fr) minmax(380px, 34%); }
body.design-mode .code-only { display: none !important; }
.editor .pane-title .seg button { text-transform: none; letter-spacing: 0; font-weight: 500; }
.editor .pane-title .seg button.off { opacity: .45; }

.designer { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.dz-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.dz-error { padding: 24px; color: var(--dim); display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.dz-error p { margin: 0; color: var(--err); font-family: var(--mono); font-size: 13px; }

/* Toolbar */
.dz-bar { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.dz-group { display: flex; gap: 2px; padding-right: 6px; border-right: 1px solid var(--line); }
.dz-group:last-child { border-right: 0; padding-right: 0; }
.dz-spacer { flex: 1; }
.dz-btn {
  display: inline-flex; align-items: center; gap: 5px; height: 30px; min-width: 30px; padding: 0 7px;
  background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--text);
}
.dz-btn:hover:not(:disabled) { background: var(--panel-2); border-color: var(--line); }
.dz-btn:disabled { opacity: .35; cursor: default; }
.dz-btn.on { background: #1d2a3a; border-color: #2c4661; color: var(--accent); }
.dz-btn span { font-size: 13px; }
.dz-zoom { font: 13px var(--mono); min-width: 52px; justify-content: center; color: var(--dim); }

.dz-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 300px; }

/* Canvas */
.dz-wrap {
  overflow: auto; display: flex; padding: 32px; min-width: 0; min-height: 0;
  background-color: #0a0d11;
  background-image: radial-gradient(rgba(140, 152, 168, .14) 1px, transparent 1px);
  background-size: 16px 16px;
}
.dz-sizer {
  position: relative; margin: auto; flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(140, 152, 168, .35), 0 12px 40px rgba(0, 0, 0, .5);
  background-color: #1a1f27;
  background-image: linear-gradient(45deg, #222833 25%, transparent 25%, transparent 75%, #222833 75%),
                    linear-gradient(45deg, #222833 25%, transparent 25%, transparent 75%, #222833 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px;
}
.dz-host { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.dz-overlay { position: absolute; inset: 0; cursor: default; touch-action: none; }

.dz-box { position: absolute; box-sizing: border-box; pointer-events: none; }
.dz-hover { outline: 1px solid rgba(90, 169, 255, .55); }
.dz-sel { outline: 1.5px solid var(--accent); }
.dz-sel.locked { outline: 1.5px dashed var(--warn); }
.dz-multi { outline: 1px dashed var(--accent); }
.dz-marquee { background: rgba(90, 169, 255, .1); outline: 1px solid rgba(90, 169, 255, .7); }
.dz-guide { position: absolute; background: #ff5fa2; pointer-events: none; }
.dz-tag {
  position: absolute; pointer-events: none; transform: translateX(0);
  font: 13px var(--mono); color: #06121f; background: var(--accent); padding: 0 6px; border-radius: 4px; white-space: nowrap;
}

.dz-h {
  position: absolute; width: 10px; height: 10px; background: #fff; border: 1.5px solid var(--accent);
  border-radius: 2px; transform: translate(-50%, -50%); pointer-events: auto; box-sizing: border-box;
}
.dz-h-nw { left: 0; top: 0; cursor: nwse-resize; }
.dz-h-n { left: 50%; top: 0; cursor: ns-resize; }
.dz-h-ne { left: 100%; top: 0; cursor: nesw-resize; }
.dz-h-e { left: 100%; top: 50%; cursor: ew-resize; }
.dz-h-se { left: 100%; top: 100%; cursor: nwse-resize; }
.dz-h-s { left: 50%; top: 100%; cursor: ns-resize; }
.dz-h-sw { left: 0; top: 100%; cursor: nesw-resize; }
.dz-h-w { left: 0; top: 50%; cursor: ew-resize; }
.dz-rot {
  position: absolute; left: 50%; top: -28px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff; transform: translateX(-50%); pointer-events: auto; cursor: grab; box-sizing: border-box;
}
.dz-rot::after { content: ""; position: absolute; left: 50%; top: 10px; width: 1.5px; height: 16px; background: var(--accent); transform: translateX(-50%); }

/* Pipes: the box is only a hint, the corners are what you edit */
.dz-sel.dz-pipebox { outline: 1px dashed rgba(90, 169, 255, .45); }
.dz-pt {
  position: absolute; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--accent);
  transform: translate(-50%, -50%); box-sizing: border-box; pointer-events: auto; cursor: move;
}
.dz-pt:hover { background: var(--accent); }
.dz-drawsvg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.dz-drawsvg polyline { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 4; }
.dz-main { position: relative; }
.dz-hint {
  position: absolute; left: calc((100% - 300px) / 2); top: 10px; transform: translateX(-50%); z-index: 5; max-width: calc(100% - 340px);
  font-size: 13px; color: var(--text); background: var(--panel); border: 1px solid var(--accent); border-radius: 8px;
  padding: 7px 12px; box-shadow: 0 6px 20px rgba(0, 0, 0, .45); pointer-events: none; text-align: center;
}
.dz-hint[hidden] { display: none; }

/* Right panel */
.dz-panel { border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.dz-tabs { display: flex; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.dz-tabs button { flex: 1; border: 0; border-radius: 0; background: transparent; padding: 9px 6px; color: var(--dim); border-bottom: 2px solid transparent; }
.dz-tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.dz-pbody { flex: 1; overflow-y: auto; padding: 10px 12px 24px; }

.dz-head { display: flex; align-items: center; gap: 8px; padding: 2px 0 10px; }
.dz-head b { text-transform: capitalize; font-size: 15px; }
.dz-head code { margin-left: auto; color: var(--dim); }
.dz-dim { color: var(--dim); font-size: 13px; margin-left: auto; }
.dz-sec { border-top: 1px solid var(--line); padding: 10px 0 4px; display: flex; flex-direction: column; gap: 8px; }
.dz-sec-t { font-size: 13px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--dim); }
.dz-f { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--dim); min-width: 0; }
.dz-f > input, .dz-f > select, .dz-f > textarea, .dz-sec > textarea, .dz-sec > select { width: 100%; }
.dz-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dz-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.dz-row select { flex: 1; min-width: 0; }
.dz-checks { display: flex; gap: 16px; }
.dz-check { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text); cursor: pointer; }
.dz-note { font-size: 13px; color: var(--dim); line-height: 1.45; }
.dz-inline { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--dim); }
.dz-inline input { width: 72px; }
.dz-unit { font-size: 13px; color: var(--dim); }
.dz-mono { font-family: var(--mono); }
.dz-pbody textarea { resize: vertical; font-family: var(--mono); min-height: 52px; }
.dz-insert { color: var(--dim); }

.dz-color { display: inline-flex; align-items: center; gap: 5px; }
.dz-color input[type=color] { width: 38px; height: 26px; }
.dz-alpha { width: 58px; }
.dz-fill { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.dz-fill > select { width: 100%; }
.dz-stop { display: flex; align-items: center; gap: 5px; }
.dz-at { width: 58px; }
.dz-x { background: transparent; border: 0; color: var(--dim); font-size: 17px; line-height: 1; padding: 2px 6px; }
.dz-x:hover { color: var(--err); }
.dz-link { background: transparent; border: 1px dashed var(--line); color: var(--accent); width: 100%; }
.dz-thumb { max-width: 100%; max-height: 90px; object-fit: contain; border-radius: 6px; background: repeating-conic-gradient(#222833 0% 25%, #1a1f27 0% 50%) 50% / 12px 12px; align-self: flex-start; }

.dz-card { border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 8px; background: var(--panel-2); }
.dz-card-top { display: flex; gap: 6px; align-items: center; }
.dz-card-top input { flex: 1; }

/* Behaviour: button + rules */
.dz-warn { font-size: 13px; color: var(--warn); }
.dz-quick { width: 100%; color: var(--accent); border-style: dashed; }
.dz-rule { gap: 6px; }
.dz-rule-t { font-size: 13px; }
.dz-rule .dz-spacer { flex: 1; }
.dz-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex-shrink: 0; }
.dz-rule.active { border-color: rgba(63, 185, 80, .55); }
.dz-rule.active .dz-dot { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.dz-cond { display: grid; grid-template-columns: minmax(0, 1.2fr) auto minmax(0, 1fr) auto; gap: 4px; align-items: center; }
.dz-cond > select, .dz-cond > input { min-width: 0; width: 100%; }
.dz-cond .dz-and { grid-column: 1 / -1; font-size: 13px; color: var(--dim); }
.dz-op { width: auto; }
.dz-between { display: flex; align-items: center; gap: 5px; min-width: 0; }
.dz-between input { width: 100%; min-width: 0; }
.dz-then { font-size: 13px; color: var(--dim); border-top: 1px dashed var(--line); padding-top: 6px; }
.dz-set { display: flex; flex-direction: column; gap: 4px; padding: 6px; border-radius: 6px; background: var(--panel); }
.dz-set-top { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--text); }
.dz-set > input, .dz-set > select { width: 100%; }
.dz-map { display: flex; flex-direction: column; gap: 6px; }
.dz-link.small { padding: 3px 8px; font-size: 13px; }

/* Icons */
.dz-iconprev { width: 40px; height: 40px; flex-shrink: 0; border-radius: 6px; background-color: transparent; outline: 1px solid var(--line); outline-offset: 3px; }
.dz-icondlg { width: min(760px, 94vw); padding: 0; }
.dz-icondlg-head { display: flex; gap: 8px; padding: 14px; border-bottom: 1px solid var(--line); }
.dz-icondlg-head input { flex: 1; font-size: 14px; padding: 7px 10px; }
.dz-icongrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 4px; padding: 12px; max-height: 60vh; overflow-y: auto; }
.dz-icongrid button {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px 6px;
  background: transparent; border: 1px solid transparent; border-radius: 8px; color: var(--text);
}
.dz-icongrid button:hover, .dz-icongrid button:focus-visible { background: var(--panel-2); border-color: var(--line); }
.dz-icongrid svg { width: 28px; height: 28px; }
.dz-icongrid span { font-size: 13px; color: var(--dim); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#dzIconFoot { padding: 0 14px 12px; }
.dz-settabs { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; flex-shrink: 0; }
.dz-settabs button { border: 0; border-radius: 0; background: transparent; color: var(--dim); padding: 6px 12px; }
.dz-settabs button + button { border-left: 1px solid var(--line); }
.dz-settabs button.on { background: var(--panel-2); color: var(--text); }

/* Layers */
.dz-layers { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.dz-layers li { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; cursor: pointer; font-size: 13px; border: 1px solid transparent; }
.dz-layers li:hover { background: var(--panel-2); }
.dz-layers li.on { background: #1d2a3a; border-color: #2c4661; }
.dz-layers li.drop-above { box-shadow: inset 0 2px 0 var(--accent); }
.dz-layers li.drop-below { box-shadow: inset 0 -2px 0 var(--accent); }
.dz-li-ic { color: var(--dim); display: inline-flex; }
.dz-li-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dz-li-btn { background: transparent; border: 0; padding: 2px 4px; color: var(--dim); display: inline-flex; opacity: .55; }
.dz-li-btn:hover, .dz-li-btn.off { opacity: 1; }
.dz-li-btn.off { color: var(--warn); }
