#hcd-overlay {
  position: fixed; inset: 0; z-index: 100000;
  background: #0b1220; color: #0f172a;
  display: flex; flex-direction: column;
  font-family: Cairo, Tajawal, "Segoe UI", sans-serif;
  direction: rtl;
}
#hcd-overlay * { box-sizing: border-box; }
.hcd-top {
  height: 56px; flex: 0 0 56px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px; background: #0f172a; color: #fff;
  border-bottom: 1px solid #1e293b;
}
.hcd-top h3 { margin: 0; font-size: 15px; font-weight: 700; white-space: nowrap; }
.hcd-top .hcd-grow { flex: 1; }
.hcd-btn {
  border: 0; border-radius: 8px; padding: 7px 12px; cursor: pointer;
  font-size: 12px; font-weight: 700; background: #1e293b; color: #e2e8f0;
}
.hcd-btn:hover { background: #334155; }
.hcd-btn-primary { background: #0868D7; color: #fff; }
.hcd-btn-primary:hover { background: #0654ad; }
.hcd-btn-danger { background: #7f1d1d; color: #fecaca; }
.hcd-btn-ghost { background: transparent; border: 1px solid #334155; }
.hcd-body { flex: 1; display: flex; min-height: 0; }
.hcd-side {
  width: 260px; flex: 0 0 260px; background: #fff;
  border-left: 1px solid #e2e8f0; border-right: 1px solid #e2e8f0;
  overflow: auto; padding: 10px;
}
.hcd-side-left { border-right: 0; }
.hcd-side-right { width: 300px; flex: 0 0 300px; }
.hcd-stage-wrap {
  flex: 1; min-width: 0; background: #e8eef6;
  display: flex; flex-direction: column; align-items: center;
  overflow: auto; padding: 24px 16px 40px; position: relative;
}
.hcd-stage-tools {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px;
  align-items: center; justify-content: center;
}
.hcd-stage-tools label { font-size: 12px; color: #334155; display: flex; align-items: center; gap: 4px; }
.hcd-canvas-outer {
  position: relative; box-shadow: 0 18px 50px rgba(15,23,42,.18);
}
.hcd-canvas {
  position: relative; overflow: hidden; background: #0868D7;
  user-select: none; touch-action: none;
}
.hcd-canvas.hcd-grid::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(to right, rgba(255,255,255,.12) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,.12) 1px, transparent 1px);
  background-size: 5% 5%;
}
.hcd-bg-layer { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.hcd-el {
  position: absolute; cursor: move; outline: 1px solid transparent;
  z-index: 1; display: flex; align-items: center; justify-content: center;
  overflow: hidden; word-break: break-word;
}
.hcd-el.selected { outline: 2px solid #38bdf8; box-shadow: 0 0 0 1px #0ea5e9; }
.hcd-el.locked { cursor: default; opacity: .85; }
.hcd-el.hidden-el { opacity: .25 !important; outline: 1px dashed #94a3b8; }
.hcd-handle {
  position: absolute; width: 10px; height: 10px; background: #38bdf8;
  border: 1px solid #fff; border-radius: 2px; z-index: 5;
}
.hcd-handle.nw { top: -5px; left: -5px; cursor: nwse-resize; }
.hcd-handle.ne { top: -5px; right: -5px; cursor: nesw-resize; }
.hcd-handle.sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.hcd-handle.se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.hcd-card-resize {
  position: absolute; width: 14px; height: 14px; right: -7px; bottom: -7px;
  background: #0868D7; border: 2px solid #fff; border-radius: 50%;
  cursor: nwse-resize; z-index: 20;
}
.hcd-panel-title {
  font-size: 12px; font-weight: 800; color: #0f172a; margin: 4px 0 10px;
  padding-bottom: 6px; border-bottom: 1px solid #e2e8f0;
}
.hcd-layer {
  display: flex; align-items: center; gap: 6px; padding: 7px 8px;
  border: 1px solid #e2e8f0; border-radius: 8px; margin-bottom: 6px;
  background: #f8fafc; cursor: pointer; font-size: 12px;
}
.hcd-layer.active { border-color: #0868D7; background: #eff6ff; }
.hcd-layer .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hcd-layer .mini { border: 0; background: transparent; cursor: pointer; font-size: 12px; padding: 2px; }
.hcd-field { margin-bottom: 10px; }
.hcd-field label { display: block; font-size: 11px; color: #64748b; margin-bottom: 4px; font-weight: 700; }
.hcd-field input, .hcd-field select, .hcd-field textarea {
  width: 100%; border: 1px solid #cbd5e1; border-radius: 8px;
  padding: 7px 9px; font-size: 12px; background: #fff;
}
.hcd-field textarea { min-height: 64px; resize: vertical; }
.hcd-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hcd-hint { font-size: 11px; color: #64748b; margin: 0 0 8px; line-height: 1.5; }
.hcd-modal-bg {
  position: absolute; inset: 0; background: rgba(2,6,23,.55);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.hcd-modal {
  background: #fff; border-radius: 14px; width: min(920px, 94vw);
  max-height: 88vh; overflow: auto; padding: 16px;
}
.hcd-modal h4 { margin: 0 0 12px; }
.hcd-devices { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; }
.hcd-device {
  background: #0f172a; border-radius: 18px; padding: 12px;
  color: #fff; text-align: center;
}
.hcd-device .label { font-size: 11px; margin-bottom: 8px; opacity: .8; }
.hcd-device-screen {
  background: #e2e8f0; border-radius: 10px; overflow: hidden;
  margin: 0 auto; position: relative;
}
.hcd-toast {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: #065f46; color: #fff; padding: 8px 14px; border-radius: 999px;
  font-size: 12px; z-index: 60; display: none;
}
