* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f7fafc;
}

#viewport {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
}

/* ---------- overlay 3D (handle + label dimensi) ---------- */
#overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

#overlay > * {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: auto;
  will-change: transform;
}

#overlay > .hidden {
  display: none;
}

.handle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: #1a6cf5;
  color: #fff;
  font-size: 20px;
  line-height: 34px;
  text-align: center;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(26, 108, 245, 0.45);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.handle:active {
  cursor: grabbing;
  background: #0f56cf;
}

#h-e, #h-w { cursor: ew-resize; }
#h-n, #h-s { cursor: ns-resize; }
#h-t { cursor: n-resize; }

.dim-label {
  background: #1a6cf5;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 10px;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(26, 108, 245, 0.35);
  user-select: none;
  -webkit-user-select: none;
}

.dim-label-h {
  background: #475569;
  box-shadow: 0 2px 8px rgba(71, 85, 105, 0.35);
}

.dim-label-draw {
  background: #0f172a;
  pointer-events: none !important;
  font-size: 13px;
  padding: 4px 10px;
}

.btn.active {
  background: #1a6cf5;
  border-color: #1a6cf5;
  color: #fff;
}

body.drawing #viewport {
  cursor: crosshair;
}

/* ---------- UI chrome ---------- */
#topbar {
  position: fixed;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  gap: 10px;
  pointer-events: none;
}

.pill {
  pointer-events: auto;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill.option {
  margin-left: auto;
  font-weight: 500;
}

.pill .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #1a6cf5;
  display: inline-block;
}

#toolbar {
  position: fixed;
  bottom: 56px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 8px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}

.btn {
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #1e293b;
  font-size: 15px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
}

.btn:hover {
  background: #f1f5f9;
}

.btn.primary {
  background: #1a6cf5;
  border-color: #1a6cf5;
  color: #fff;
}

.btn.primary:hover {
  background: #0f56cf;
}

#zoombar {
  position: fixed;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#zoombar .btn {
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 20px;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
}

#hint {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: #64748b;
  background: rgba(255, 255, 255, 0.85);
  padding: 5px 12px;
  border-radius: 10px;
  white-space: nowrap;
  max-width: 96vw;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
