
#main-area {
  position: fixed; top: var(--top-h); left: 0; right: 0; bottom: 0;
  overflow: hidden;
}

#canvas-wrap {
  position: absolute; top: 0; bottom: 0; left: 0; right: 0;
  overflow: hidden; touch-action: none;
}
#canvas-container {
  position: absolute; inset: 0;
  overflow: hidden; cursor: default;
  background: radial-gradient(circle, #b8b8b8 1px, transparent 1px) 0 0 / 28px 28px, #e5e5e5;
}
#canvas-container.space-pan-ready { cursor: grab !important; }
#canvas-container.panning { cursor: grabbing !important; }
#canvas-container.edging  { cursor: crosshair !important; }
#world { position: absolute; top: 0; left: 0; transform-origin: 0 0; z-index: 3; }

#edges-svg, #temp-svg, #overlay-svg {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; overflow: visible; transform-origin: 0 0;
}
#edges-svg   { z-index: 2; }
#temp-svg    { z-index: 7; }
#overlay-svg { z-index: 8; }
#edges-svg path.edge-path { pointer-events: none; }
#edges-svg path.edge-hit  { pointer-events: stroke; stroke-width: 18px; cursor: pointer; }

.group-overlay-rect {
  fill: none; stroke: #4caf50; stroke-width: 2; stroke-dasharray: 8 6;
  opacity: 0.6;
}

#temp-svg circle.edge-end-handle,
#temp-svg circle.edge-start-handle {
  fill: transparent; stroke: none;
  pointer-events: auto; cursor: crosshair;
}

#edges-svg circle.edge-waypoint {
  fill: #666; stroke: #252525; stroke-width: 1.5px;
  pointer-events: auto; cursor: grab;
  transition: fill 0.1s;
}
#edges-svg circle.edge-waypoint:hover,
#edges-svg circle.edge-waypoint.hi { fill: #4a9eff; }

#fit-bounds-svg {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 7; overflow: visible;
}
.fit-bounds-rect {
  fill: none; stroke: #4a9eff; stroke-width: 1.5; stroke-dasharray: 20 12;
  opacity: 0; transition: opacity 0.35s ease;
}
.fit-bounds-rect.show { opacity: 1; }

#smart-guides-svg {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 7; overflow: visible;
}
.smart-guide-line { stroke: #ff2e7e; stroke-width: 1; shape-rendering: crispEdges; }
.smart-guide-mark-main { stroke: #ff2e7e; stroke-width: 1; stroke-dasharray: 3 2; shape-rendering: crispEdges; }
.smart-guide-mark-tick { stroke: #ff2e7e; stroke-width: 1; shape-rendering: crispEdges; }

#canvas-ctrl-wrap {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 400;
}
#canvas-ctrl {
  background: #2d2d2d; border-radius: 10px; padding: 7px 12px;
  display: flex; align-items: center; gap: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
#canvas-ctrl button {
  padding: 5px 11px; border: 1px solid #555; border-radius: 5px;
  background: #444; color: #eee; font-size: 13px; cursor: pointer;
  transition: background 0.12s; white-space: nowrap;
}
#canvas-ctrl button:hover { background: #5a5a5a; }
#canvas-ctrl button.active { background: #2c5282; border-color: #4a9eff; color: #fff; }
#zoom-label {
  color: #bbb; font-size: 12px; min-width: 38px; text-align: center;
  cursor: pointer; border-radius: 4px; padding: 2px 4px; transition: background 0.12s;
  background: rgba(255,255,255,0.06);
}
#zoom-label:hover { background: rgba(255,255,255,0.12); color: #fff; }
.cc-sep { width: 1px; height: 22px; background: #555; }

#topo-opts-bar {
  background: rgba(45,45,45,0.97); border-radius: 8px; padding: 5px 12px;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}
#topo-opts-bar button {
  padding: 4px 10px; border: 1px solid #555; border-radius: 5px;
  background: #444; color: #eee; font-size: 12px; cursor: pointer;
  transition: background 0.12s; white-space: nowrap;
}
#topo-opts-bar button:hover { background: #5a5a5a; }
.topo-opts-sep { width: 1px; height: 18px; background: #555; }

.topo-gap-ctrl {
  display: flex; align-items: center; gap: 6px; color: #bbb; font-size: 12px;
}
.topo-gap-ctrl label { display: flex; align-items: center; gap: 3px; white-space: nowrap; }
.topo-gap-ctrl input[type="number"] {
  width: 44px; padding: 3px 4px; border: 1px solid #555; border-radius: 4px;
  background: #333; color: #eee; font-size: 12px; text-align: center;
  -moz-appearance: textfield;
}
.topo-gap-ctrl input[type="number"]::-webkit-inner-spin-button { opacity: 0.5; }
