html.dark,
html.dark body,
html.dark main {
  background-color: #020617 !important; /* slate-950 */
  color: #f1f5f9;
}

/* Scrollbar gelap di Dark Mode */
html.dark ::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
html.dark ::-webkit-scrollbar-track {
  background: #0f172a;
}
html.dark ::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 9999px;
}
/* Canvas & Selection Box */
.canvas-wrapper {
  position: relative;
  display: inline-block;
  box-shadow: 0 20px 45px -10px rgba(15, 23, 42, 0.22);
  background: #ffffff;
  touch-action: pan-x pan-y;
}

.overlay-item {
  position: absolute;
  cursor: move;
  border: 1.5px dashed transparent;
  user-select: none;
  box-sizing: border-box;
}

.overlay-item:hover,
.overlay-item.selected {
  border-color: #2563eb;
  background-color: rgba(37, 99, 235, 0.04);
}

/* 4-Corner Resize Handles */
.resize-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #2563eb;
  border: 2px solid #ffffff;
  border-radius: 50%;
  display: none;
  z-index: 40;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
}

.overlay-item:hover .resize-handle,
.overlay-item.selected .resize-handle {
  display: block;
}

.handle-nw { top: -7px; left: -7px; cursor: nwse-resize; }
.handle-ne { top: -7px; right: -7px; cursor: nesw-resize; }
.handle-sw { bottom: -7px; left: -7px; cursor: nesw-resize; }
.handle-se { bottom: -7px; right: -7px; cursor: nwse-resize; }

/* Floating Selection Toolbar (Ratio Lock, Layer, BG, Delete) */
.item-toolbar {
  position: absolute;
  top: -36px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 4px;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(8px);
  color: #fff;
  padding: 4px 8px;
  border-radius: 9999px;
  font-size: 11px;
  white-space: nowrap;
  z-index: 45;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.overlay-item.selected .item-toolbar,
.overlay-item:hover .item-toolbar {
  display: flex;
}

/* Aesthetic Radial Pie Menu */
.pie-menu-container {
  position: fixed;
  width: 220px;
  height: 220px;
  margin-left: -110px;
  margin-top: -110px;
  pointer-events: none;
  z-index: 60;
  transform: scale(0.5);
  opacity: 0;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.15s ease;
}

.pie-menu-container.open {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}

.pie-center-ring {
  position: absolute;
  inset: 28px;
  border-radius: 9999px;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

.pie-slice-btn {
  position: absolute;
  width: 54px;
  height: 54px;
  margin-left: -27px;
  margin-top: -27px;
  border-radius: 9999px;
  background: rgba(30, 41, 59, 0.95);
  color: #f8fafc;
  border: 1.5px solid rgba(148, 163, 184, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.1;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.pie-slice-btn:hover {
  transform: scale(1.16);
  background: #2563eb;
  border-color: #93c5fd;
  z-index: 5;
}

/* Native Text Hotspot */
.native-text-hotspot {
  position: absolute;
  cursor: text;
  border: 1px dashed rgba(245, 158, 11, 0.6);
  background-color: rgba(245, 158, 11, 0.08);
}

.native-text-hotspot:hover {
  border-color: #d97706;
  background-color: rgba(245, 158, 11, 0.24);
}

.overlay-item.selected {
  outline: 1.5px dashed #2563eb;
}
.overlay-item .item-toolbar {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 40;
  background: #0f172a;
  color: #fff;
  padding: 4px 6px;
  border-radius: 8px;
  align-items: center;
  gap: 4px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  white-space: nowrap;
}
.overlay-item.selected .item-toolbar {
  display: flex;
}
.overlay-item .resize-handle {
  display: none;
  position: absolute;
  width: 11px;
  height: 11px;
  background: #2563eb;
  border: 2px solid #ffffff;
  border-radius: 9999px;
  z-index: 45;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
.overlay-item.selected .resize-handle {
  display: block;
}
.handle-nw { top: -6px; left: -6px; cursor: nwse-resize; }
.handle-ne { top: -6px; right: -6px; cursor: nesw-resize; }
.handle-sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.handle-se { bottom: -6px; right: -6px; cursor: nwse-resize; }

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }